Authored by yyq

Merge remote-tracking branch 'origin/feature/newsDetail' into feature/seo1113

... ... @@ -541,6 +541,13 @@ module.exports = class extends global.yoho.BaseModel {
navUrl: urlHelper.listUrl(channel, cat.id)
});
}
list.push({
typeId: 0,
type: '资讯',
isActive: false,
navUrl: helpers.urlFormat('/guang/news')
});
}
return list;
... ...
... ... @@ -19,7 +19,7 @@ exports.index = (req, res, next) => {
}
return res.render('news-index', Object.assign({
title: '潮流资讯 | ' + (res.locals.title || ''),
title: '资讯 | ' + (res.locals.title || ''),
module: 'news',
page: 'index'
}, result));
... ...
... ... @@ -7,6 +7,8 @@ const NewsAPi = require('./news-api');
const utils = require('./utils');
const moment = require('moment');
const searchHandler = require('../../product/models/search-handler');
const hotBrandsModel = require('../../../doraemon/models/hot-brands');
const redis = global.yoho.redis;
const BOYS = 'boys';
const GIRLS = 'girls';
... ... @@ -57,9 +59,9 @@ module.exports = class extends global.yoho.BaseModel {
pathTitle: 'YOHO!BUY 有货'
},
{
href: helpers.urlFormat('/news'),
name: '潮流资讯',
pathTitle: '潮流资讯'
href: helpers.urlFormat('/guang/news'),
name: '资讯',
pathTitle: '资讯'
}
]).concat(subNav || []);
... ... @@ -80,7 +82,7 @@ module.exports = class extends global.yoho.BaseModel {
lresult = {
id: articleData.id,
classification: _.get(articleData, 'min_category_name', '') || _.get(articleData, 'category_name', ''),
url: helpers.urlFormat(`/news/${articleData.id}_${articleData.cid}.html`),
url: helpers.urlFormat(`/guang/news/${articleData.id}_${articleData.cid}.html`),
img: helpers.image(articleData.image, width, height, 1),
title: articleData.title,
pTime: articleData.update_time && moment(articleData.update_time * 1000).format('YYYY年MM月DD HH:mm'),
... ... @@ -99,7 +101,8 @@ module.exports = class extends global.yoho.BaseModel {
let list = _.map(_.get(res, 'data[0].data', []), (it) => {
return {
img: helpers.image(it.src, 640, 640, 1),
url: it.url
url: it.url,
alt: it.alt
};
});
... ... @@ -121,8 +124,6 @@ module.exports = class extends global.yoho.BaseModel {
getIndexList(channel, param) {
let newsAPi = new NewsAPi(this.ctx);
let params = {
type: 'wechat',
limit: 20,
page: param.page || 1
};
... ... @@ -137,7 +138,11 @@ module.exports = class extends global.yoho.BaseModel {
content_code: ADS_CODE[channel] || ADS_CODE.boys,
isAdDegrade: _.get(this.ctx, 'req.app.locals.pc.guang.removeAd', false)
}),
newsAPi.getPolymerizationList(Object.assign({}, params, {id: ATYPE})),
newsAPi.getPolymerizationList(Object.assign({}, params, {
type: 'wechat',
limit: 20,
id: ATYPE
})),
];
return Promise.all(apiMethod).then(result => {
... ... @@ -168,6 +173,7 @@ module.exports = class extends global.yoho.BaseModel {
title: contents.title,
summary: contents.summary,
tag: contents.tag,
syncTypeName: contents.syncTypeName || 'YOHO潮流志',
time: contents.update_time && moment(contents.update_time * 1000).format('YYYY年MM月DD HH:mm'),
};
let content = utils.filterPhtml(contents.content, [
... ... @@ -176,7 +182,31 @@ module.exports = class extends global.yoho.BaseModel {
'点这里'
]);
return {header: header, content: utils.filterAhtml(content)};
content = utils.filterAhtml(content);
return {header: header, content: utils.imgAlt(content, contents.title, 5)};
}
// 潮流详情
getContentDetail(newsAPi, params) {
return redis.all([
['get', `global:yoho:news:detail:${params.id}-${params.cid}`]
]).then(redisData => {
redisData = JSON.parse(redisData[0] || '{}');
if (!redisData.data) {
return newsAPi.getContentDetail(params);
}
return redisData;
});
}
// 获取热销品牌
_getHotBrands() {
return {recommendKeywords: {
keywordsTitle: '热销品牌',
keywords: _.map(hotBrandsModel.hotBrands(), item => {
return Object.assign({}, item, {keyword: item.title});
})
}};
}
detail(channel, param) {
... ... @@ -196,7 +226,7 @@ module.exports = class extends global.yoho.BaseModel {
content_code: ADS_CODE[channel] || ADS_CODE.boys,
isAdDegrade: _.get(this.ctx, 'req.app.locals.pc.guang.removeAd', false)
}),
newsAPi.getContentDetail(params)
this.getContentDetail(newsAPi, params)
];
return Promise.all(apiMethod).then(result => {
... ... @@ -214,11 +244,14 @@ module.exports = class extends global.yoho.BaseModel {
// 详情页数据
Object.assign(responseData, this._formatDetail(result[3], params));
// 热销品牌
Object.assign(responseData, this._getHotBrands());
// 导航pathNav
let title = _.get(responseData, 'header.title', '潮流资讯详情页');
let title = _.get(responseData, 'header.title', '资讯详情页');
Object.assign(responseData, this.getPathNav(channel, [{
href: helpers.urlFormat('/news'),
href: helpers.urlFormat('/guang/news'),
name: title,
pathTitle: title
}]));
... ...
... ... @@ -23,7 +23,10 @@ const util = {
});
return $.html();
html = $.html();
$ = '';
return html;
},
// 过滤 a标签连接和删除html标签中的script和link脚本
... ... @@ -34,9 +37,33 @@ const util = {
let $ = cheerio.load(html, {decodeEntities: false});
$('a').attr('href', 'javascript:void(0);').css({cursor: 'text'});// eslint-disable-line
$('a:not(.a-anchor)').removeAttr('style').attr('href', 'javascript:void(0);').css({cursor: 'text'});// eslint-disable-line
$('script,link').remove();
return $.html();
html = $.html();
$ = '';
return html;
},
// 过滤 a标签连接和删除html标签中的script和link脚本
imgAlt: (html, alt, num) => {
if (!html) {
return html;
}
let $ = cheerio.load(html, {decodeEntities: false});
_.each($('img').slice(0, num), item => {
let $dom = $(item);
$dom.attr('alt', $dom.attr('alt') || alt);
});
html = $.html();
$ = '';
return html;
}
};
... ...
<div class="news-detail-page news-page yoho-page clearfix">
{{> common/path-nav}}
<div class="left-side detail-body" data-id="{{id}}">
{{# header}}
<h1 class="detail-title">{{title}}</h1>
<div class="article-info clearfix">
{{#if authorUrl}}
<div class="article-author">
<div class="author-avatar">
<a href="{{authorUrl}}" target="_blank">
<img src="http:{{image2 avatar}}">
</a>
</div>
{{> common/path-nav}}
<div class="left-side detail-body" data-id="{{id}}">
{{# header}}
<h1 class="detail-title">{{title}}</h1>
<div class="article-info clearfix">
{{#if authorUrl}}
<div class="article-author">
<div class="author-avatar">
<a href="{{authorUrl}}" target="_blank">
<img src="http:{{image2 avatar}}">
</a>
</div>
<div class="author-info">
<a class="author-name" href="{{authorUrl}}">{{name}}</a>
</div>
{{/if}}
<div class="article-status clearfix">
{{#if time}}
<span class="article-time">
<i class="iconfont">&#xe625;</i>
{{time}}
</span>
{{/if}}
{{#if click}}
<span class="article-click">点击:<em>{{click}}</em></span>
{{/if}}
{{#if commentNum}}
<a href="#comment-info" id="article-comment" class="article-comment"><em class="comment-num">{{commentNum}}</em>条评论</a>
{{/if}}
</div>
<div class="author-info">
<a class="author-name" href="{{authorUrl}}">{{name}}</a>
</div>
{{/if}}
{{#if syncTypeName}}
<div class="article-source">来源于微信公众号:{{syncTypeName}}</div>
{{/if}}
<div class="article-status clearfix">
{{#if time}}
<span class="article-time">
<i class="iconfont">&#xe625;</i>
{{time}}
</span>
{{/if}}
{{#if click}}
<span class="article-click">点击:<em>{{click}}</em></span>
{{/if}}
{{#if commentNum}}
<a href="#comment-info" id="article-comment" class="article-comment"><em class="comment-num">{{commentNum}}</em>条评论</a>
{{/if}}
</div>
{{/ header}}
<div class="article-main">
{{{content}}}
</div>
{{/ header}}
<div class="article-main">
{{{content}}}
</div>
<div class="right-side detail-side">
{{> news-right-side}}
</div>
</div>
<div class="right-side detail-side">
{{> news-right-side}}
</div>
<div class="hot-brand">
{{> product/rec-keywords}}
</div>
</div>
... ...
... ... @@ -7,12 +7,12 @@
<div class="type-icon fashion-man"></div>
{{/if}}
<a href="{{url}}" target="_blank">
<img class="lazy{{#if isSquareImg}} square{{/if}}" data-original="http:{{image2 img}}">
<img class="lazy{{#if isSquareImg}} square{{/if}}" data-original="http:{{image2 img}}" alt="{{title}}">
{{#if isVideo}}<i class="video-icon"></i>{{/if}}
</a>
</div>
<div class="msg-info">
<a class="msg-title" href="{{url}}" target="_blank">{{title}}</a>
<a class="msg-title" href="{{url}}" target="_blank" title="{{title}}">{{title}}</a>
<p class="msg-app">
{{#if editorUrl}}
<a href="{{editorUrl}}" target="_blank">
... ...
... ... @@ -4,11 +4,11 @@
{{# exRecos}}
<div class="ex-reco-item clearfix">
{{#if img}}
<a class="ex-reco-img" href="{{url}}" target="_blank">
<a class="ex-reco-img" href="{{url}}" target="_blank" title="{{title}}">
<span class="bg-img" style="background-image:url({{image2 img}})"></span>
</a>
{{/if}}
<a href="{{url}}" target="_blank">
<a href="{{url}}" target="_blank" title="{{title}}">
<p class="ex-reco-context">{{title}}</p>
</a>
</div>
... ... @@ -19,7 +19,7 @@
<div class="ads">
{{# ads}}
<a class="ad" href="{{url}}" target="_blank">
<img class="lazy" data-original="{{image2 img}}">
<img class="lazy" data-original="{{image2 img}}" alt="{{alt}}">
</a>
{{/ ads}}
</div>
... ...
... ... @@ -518,7 +518,7 @@ function getSearchKeywordDataById(id, params, channel) {
}
// 前10的热销品牌
Object.assign(resData.search.leftContent, searchHandler.hotBrands(hotBrandsModel.hotBrands()));
Object.assign(resData.search.leftContent, searchHandler.hotBrands(hotBrandsModel.hotBrands().slice(0, 10)));
return resData;
}).bind(this)();
... ...
... ... @@ -16,8 +16,8 @@ module.exports = app => {
app.use(require('./apps/passport')); // 登录注册
app.use('/home', require('./apps/home')); // 会员中心
app.use(require('./apps/brands')); // 品牌一览
app.use('/guang/news', require('./apps/news')); // seo-潮流资讯页
app.use('/guang', require('./apps/guang')); // 逛
app.use('/news', require('./apps/news')); // seo-潮流资讯页
app.use('/cart', require('./apps/cart'));// 购物车
app.use('/help', require('./apps/help'));// 帮助中心
app.use('/shop', require('./apps/shop'));// 店铺
... ...
... ... @@ -5,6 +5,8 @@
*/
'use strict';
const helpers = global.yoho.helpers;
/**
* 热销品牌
*/
... ... @@ -13,54 +15,104 @@ const hotBrands = () => {
return [
{
url: '//www.yohobuy.com/shop/vans-1284.html',
url: helpers.urlFormat('/shop/vans-1284.html'),
image: `//img10.static.yhbimg.com/yhb-img01/2016/03/24/15/01ef24d3ec4caabd8c416901cdf4739917.jpg${imgView}`,
title: 'VANS/范斯'
},
{
url: '//www.yohobuy.com/shop/madness-1482.html',
url: helpers.urlFormat('/shop/madness-1482.html'),
image: `//img11.static.yhbimg.com/yhb-img01/2015/12/07/10/01e12663e56ae7c559ac72de209b6bf787.jpg${imgView}`,
title: 'MADNESS'
},
{
url: '//www.yohobuy.com/shop/hipanda-1488.html',
url: helpers.urlFormat('/shop/hipanda-1488.html'),
image: `//img11.static.yhbimg.com/yhb-img01/2017/11/06/09/01a9ea04b54af0c2830041678ff8e1b6a2.jpg${imgView}`,
title: 'HIPANDA/你好熊猫'
},
{
url: '//www.yohobuy.com/shop/dickies-1474.html',
url: helpers.urlFormat('/shop/dickies-1474.html'),
image: `//img10.static.yhbimg.com/yhb-img01/2017/11/03/11/018c06003f58b0a5087258ed21f63fde7b.jpg${imgView}`,
title: 'Dickies/迪凯斯'
},
{
url: '//www.yohobuy.com/shop/viishow-1360.html',
url: helpers.urlFormat('/shop/viishow-1360.html'),
image: `//img11.static.yhbimg.com/yhb-img01/2017/11/06/10/012ca25acd7958b8b499f80a40c28de059.jpg${imgView}`,
title: 'viishow/维秀'
},
{
url: '//www.yohobuy.com/shop/dusty-97.html',
url: helpers.urlFormat('/shop/dusty-97.html'),
image: `//img10.static.yhbimg.com/yhb-img01/2017/11/02/17/01eaa0d064e0a59ea683686637271eede0.jpg${imgView}`,
title: 'DUSTY/DUSTY潮牌'
},
{
url: '//www.yohobuy.com/shop/adidas-1258.html',
url: helpers.urlFormat('/shop/adidas-1258.html'),
image: `//img10.static.yhbimg.com/yhb-img01/2017/10/31/10/013ec61b8ccd4440db11c9ab2371c3605d.jpg${imgView}`,
title: 'adidas Originals/阿迪达斯'
},
{
url: '//www.yohobuy.com/shop/genanx-300.html',
url: helpers.urlFormat('/shop/genanx-300.html'),
image: `//img11.static.yhbimg.com/yhb-img01/2017/10/31/10/0183880efb53bb6e13fce74b670aef1cff.jpg${imgView}`,
title: 'Genanx/格男仕'
},
{
url: '//www.yohobuy.com/shop/glemall-2380.html',
url: helpers.urlFormat('/shop/glemall-2380.html'),
image: `//img10.static.yhbimg.com/yhb-img01/2017/11/03/09/0127a25d415d0e5a70fb26dc43ac1a5663.jpg${imgView}`,
title: 'GLEMALL'
},
{
url: '//www.yohobuy.com/shop/puma-1534.html',
url: helpers.urlFormat('/shop/puma-1534.html'),
image: `//img11.static.yhbimg.com/yhb-img01/2017/10/31/10/01e78f852cf69a57fefe71dcb8aab4b457.jpg${imgView}`,
title: 'PUMA/彪马'
},
{
url: helpers.urlFormat('/shop/thething-1330.html'),
image: `//img10.static.yhbimg.com/yhb-img01/2017/11/06/10/018cedbc8d32fb54edc54cc9e75c726464.jpg${imgView}`,
title: 'THETHING'
},
{
url: helpers.urlFormat('/shop/stussy-1292.html'),
image: `//img11.static.yhbimg.com/yhb-img01/2017/11/02/17/01f0487eefeecfc15ab3f8559317a8a3dc.jpg${imgView}`,
title: 'Stussy/斯图西'
},
{
url: helpers.urlFormat('/shop/converse-1252.html'),
image: `//img10.static.yhbimg.com/yhb-img01/2017/10/31/10/01b21a4da5297218adf33bedca11e09ce5.jpg${imgView}`,
title: 'Converse/匡威'
},
{
url: helpers.urlFormat('/shop/akop-2222.html'),
image: `//img11.static.yhbimg.com/yhb-img01/2017/11/03/09/0168a4088b1db414fac91286addb44fbe5.jpg${imgView}`,
title: 'AKOP'
},
{
url: helpers.urlFormat('/shop/timberland-2642.html'),
image: `//img10.static.yhbimg.com/yhb-img01/2017/11/06/10/017f4e8f44cf9f3f273d149ad57aa10257.jpg${imgView}`,
title: 'Timberland/添柏岚'
},
{
url: helpers.urlFormat('/shop/levis-1248.html'),
image: `//img11.static.yhbimg.com/yhb-img01/2017/11/06/09/011ead0b91f6f2cf776eb295555121e47e.jpg${imgView}`,
title: 'Levi’s/李维斯'
},
{
url: helpers.urlFormat('/shop/dc-275.html'),
image: `//img11.static.yhbimg.com/yhb-img01/2017/10/31/10/01f1bb407957dc717119ab9d32ea3f95fd.jpg${imgView}`,
title: 'DC/DCSHOECOUSA'
},
{
url: helpers.urlFormat('/shop/guuka-492.html'),
image: `//img11.static.yhbimg.com/yhb-img01/2017/11/02/17/01fcb145bf9e9276549468702b1ec57a7e.jpg${imgView}`,
title: 'Guuka/古由卡'
},
{
url: helpers.urlFormat('/shop/lal-1540.html'),
image: `//img10.static.yhbimg.com/yhb-img01/2017/11/02/16/013acf2a31ab930d34a80b2d87bfe4a9a9.jpg${imgView}`,
title: 'Life·After Life'
},
{
url: helpers.urlFormat('/shop/redcharcoal-2996.html'),
image: `//img10.static.yhbimg.com/yhb-img01/2017/10/31/10/01a8b7f3f496fbeb7a681aeacb9ea9aba5.jpg${imgView}`,
title: 'Red Charcoal'
}
];
};
... ...
{{# recommendKeywords}}
<div class="recommend-keywords">
<h3>{{#if keywordsTitle}}{{keywordsTitle}}{{^}}相关推荐{{/if}}</h3>
<p>
{{# keywords}}
<a href="{{url}}" title="{{keyword}}" target="_blank" class="keyword">{{keyword}}</a>
{{/ keywords}}
</p>
</div>
{{/recommendKeywords}}
... ...
... ... @@ -264,3 +264,7 @@ $('#comment-info').keyup(function() {
// init
$('#comment-info').trigger('keyup');
$(function() {
$('.guang-detail-page .article-main').find('a.a-anchor').attr({target: '_blank'});
});
... ...
var $ = require('yoho-jquery');
require('../common');
require('./img-blink');
require('./right-side');
$(function() {
$('.news-detail-page .article-main').find('a.a-anchor').attr({target: '_blank'});
});
... ...
... ... @@ -163,6 +163,7 @@
display: block;
width: 360px;
height: 240px;
color: #fff;
}
img.square {
... ...
... ... @@ -52,7 +52,7 @@
}
.detail-title {
font-size: 28px;
font-size: 26px;
line-height: 50px;
border-bottom: 1px dotted #c1c1c1;
word-wrap: break-word;
... ... @@ -99,6 +99,14 @@
}
}
.article-source {
float: left;
height: 64px;
line-height: 64px;
color: #999;
font-size: 13px;
}
.article-status {
float: right;
height: 64px;
... ... @@ -119,9 +127,11 @@
.article-main {
img {
display: block;
max-width: 100%;
margin: 0 auto;
height: auto;
width: auto;
max-width: 100%;
color: #fff;
}
.article-text {
... ... @@ -556,5 +566,10 @@
margin-bottom: 0;
}
}
.hot-brand {
width: 100%;
overflow: hidden;
}
}
... ...
@import "base";
@import "detail";
@import "recommend-keywords";
... ...
.recommend-keywords {
margin: 30px 0 20px;
border: 1px #e0e0e0 solid;
h3 {
height: 46px;
border-bottom: 1px #e0e0e0 solid;
line-height: 44px;
background: #f5f5f5;
text-align: center;
font-size: 15px;
}
p {
padding: 10px;
.keyword {
display: inline-block;
margin: 5px 15px;
font-size: 12px;
width: 150px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.common {
display: inline-block;
margin: 5px 15px;
font-size: 12px;
width: 190px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
}
}
... ...