Authored by yyq

add rec word

@@ -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; // eslint-disable-line
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`), // eslint-disable-line
  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}}
@@ -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: 28px;
  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;