...
|
...
|
@@ -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];
|
|
|
});
|
|
|
},
|
|
|
|
...
|
...
|
|