Authored by 毕凯

Merge branch 'feature/recWord' into 'master'

Feature/rec word



See merge request !850
@@ -342,7 +342,7 @@ const keyId = (req, res, next) => { @@ -342,7 +342,7 @@ const keyId = (req, res, next) => {
342 'total', 0)}${queryKey}、产品的详细参数,实时报价,价格行情,图片、评价、品牌等信息。买${queryKey},就上YOHO!BUY有货`, 342 'total', 0)}${queryKey}、产品的详细参数,实时报价,价格行情,图片、评价、品牌等信息。买${queryKey},就上YOHO!BUY有货`,
343 pageFooter: true, 343 pageFooter: true,
344 cononical: { 344 cononical: {
345 - currentHref: helpers.urlFormat(req.originalUrl, null, 'www') 345 + currentHref: `//www.yohobuy.com${req.originalUrl}`
346 } 346 }
347 }); 347 });
348 }).catch(next); 348 }).catch(next);
@@ -7,7 +7,9 @@ const commentModel = require('./consult-comment'); @@ -7,7 +7,9 @@ const commentModel = require('./consult-comment');
7 const bundle = require('./bundle'); 7 const bundle = require('./bundle');
8 const utils = '../../../utils'; 8 const utils = '../../../utils';
9 const detailProcess = require(`${utils}/detail-process`); 9 const detailProcess = require(`${utils}/detail-process`);
  10 +const redis = require(`${utils}/redis`);
10 const api = global.yoho.API; 11 const api = global.yoho.API;
  12 +const helpers = global.yoho.helpers;
11 13
12 const newDetail = { 14 const newDetail = {
13 /** 15 /**
@@ -42,7 +44,35 @@ const newDetail = { @@ -42,7 +44,35 @@ const newDetail = {
42 result.data.goods_id = data.goodsId; 44 result.data.goods_id = data.goodsId;
43 result.data.shopId = _.get(result, 'data.shop_id', null); 45 result.data.shopId = _.get(result, 'data.shop_id', null);
44 46
45 - return detailProcess.prodessDetailData(result.data); 47 + let finalResult = detailProcess.prodessDetailData(result.data);
  48 + let smallSort = _.get(result, 'data.smallSortId');
  49 +
  50 + if (!smallSort) {
  51 + return finalResult;
  52 + }
  53 +
  54 + return this.getRecomdKeywords(smallSort).then(res => {
  55 + let recomdKeywords = [];
  56 +
  57 + res = res ? JSON.parse(res) : [];
  58 +
  59 + _.forEach(_.slice(_.shuffle(res), 0, 12), val => {
  60 + recomdKeywords.push({
  61 + url: helpers.urlFormat(`/chanpin/${val.id}.html`),
  62 + keyword: val.keyword
  63 + });
  64 + });
  65 +
  66 + finalResult.recommendKeywords = recomdKeywords;
  67 +
  68 + return finalResult;
  69 + });
  70 + });
  71 + },
  72 +
  73 + getRecomdKeywords(smallSort) {
  74 + return redis.all([['get', `global:yoho:seo:keywords:sortId:${smallSort}:page:1`]]).then(res => {
  75 + return res[0];
46 }); 76 });
47 }, 77 },
48 78
@@ -124,6 +124,14 @@ @@ -124,6 +124,14 @@
124 <input id="product-coupon-switch" type="hidden" value="{{showCoupon}}"> 124 <input id="product-coupon-switch" type="hidden" value="{{showCoupon}}">
125 <input id="bundleType" type="hidden" value="{{bundleType}}"> 125 <input id="bundleType" type="hidden" value="{{bundleType}}">
126 126
  127 + {{#if recommendKeywords}}
  128 + <div class="rec-word clearfix">
  129 + {{# recommendKeywords}}
  130 + <a href="{{url}}">{{keyword}}</a>
  131 + {{/ recommendKeywords}}
  132 + </div>
  133 + {{/if}}
  134 +
127 {{> common/suspend-home}} 135 {{> common/suspend-home}}
128 </div> 136 </div>
129 {{/ result}} 137 {{/ result}}
1 { 1 {
2 "name": "m-yohobuy-node", 2 "name": "m-yohobuy-node",
3 - "version": "6.0.11", 3 + "version": "6.0.12",
4 "private": true, 4 "private": true,
5 "description": "A New Yohobuy Project With Express", 5 "description": "A New Yohobuy Project With Express",
6 "repository": { 6 "repository": {
@@ -1225,6 +1225,24 @@ $basicBtnC: #eb0313; @@ -1225,6 +1225,24 @@ $basicBtnC: #eb0313;
1225 } 1225 }
1226 } 1226 }
1227 1227
  1228 + .rec-word {
  1229 + padding-top: 16px;
  1230 + padding-left: 30px;
  1231 + background-color: #fff;
  1232 + border-top: 1px solid #e6e6e6;
  1233 + border-bottom: 1px solid #e6e6e6;
  1234 +
  1235 + > * {
  1236 + display: inline-block;
  1237 + font-size: 24px;
  1238 + border: 1px solid #bbb;
  1239 + border-radius: 10px;
  1240 + padding: 6px 14px;
  1241 + margin-right: 24px;
  1242 + margin-bottom: 16px;
  1243 + }
  1244 + }
  1245 +
1228 .recommend-for-you { 1246 .recommend-for-you {
1229 border-bottom: none; 1247 border-bottom: none;
1230 padding-left: 15px; 1248 padding-left: 15px;