Authored by 杨延青

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

Feature/hot entry



See merge request !288
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 <h1 class="main-title">产品大全</h1> 5 <h1 class="main-title">产品大全</h1>
6 <ul class="list-block clearfix"> 6 <ul class="list-block clearfix">
7 {{# chanpinList}} 7 {{# chanpinList}}
8 - <li><a href="//www.yohobuy.com/chanpin/{{id}}.html" title="{{keyword}}" target="_blank">{{keyword}}</a></li> 8 + <li><a href="//www.yohobuy.com/{{#if is_hot}}hot{{^}}chanpin{{/if}}/{{id}}.html" title="{{keyword}}" target="_blank">{{keyword}}</a></li>
9 {{/ chanpinList}} 9 {{/ chanpinList}}
10 </ul> 10 </ul>
11 </div> 11 </div>
@@ -65,6 +65,7 @@ module.exports = class extends global.yoho.BaseModel { @@ -65,6 +65,7 @@ module.exports = class extends global.yoho.BaseModel {
65 65
66 this.getNewProduct = _cached(this._getNewProduct, this); 66 this.getNewProduct = _cached(this._getNewProduct, this);
67 this.getGuangArticles = _cached(this._getGuangArticles, this); 67 this.getGuangArticles = _cached(this._getGuangArticles, this);
  68 + this.getRecommendHotKeywords = _cached(this._getRecommendHotKeywords, this);
68 this.getRecommendKeywords = _cached(this._getRecommendKeywords, this); 69 this.getRecommendKeywords = _cached(this._getRecommendKeywords, this);
69 this.getShopRecommendAsync = _cached(this._getShopRecommendAsync, this, ONE_DAY); 70 this.getShopRecommendAsync = _cached(this._getShopRecommendAsync, this, ONE_DAY);
70 } 71 }
@@ -235,6 +236,17 @@ module.exports = class extends global.yoho.BaseModel { @@ -235,6 +236,17 @@ module.exports = class extends global.yoho.BaseModel {
235 }); 236 });
236 } 237 }
237 238
  239 + // 根据mid_sort从redis获取分类下的hot关键词
  240 + _getRecommendHotKeywords(midSort, skn) { // eslint-disable-line
  241 + return redis.all([['get', `global:yoho:seo:hot:keywords:${midSort}:page`]]).then(res => {
  242 + return redis.all([
  243 + ['get', `global:yoho:seo:hot:keywords:${midSort}:page:${ _.random(1, res[0]) || 1}`]
  244 + ]);
  245 + }).then(res => {
  246 + return this._getKeywordsInfo(JSON.parse(res[0] || '[]'));
  247 + });
  248 + }
  249 +
238 // 根据small_sort从redis获取分类下的关键词 250 // 根据small_sort从redis获取分类下的关键词
239 _getRecommendKeywords(smallSort, skn) { // eslint-disable-line 251 _getRecommendKeywords(smallSort, skn) { // eslint-disable-line
240 return redis.all([['get', `global:yoho:seo:keywords:sortId:${smallSort}:page`]]).then(res => { 252 return redis.all([['get', `global:yoho:seo:keywords:sortId:${smallSort}:page`]]).then(res => {
@@ -252,7 +264,7 @@ module.exports = class extends global.yoho.BaseModel { @@ -252,7 +264,7 @@ module.exports = class extends global.yoho.BaseModel {
252 264
253 _.forEach(_.slice(_.shuffle(keywords), 0, 18), val => { 265 _.forEach(_.slice(_.shuffle(keywords), 0, 18), val => {
254 res.push({ 266 res.push({
255 - url: helpers.urlFormat(`/chanpin/${val.id}.html`), 267 + url: helpers.urlFormat(`/${val.is_hot ? 'hot' : 'chanpin'}/${val.id}.html`),
256 keyword: val.keyword 268 keyword: val.keyword
257 }); 269 });
258 }); 270 });
@@ -1032,6 +1032,7 @@ function _detailDataPkg(origin, uid, vipLevel, cookies) { @@ -1032,6 +1032,7 @@ function _detailDataPkg(origin, uid, vipLevel, cookies) {
1032 1032
1033 result.maxSortId = propOrigin('maxSortId', ''); 1033 result.maxSortId = propOrigin('maxSortId', '');
1034 result.smallSortId = propOrigin('smallSortId', ''); 1034 result.smallSortId = propOrigin('smallSortId', '');
  1035 + result.middleSortId = propOrigin('middleSortId', '');
1035 1036
1036 result.goCartUrl = helpers.urlFormat('/cart/cart'); 1037 result.goCartUrl = helpers.urlFormat('/cart/cart');
1037 1038
@@ -1073,7 +1074,7 @@ function _detailDataPkg(origin, uid, vipLevel, cookies) { @@ -1073,7 +1074,7 @@ function _detailDataPkg(origin, uid, vipLevel, cookies) {
1073 } 1074 }
1074 1075
1075 // 相关推荐词 1076 // 相关推荐词
1076 - requestApi.recommendKeywords = this.productAPI.getRecommendKeywords(result.smallSortId, result.skn); 1077 + requestApi.recommendKeywords = this.productAPI.getRecommendHotKeywords(result.middleSortId, result.skn);
1077 1078
1078 // 店铺推荐直出(seo需要) 1079 // 店铺推荐直出(seo需要)
1079 requestApi.shopRecommend = this.productAPI.getShopRecommendAsync(result.skn); 1080 requestApi.shopRecommend = this.productAPI.getShopRecommendAsync(result.skn);