Authored by 周少峰

Merge branch 'feature/guangDev' into release/5.8

... ... @@ -35,6 +35,7 @@ exports.index = (req, res, next) => {
Promise.all([
reqCtx.getBanner(channel),
reqCtx.getCategory(type, channel),
reqCtx.getTopList(gender, uid, udid, page, true),
reqCtx.getArticleList(gender, type, uid, udid, page, '', '', pageSize, channel, true),
reqCtx.getHotTags(page, pageSize, channel, isHotDegrade),
reqCtx.getAds(channel, isAdDegrade),
... ... @@ -42,7 +43,7 @@ exports.index = (req, res, next) => {
headerModel.requestHeaderData(channel)
]).then(ret => {
if (_.isEmpty(ret[2]) || _.isEmpty(ret[2].msgs)) {
if (_.get(ret[2], 'msgs') || _.get(ret[3], 'msgs')) {
res.set('Cache-Control', 'no-cache');
}
... ... @@ -52,10 +53,11 @@ exports.index = (req, res, next) => {
guang: {
slider: ret[0],
msgTypes: ret[1],
msgs: ret[2] && ret[2].msgs,
hotTags: ret[3],
ads: ret[4],
exRecos: ret[5],
msgs: (+type === 0 && +page === 1) ?
_.concat(ret[2] && ret[2].msgs, ret[3] && ret[3].msgs) : ret[3] && ret[3].msgs,
hotTags: ret[4],
ads: ret[6],
exRecos: ret[6],
guangIndexPage: true,
pageSize: pageSize,
... ... @@ -63,11 +65,11 @@ exports.index = (req, res, next) => {
pathNav: pathNav,
baseUrl: urlHelper.listUrl(channel, type),
page: page,
total: (ret[2] && ret[2].total) || 0
total: (ret[3] && ret[3].total) || 0
},
module: 'guang',
page: 'guang',
headerData: ret[6] && ret[6].headerData
headerData: ret[7] && ret[7].headerData
}));
}).catch(next);
... ... @@ -215,7 +217,7 @@ exports.detail = (req, res, next) => {
}
if (pjax) {
req.ctx(guangModel).getArticleComments(id, page, pageSize).then(ret => {
req.ctx(guangModel).getArticleComments(uid, id, page, pageSize).then(ret => {
res.set('Cache-Control', 'no-cache');
res.render('guang/detail-comment', {
... ... @@ -248,7 +250,7 @@ exports.detail = (req, res, next) => {
headerModel.requestHeaderData(channel),
reqCtx.getArticleContent(id),
reqCtx.getHotTags(1, 20, channel, isHotDegrade),
reqCtx.getArticleComments(id, page, pageSize),
reqCtx.getArticleComments(uid, id, page, pageSize),
reqCtx.getArticleBaseInfo(id, uid, udid),
reqCtx.getArticleRelateBrand(id),
reqCtx.getRecoArticles(gender, 1, 10, channel),
... ... @@ -390,7 +392,7 @@ exports.comment = (req, res) => {
req.session['comment_' + udid] = null;
}
return req.ctx(guangModel).getArticleComments(id, 1, 20);
return req.ctx(guangModel).getArticleComments(uid, id, 1, 20);
}).then(commentInfo => {
res.render('guang/detail-comment', {
... ...
/**
* Created by TaoHuang on 2016/11/3.
*/
'use strict';
module.exports = (url, width, height) => {
width = width || 750;
height = height || 420;
return `<div class="video-wrap">
<a href="javascript:;" class="video-close-btn"></a>
<object id="video_0" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab"
classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">
<param value="http://rescdn.yohoboys.com/res/new/boys/swf/util/VideoPlayerNew.swf?id=video_0&amp;url=${url}&amp;language=1&amp;sharepic=http://img01.yohoboys.com/contentimg/2016/06/12/14/0183fabea5332c5902cdd1d0d7fb63df04.jpg?imageMogr2/thumbnail/738x424|watermark/1/image/aHR0cDovL3Jlc2Nkbi55b2hvYm95cy5jb20vcmVzL25ldy9ib3lzL2ltYWdlcy9iYW5uZXJwbGF5LnBuZw==/dissolve/100/gravity/Center/dx/10/dy/10&amp;title1=Meet...Cody Sanderson &amp;shareurl=http://www.yohoboys.com/channel/detail/index/id/10657/time/1478052894&amp;coverpic=http://img01.yohoboys.com/contentimg/2016/06/12/14/0183fabea5332c5902cdd1d0d7fb63df04.jpg"
name="movie">
<param value="high" name="quality">
<param value="#ffffff" name="bgcolor">
<param name="allowFullScreen" value="true">
<param value="always" name="allowScriptAccess">
<param value="transparent" name="wmode">
<embed style="width: ${width}px;height: ${height}px; display:block; margin:0 auto;" id="flash" align="middle" pluginspage="http://www.macromedia.com/go/getflashplayer"
type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" loop="false"
play="true" bgcolor="#ffffff" quality="high" wmode="transparent" name="vMessage"
src="http://rescdn.yohoboys.com/res/new/boys/swf/util/VideoPlayerNew.swf?id=video_0&amp;url=${url}&amp;language=1&amp;sharepic=http://img01.yohoboys.com/contentimg/2016/06/12/14/0183fabea5332c5902cdd1d0d7fb63df04.jpg?imageMogr2/thumbnail/738x424|watermark/1/image/aHR0cDovL3Jlc2Nkbi55b2hvYm95cy5jb20vcmVzL25ldy9ib3lzL2ltYWdlcy9iYW5uZXJwbGF5LnBuZw==/dissolve/100/gravity/Center/dx/10/dy/10&amp;title1=Meet...Cody Sanderson &amp;shareurl=http://www.yohoboys.com/channel/detail/index/id/10657/time/1478052894&amp;coverpic=${url}?vframe/jpg/offset/0">
</object>
</div> `;
};
... ...
... ... @@ -9,6 +9,7 @@ const _ = require('lodash');
const moment = require('moment');
const ghelper = require('./guang-helper');
const urlHelper = require('./url-helper');
const videoPlayerTpl = require('../helpers/video-player-tpl');
const helpers = global.yoho.helpers;
... ... @@ -324,6 +325,60 @@ module.exports = class extends global.yoho.BaseModel {
}
/**
* 获取最新置顶文章
*/
getTopList(gender, uid, udid, page, useCache) {
uid = uid || 0;
udid = udid || '';
page = page || 1;
useCache = useCache || false;
let param = {
gender: gender,
uid: uid,
udid: udid,
page: page,
client_type: 'web'
};
return this.get({
url: 'guang/api/v2/article/getTopList',
data: param,
param: {
cache: useCache ? 300 : false
},
api: global.yoho.ServiceAPI
}).then(res => {
if (res && res.data) {
let artList,
total = 0;
if (res.data.total) {
total = _.parseInt(res.data.total);
}
if (res.data.list) {
let list = res.data.list;
if (list.artList) {
artList = _.map(list.artList, it => this._formatArticle(it, true, false, ''));
}
}
return {
msgs: artList,
total: total
};
}
return null;
});
}
/**
* 获取热门标签数据
* @param {String} type 传入频道页类型,值可以是: boys, girls, kids, lifestyle
* @return {Object}
... ... @@ -610,7 +665,8 @@ module.exports = class extends global.yoho.BaseModel {
thumb: helpers.image(val.default_images, 235, 314),
product_name: val.product_name,
sales_price: val.sales_price,
url: helpers.getUrlBySkc(val.product_skn)
url: (val.is_global !== 'Y') ? helpers.getUrlBySkc(val.product_skn) :
helpers.urlFormat(`/product/global/${val.product_skn}.html`, null)
};
if (val.market_price !== val.sales_price) {
... ... @@ -636,6 +692,7 @@ module.exports = class extends global.yoho.BaseModel {
let data = {
method: 'web.search.search',
from: 'fuzzySearch',
order: 's_n_desc',
limit: 60
};
... ... @@ -715,6 +772,16 @@ module.exports = class extends global.yoho.BaseModel {
text: data => {
return data;
},
video: data => {
let result = {
video: []
};
result.video.push(videoPlayerTpl(data.src, 640, 480));
return result;
},
singleImage: data => {
if (data && data[0] && data[0].src) {
return {
... ... @@ -770,7 +837,10 @@ module.exports = class extends global.yoho.BaseModel {
_.forEach(it, (val, key) => {
if (key === 'goods') {
gpromises.push(that._articleContentFormat().goods(val.data));
gpromises.push(
that._articleContentFormat().goods(_.union(val.data, val.dataGlobal, val.dataLimit)));
return;
} else if (key === 'goodsGroup') {
// 可能包含多个list,则有多个promise
... ... @@ -870,8 +940,10 @@ module.exports = class extends global.yoho.BaseModel {
if (res && res.code === 200 && res.data) {
return _.map(res.data, it => {
it.thumb = it.thumb;
it.url = it.url;
it.url = (it.isGlobal !== 'Y') ? it.url :
helpers.urlFormat('/product/global/list', {brand: it.tbl_id});
return it;
});
}
... ... @@ -918,11 +990,14 @@ module.exports = class extends global.yoho.BaseModel {
/**
* 获取文章评论数据
*/
getArticleComments(aid, page, pageSize) {
getArticleComments(uid, aid, page, pageSize) {
uid = uid || 0;
page = page || 1;
pageSize = pageSize || 20;
let data = {
uid: uid,
article_id: aid,
page: page,
limit: pageSize
... ...
... ... @@ -25,6 +25,11 @@
<div class="article-main">
{{# content}}
{{# video}}
<div class="article-video block">
{{{.}}}
</div>
{{/ video}}
{{# pic}}
<div class="article-pic block">
<img class="lazy" data-original="{{image2 .}}">
... ...