Authored by 周少峰

Merge branch 'feature/guangDev' into release/5.8

@@ -35,6 +35,7 @@ exports.index = (req, res, next) => { @@ -35,6 +35,7 @@ exports.index = (req, res, next) => {
35 Promise.all([ 35 Promise.all([
36 reqCtx.getBanner(channel), 36 reqCtx.getBanner(channel),
37 reqCtx.getCategory(type, channel), 37 reqCtx.getCategory(type, channel),
  38 + reqCtx.getTopList(gender, uid, udid, page, true),
38 reqCtx.getArticleList(gender, type, uid, udid, page, '', '', pageSize, channel, true), 39 reqCtx.getArticleList(gender, type, uid, udid, page, '', '', pageSize, channel, true),
39 reqCtx.getHotTags(page, pageSize, channel, isHotDegrade), 40 reqCtx.getHotTags(page, pageSize, channel, isHotDegrade),
40 reqCtx.getAds(channel, isAdDegrade), 41 reqCtx.getAds(channel, isAdDegrade),
@@ -42,7 +43,7 @@ exports.index = (req, res, next) => { @@ -42,7 +43,7 @@ exports.index = (req, res, next) => {
42 headerModel.requestHeaderData(channel) 43 headerModel.requestHeaderData(channel)
43 ]).then(ret => { 44 ]).then(ret => {
44 45
45 - if (_.isEmpty(ret[2]) || _.isEmpty(ret[2].msgs)) { 46 + if (_.get(ret[2], 'msgs') || _.get(ret[3], 'msgs')) {
46 res.set('Cache-Control', 'no-cache'); 47 res.set('Cache-Control', 'no-cache');
47 } 48 }
48 49
@@ -52,10 +53,11 @@ exports.index = (req, res, next) => { @@ -52,10 +53,11 @@ exports.index = (req, res, next) => {
52 guang: { 53 guang: {
53 slider: ret[0], 54 slider: ret[0],
54 msgTypes: ret[1], 55 msgTypes: ret[1],
55 - msgs: ret[2] && ret[2].msgs,  
56 - hotTags: ret[3],  
57 - ads: ret[4],  
58 - exRecos: ret[5], 56 + msgs: (+type === 0 && +page === 1) ?
  57 + _.concat(ret[2] && ret[2].msgs, ret[3] && ret[3].msgs) : ret[3] && ret[3].msgs,
  58 + hotTags: ret[4],
  59 + ads: ret[6],
  60 + exRecos: ret[6],
59 61
60 guangIndexPage: true, 62 guangIndexPage: true,
61 pageSize: pageSize, 63 pageSize: pageSize,
@@ -63,11 +65,11 @@ exports.index = (req, res, next) => { @@ -63,11 +65,11 @@ exports.index = (req, res, next) => {
63 pathNav: pathNav, 65 pathNav: pathNav,
64 baseUrl: urlHelper.listUrl(channel, type), 66 baseUrl: urlHelper.listUrl(channel, type),
65 page: page, 67 page: page,
66 - total: (ret[2] && ret[2].total) || 0 68 + total: (ret[3] && ret[3].total) || 0
67 }, 69 },
68 module: 'guang', 70 module: 'guang',
69 page: 'guang', 71 page: 'guang',
70 - headerData: ret[6] && ret[6].headerData 72 + headerData: ret[7] && ret[7].headerData
71 })); 73 }));
72 }).catch(next); 74 }).catch(next);
73 75
@@ -215,7 +217,7 @@ exports.detail = (req, res, next) => { @@ -215,7 +217,7 @@ exports.detail = (req, res, next) => {
215 } 217 }
216 218
217 if (pjax) { 219 if (pjax) {
218 - req.ctx(guangModel).getArticleComments(id, page, pageSize).then(ret => { 220 + req.ctx(guangModel).getArticleComments(uid, id, page, pageSize).then(ret => {
219 221
220 res.set('Cache-Control', 'no-cache'); 222 res.set('Cache-Control', 'no-cache');
221 res.render('guang/detail-comment', { 223 res.render('guang/detail-comment', {
@@ -248,7 +250,7 @@ exports.detail = (req, res, next) => { @@ -248,7 +250,7 @@ exports.detail = (req, res, next) => {
248 headerModel.requestHeaderData(channel), 250 headerModel.requestHeaderData(channel),
249 reqCtx.getArticleContent(id), 251 reqCtx.getArticleContent(id),
250 reqCtx.getHotTags(1, 20, channel, isHotDegrade), 252 reqCtx.getHotTags(1, 20, channel, isHotDegrade),
251 - reqCtx.getArticleComments(id, page, pageSize), 253 + reqCtx.getArticleComments(uid, id, page, pageSize),
252 reqCtx.getArticleBaseInfo(id, uid, udid), 254 reqCtx.getArticleBaseInfo(id, uid, udid),
253 reqCtx.getArticleRelateBrand(id), 255 reqCtx.getArticleRelateBrand(id),
254 reqCtx.getRecoArticles(gender, 1, 10, channel), 256 reqCtx.getRecoArticles(gender, 1, 10, channel),
@@ -390,7 +392,7 @@ exports.comment = (req, res) => { @@ -390,7 +392,7 @@ exports.comment = (req, res) => {
390 req.session['comment_' + udid] = null; 392 req.session['comment_' + udid] = null;
391 } 393 }
392 394
393 - return req.ctx(guangModel).getArticleComments(id, 1, 20); 395 + return req.ctx(guangModel).getArticleComments(uid, id, 1, 20);
394 }).then(commentInfo => { 396 }).then(commentInfo => {
395 397
396 res.render('guang/detail-comment', { 398 res.render('guang/detail-comment', {
  1 +/**
  2 + * Created by TaoHuang on 2016/11/3.
  3 + */
  4 +
  5 +'use strict';
  6 +
  7 +module.exports = (url, width, height) => {
  8 + width = width || 750;
  9 + height = height || 420;
  10 + return `<div class="video-wrap">
  11 + <a href="javascript:;" class="video-close-btn"></a>
  12 + <object id="video_0" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab"
  13 + classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">
  14 + <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"
  15 + name="movie">
  16 + <param value="high" name="quality">
  17 + <param value="#ffffff" name="bgcolor">
  18 + <param name="allowFullScreen" value="true">
  19 + <param value="always" name="allowScriptAccess">
  20 + <param value="transparent" name="wmode">
  21 + <embed style="width: ${width}px;height: ${height}px; display:block; margin:0 auto;" id="flash" align="middle" pluginspage="http://www.macromedia.com/go/getflashplayer"
  22 + type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" loop="false"
  23 + play="true" bgcolor="#ffffff" quality="high" wmode="transparent" name="vMessage"
  24 + 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">
  25 + </object>
  26 + </div> `;
  27 +};
@@ -9,6 +9,7 @@ const _ = require('lodash'); @@ -9,6 +9,7 @@ const _ = require('lodash');
9 const moment = require('moment'); 9 const moment = require('moment');
10 const ghelper = require('./guang-helper'); 10 const ghelper = require('./guang-helper');
11 const urlHelper = require('./url-helper'); 11 const urlHelper = require('./url-helper');
  12 +const videoPlayerTpl = require('../helpers/video-player-tpl');
12 13
13 const helpers = global.yoho.helpers; 14 const helpers = global.yoho.helpers;
14 15
@@ -324,6 +325,60 @@ module.exports = class extends global.yoho.BaseModel { @@ -324,6 +325,60 @@ module.exports = class extends global.yoho.BaseModel {
324 } 325 }
325 326
326 /** 327 /**
  328 + * 获取最新置顶文章
  329 + */
  330 + getTopList(gender, uid, udid, page, useCache) {
  331 + uid = uid || 0;
  332 + udid = udid || '';
  333 + page = page || 1;
  334 + useCache = useCache || false;
  335 +
  336 + let param = {
  337 + gender: gender,
  338 + uid: uid,
  339 + udid: udid,
  340 + page: page,
  341 + client_type: 'web'
  342 + };
  343 +
  344 + return this.get({
  345 + url: 'guang/api/v2/article/getTopList',
  346 + data: param,
  347 + param: {
  348 + cache: useCache ? 300 : false
  349 + },
  350 + api: global.yoho.ServiceAPI
  351 +
  352 + }).then(res => {
  353 + if (res && res.data) {
  354 +
  355 + let artList,
  356 + total = 0;
  357 +
  358 + if (res.data.total) {
  359 + total = _.parseInt(res.data.total);
  360 + }
  361 +
  362 + if (res.data.list) {
  363 + let list = res.data.list;
  364 +
  365 + if (list.artList) {
  366 + artList = _.map(list.artList, it => this._formatArticle(it, true, false, ''));
  367 + }
  368 + }
  369 +
  370 + return {
  371 + msgs: artList,
  372 + total: total
  373 + };
  374 + }
  375 + return null;
  376 + });
  377 +
  378 +
  379 + }
  380 +
  381 + /**
327 * 获取热门标签数据 382 * 获取热门标签数据
328 * @param {String} type 传入频道页类型,值可以是: boys, girls, kids, lifestyle 383 * @param {String} type 传入频道页类型,值可以是: boys, girls, kids, lifestyle
329 * @return {Object} 384 * @return {Object}
@@ -610,7 +665,8 @@ module.exports = class extends global.yoho.BaseModel { @@ -610,7 +665,8 @@ module.exports = class extends global.yoho.BaseModel {
610 thumb: helpers.image(val.default_images, 235, 314), 665 thumb: helpers.image(val.default_images, 235, 314),
611 product_name: val.product_name, 666 product_name: val.product_name,
612 sales_price: val.sales_price, 667 sales_price: val.sales_price,
613 - url: helpers.getUrlBySkc(val.product_skn) 668 + url: (val.is_global !== 'Y') ? helpers.getUrlBySkc(val.product_skn) :
  669 + helpers.urlFormat(`/product/global/${val.product_skn}.html`, null)
614 }; 670 };
615 671
616 if (val.market_price !== val.sales_price) { 672 if (val.market_price !== val.sales_price) {
@@ -636,6 +692,7 @@ module.exports = class extends global.yoho.BaseModel { @@ -636,6 +692,7 @@ module.exports = class extends global.yoho.BaseModel {
636 692
637 let data = { 693 let data = {
638 method: 'web.search.search', 694 method: 'web.search.search',
  695 + from: 'fuzzySearch',
639 order: 's_n_desc', 696 order: 's_n_desc',
640 limit: 60 697 limit: 60
641 }; 698 };
@@ -715,6 +772,16 @@ module.exports = class extends global.yoho.BaseModel { @@ -715,6 +772,16 @@ module.exports = class extends global.yoho.BaseModel {
715 text: data => { 772 text: data => {
716 return data; 773 return data;
717 }, 774 },
  775 + video: data => {
  776 +
  777 + let result = {
  778 + video: []
  779 + };
  780 +
  781 + result.video.push(videoPlayerTpl(data.src, 640, 480));
  782 +
  783 + return result;
  784 + },
718 singleImage: data => { 785 singleImage: data => {
719 if (data && data[0] && data[0].src) { 786 if (data && data[0] && data[0].src) {
720 return { 787 return {
@@ -770,7 +837,10 @@ module.exports = class extends global.yoho.BaseModel { @@ -770,7 +837,10 @@ module.exports = class extends global.yoho.BaseModel {
770 837
771 _.forEach(it, (val, key) => { 838 _.forEach(it, (val, key) => {
772 if (key === 'goods') { 839 if (key === 'goods') {
773 - gpromises.push(that._articleContentFormat().goods(val.data)); 840 +
  841 + gpromises.push(
  842 + that._articleContentFormat().goods(_.union(val.data, val.dataGlobal, val.dataLimit)));
  843 +
774 return; 844 return;
775 } else if (key === 'goodsGroup') { 845 } else if (key === 'goodsGroup') {
776 // 可能包含多个list,则有多个promise 846 // 可能包含多个list,则有多个promise
@@ -870,8 +940,10 @@ module.exports = class extends global.yoho.BaseModel { @@ -870,8 +940,10 @@ module.exports = class extends global.yoho.BaseModel {
870 940
871 if (res && res.code === 200 && res.data) { 941 if (res && res.code === 200 && res.data) {
872 return _.map(res.data, it => { 942 return _.map(res.data, it => {
  943 +
873 it.thumb = it.thumb; 944 it.thumb = it.thumb;
874 - it.url = it.url; 945 + it.url = (it.isGlobal !== 'Y') ? it.url :
  946 + helpers.urlFormat('/product/global/list', {brand: it.tbl_id});
875 return it; 947 return it;
876 }); 948 });
877 } 949 }
@@ -918,11 +990,14 @@ module.exports = class extends global.yoho.BaseModel { @@ -918,11 +990,14 @@ module.exports = class extends global.yoho.BaseModel {
918 /** 990 /**
919 * 获取文章评论数据 991 * 获取文章评论数据
920 */ 992 */
921 - getArticleComments(aid, page, pageSize) { 993 + getArticleComments(uid, aid, page, pageSize) {
  994 +
  995 + uid = uid || 0;
922 page = page || 1; 996 page = page || 1;
923 pageSize = pageSize || 20; 997 pageSize = pageSize || 20;
924 998
925 let data = { 999 let data = {
  1000 + uid: uid,
926 article_id: aid, 1001 article_id: aid,
927 page: page, 1002 page: page,
928 limit: pageSize 1003 limit: pageSize
@@ -25,6 +25,11 @@ @@ -25,6 +25,11 @@
25 25
26 <div class="article-main"> 26 <div class="article-main">
27 {{# content}} 27 {{# content}}
  28 + {{# video}}
  29 + <div class="article-video block">
  30 + {{{.}}}
  31 + </div>
  32 + {{/ video}}
28 {{# pic}} 33 {{# pic}}
29 <div class="article-pic block"> 34 <div class="article-pic block">
30 <img class="lazy" data-original="{{image2 .}}"> 35 <img class="lazy" data-original="{{image2 .}}">