Authored by yyq

add rec word

... ... @@ -7,7 +7,9 @@ const commentModel = require('./consult-comment');
const bundle = require('./bundle');
const utils = '../../../utils';
const detailProcess = require(`${utils}/detail-process`);
const redis = require(`${utils}/redis`);
const api = global.yoho.API;
const helpers = global.yoho.helpers; // eslint-disable-line
const newDetail = {
/**
... ... @@ -42,7 +44,35 @@ const newDetail = {
result.data.goods_id = data.goodsId;
result.data.shopId = _.get(result, 'data.shop_id', null);
return detailProcess.prodessDetailData(result.data);
let finalResult = detailProcess.prodessDetailData(result.data);
let smallSort = _.get(result, 'data.smallSortId');
if (!smallSort) {
return finalResult;
}
return this.getRecomdKeywords(smallSort).then(res => {
let recomdKeywords = [];
res = res ? JSON.parse(res) : [];
_.forEach(_.slice(_.shuffle(res), 0, 12), val => {
recomdKeywords.push({
url: Helpers.urlFormat(`/chanpin/${val.id}.html`), // eslint-disable-line
keyword: val.keyword
});
});
finalResult.recommendKeywords = recomdKeywords;
return finalResult;
});
});
},
getRecomdKeywords(smallSort) {
return redis.all([['get', `global:yoho:seo:keywords:sortId:${smallSort}:page:1`]]).then(res => {
return res[0];
});
},
... ...
... ... @@ -124,6 +124,14 @@
<input id="product-coupon-switch" type="hidden" value="{{showCoupon}}">
<input id="bundleType" type="hidden" value="{{bundleType}}">
{{#if recommendKeywords}}
<div class="rec-word clearfix">
{{# recommendKeywords}}
<a href="{{url}}">{{keyword}}</a>
{{/ recommendKeywords}}
</div>
{{/if}}
{{> common/suspend-home}}
</div>
{{/ result}}
... ...
... ... @@ -1225,6 +1225,24 @@ $basicBtnC: #eb0313;
}
}
.rec-word {
padding-top: 16px;
padding-left: 30px;
background-color: #fff;
border-top: 1px solid #e6e6e6;
border-bottom: 1px solid #e6e6e6;
> * {
display: inline-block;
font-size: 28px;
border: 1px solid #bbb;
border-radius: 10px;
padding: 6px 14px;
margin-right: 24px;
margin-bottom: 16px;
}
}
.recommend-for-you {
border-bottom: none;
padding-left: 15px;
... ...