Authored by 毕凯

Merge branch 'feature/recWord' into 'master'

Feature/rec word



See merge request !850
... ... @@ -342,7 +342,7 @@ const keyId = (req, res, next) => {
'total', 0)}${queryKey}、产品的详细参数,实时报价,价格行情,图片、评价、品牌等信息。买${queryKey},就上YOHO!BUY有货`,
pageFooter: true,
cononical: {
currentHref: helpers.urlFormat(req.originalUrl, null, 'www')
currentHref: `//www.yohobuy.com${req.originalUrl}`
}
});
}).catch(next);
... ...
... ... @@ -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;
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`),
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}}
... ...
{
"name": "m-yohobuy-node",
"version": "6.0.11",
"version": "6.0.12",
"private": true,
"description": "A New Yohobuy Project With Express",
"repository": {
... ...
... ... @@ -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: 24px;
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;
... ...