Authored by 杨延青

Merge branch 'feature/hotEntry' into 'release/0529'

Feature/hot entry



See merge request !288
... ... @@ -5,7 +5,7 @@
<h1 class="main-title">产品大全</h1>
<ul class="list-block clearfix">
{{# chanpinList}}
<li><a href="//www.yohobuy.com/chanpin/{{id}}.html" title="{{keyword}}" target="_blank">{{keyword}}</a></li>
<li><a href="//www.yohobuy.com/{{#if is_hot}}hot{{^}}chanpin{{/if}}/{{id}}.html" title="{{keyword}}" target="_blank">{{keyword}}</a></li>
{{/ chanpinList}}
</ul>
</div>
... ...
... ... @@ -65,6 +65,7 @@ module.exports = class extends global.yoho.BaseModel {
this.getNewProduct = _cached(this._getNewProduct, this);
this.getGuangArticles = _cached(this._getGuangArticles, this);
this.getRecommendHotKeywords = _cached(this._getRecommendHotKeywords, this);
this.getRecommendKeywords = _cached(this._getRecommendKeywords, this);
this.getShopRecommendAsync = _cached(this._getShopRecommendAsync, this, ONE_DAY);
}
... ... @@ -235,6 +236,17 @@ module.exports = class extends global.yoho.BaseModel {
});
}
// 根据mid_sort从redis获取分类下的hot关键词
_getRecommendHotKeywords(midSort, skn) { // eslint-disable-line
return redis.all([['get', `global:yoho:seo:hot:keywords:${midSort}:page`]]).then(res => {
return redis.all([
['get', `global:yoho:seo:hot:keywords:${midSort}:page:${ _.random(1, res[0]) || 1}`]
]);
}).then(res => {
return this._getKeywordsInfo(JSON.parse(res[0] || '[]'));
});
}
// 根据small_sort从redis获取分类下的关键词
_getRecommendKeywords(smallSort, skn) { // eslint-disable-line
return redis.all([['get', `global:yoho:seo:keywords:sortId:${smallSort}:page`]]).then(res => {
... ... @@ -252,7 +264,7 @@ module.exports = class extends global.yoho.BaseModel {
_.forEach(_.slice(_.shuffle(keywords), 0, 18), val => {
res.push({
url: helpers.urlFormat(`/chanpin/${val.id}.html`),
url: helpers.urlFormat(`/${val.is_hot ? 'hot' : 'chanpin'}/${val.id}.html`),
keyword: val.keyword
});
});
... ...
... ... @@ -1032,6 +1032,7 @@ function _detailDataPkg(origin, uid, vipLevel, cookies) {
result.maxSortId = propOrigin('maxSortId', '');
result.smallSortId = propOrigin('smallSortId', '');
result.middleSortId = propOrigin('middleSortId', '');
result.goCartUrl = helpers.urlFormat('/cart/cart');
... ... @@ -1073,7 +1074,7 @@ function _detailDataPkg(origin, uid, vipLevel, cookies) {
}
// 相关推荐词
requestApi.recommendKeywords = this.productAPI.getRecommendKeywords(result.smallSortId, result.skn);
requestApi.recommendKeywords = this.productAPI.getRecommendHotKeywords(result.middleSortId, result.skn);
// 店铺推荐直出(seo需要)
requestApi.shopRecommend = this.productAPI.getShopRecommendAsync(result.skn);
... ...