Authored by yyq

seo hot

... ... @@ -8,7 +8,7 @@
const seoModel = require('../models/seo-service'); // seo 页 model
const hot = (req, res, next) => {
return req.ctx(seoModel).getHotKeywordDate(req.query, req.yoho.channel).then(result => {
return req.ctx(seoModel).getHotKeywordDate(req.params.id, req.query, req.yoho.channel).then(result => {
res.render('seo/hot', result);
}).catch(next);
};
... ...
const redis = global.yoho.redis;
const helpers = global.yoho.helpers;
const logger = global.yoho.logger;
const _ = require('lodash');
const headerModel = require('../../../doraemon/models/header');
const SearchApi = require('./search-api');
const searchHandler = require('./search-handler');
const utils = '../../../utils';
const productProcess = require(`${utils}/product-process-simple`);
... ... @@ -31,8 +34,7 @@ const _setHotKeywordData = (result, params, channel) => {
totalCount: data.total,
footPager: searchHandler.handlePagerData(data.total, changeQuery),
goods: productProcess.processProductList(data.product_list,
Object.assign({showDiscount: false, from: {type: 'search', params: params}}, params)),
latestWalk: 6,
Object.assign({showDiscount: false, from: {type: 'hot', params: params}}, params)),
hasNextPage: searchHandler.handleNextPage(changeQuery, data.total)
}
}
... ... @@ -41,16 +43,24 @@ const _setHotKeywordData = (result, params, channel) => {
finalResult.hotBrands = _.get(data, 'filter.brand', []);
finalResult.hotBrands.forEach((val) => {
val.href = '#'; // TODO
val.href = helpers.urlFormat(`/list/bd${val.id}.html`);
return val;
});
console.log(_.get(data, 'filter.brand', []));
// finalResult.criteo = {skn: searchHandler.getCriteo(_.get(finalResult.search, 'goods'))};
finalResult.criteo = {skn: searchHandler.getCriteo(_.get(finalResult.search, 'goods'))};
}
// console.log(finalResult);
if (result[2].code === 200) {
let data = result[2].data;
finalResult.latestWalkExtra = [{
extraTabName: '相关推荐',
extraGoodsList: productProcess.processProductList(data.product_list,
Object.assign({showDiscount: false, from: {type: 'hot', params: params}}, params))
}];
}
return finalResult;
};
... ... @@ -62,7 +72,7 @@ module.exports = class extends global.yoho.BaseModel {
this.searchApi = new SearchApi(ctx);
}
getHotKeywordDate(params, channel) {
getSearchProduct(params, channel) {
let searchParams = searchHandler.getSearchParams(params);
switch (channel) {
... ... @@ -83,12 +93,47 @@ module.exports = class extends global.yoho.BaseModel {
}
searchParams.need_filter = 'yes';
searchParams.query = '夹克';
return Promise.all([
headerModel.requestHeaderData(channel),
this.searchApi.getSeoProductList(searchParams, 'fuzzySearch')
this.searchApi.getSeoProductList(searchParams, 'fuzzySearch'),
this.searchApi.getSeoProductList(Object.assign(searchParams, {
order: 's_n_desc',
limit: 5
}), 'fuzzySearch'),
]).then(result => {
return _setHotKeywordData(result, params, channel);
});
}
getHotKeywordDate(id, params, channel) {
return redis.all([
['get', `global:yoho:seo:hot:keywords:id:${id}`]
]).then(redisData => {
let keyword = redisData[0];
try {
keyword = JSON.parse(keyword);
} catch (e) {
logger.debug('getProductList cache data parse fail.');
}
if (!_.get(keyword, 'name')) {
return Promise.reject(`cannot find hot keywords by id(${id})`);
}
params.query = keyword.name;
return this.getSearchProduct(params, channel).then(result => {
result.hotKeys = (keyword.data || []).map(val => {
val.href = helpers.urlFormat(`/hot/${val.id}.html`);
return val;
});
result.keyword = keyword;
result.latestWalk = 5;
return result;
});
})
}
};
... ...
<div class="yoho-page seo-hot-page">
<div class="yoho-page seo-hot-page product-list-page">
{{> common/path-nav}}
<div class="clearfix">
<div class="left-content">
<div class="hot-sort">
{{# keyword}}
<div class="sort-intro">
<div class="inline">
<p class="name">
<span class="cn">夹克</span>
<span class="en">JACKETS & COATS</span>
<span class="cn">{{name}}</span>
{{# nameEn}}<span class="en">{{.}}</span>{{/ nameEn}}
</p>
<p class="desc">夹克(英语:Jacket),是一种长度至腰部或臀部的上半身衣着。夹克自诞生以来,款式演变千姿百态,形成了庞大的家族。 随着日新月异的世界发展, 夹克以各种各样的姿态永恒不衰,成为经典服饰之一。</p>
{{# describe}}<p class="desc">{{.}}</p>{{/ describe}}
{{#if list}}
<ul class="key">
<li><a href="#">牛仔夹克户</a></li>
<li><a href="#">牛仔夹克户</a></li>
<li><a href="#">牛仔夹克户</a></li>
<li><a href="#">牛仔夹克户</a></li>
<li><a href="#">牛仔夹克户</a></li>
<li><a href="#">牛仔夹克户</a></li>
{{# list}}
<li><a href="{{href}}">{{name}}</a></li>
{{/ list}}
</ul>
{{/if}}
</div>
</div>
<img class="thumb" src="//img12.static.yhbimg.com/adpic/2017/05/03/18/0228ed1fb3baf7c9198bfd65024812908a.jpg?imageView2/2/interlace/1/q/75">
<img class="thumb" src="{{image2 goods_img}}">
{{/ keyword}}
</div>
{{# product}}
... ... @@ -33,21 +35,16 @@
<div class="hot-block">
<p class="title">热门关键词</p>
<p class="hot-key">
<a href="#">鞋履</a>
<a href="#">鞋履</a>
<a href="#">鞋履</a>
<a href="#">鞋履</a>
<a href="#">鞋履</a>
<a href="#">鞋履</a>
<a href="#">鞋履</a>
<a href="#">鞋履</a>
{{# hotKeys}}
<a href="{{href}}">{{keyword}}</a>
{{/ hotKeys}}
</p>
</div>
<div class="hot-block">
<p class="title">热门品牌</p>
{{# hotBrands}}
<a href="#" class="brand-item" target="_blank" title="{{brand_name_cn}}">
<a href="{{href}}" class="brand-item" target="_blank" title="{{brand_name_cn}}">
<img src="{{image2 brand_ico w=138 h=70}}" alt="{{brand_name_cn}} {{brand_keyword}}">
</a>
{{/ hotBrands}}
... ... @@ -55,5 +52,5 @@
</div>
</div>
{{> product/latest-walk goodsInfo=@root.recommendKeywordsInfo}}
{{> product/latest-walk goodsInfo=@root.recommendGoodsInfo}}
</div>
... ...
... ... @@ -7,6 +7,9 @@
<span class="about tab-item">相关推荐</span>
{{/if}}
{{# latestWalkExtra}}
<span class="tab-item extra-tab-item" data-key="{{@index}}">{{extraTabName}}</span>
{{/ latestWalkExtra}}
<div class="bottom-line"></div>
</div>
<div class="bottom-tab-cont">
... ... @@ -39,5 +42,24 @@
</p>
</div>
{{/if}}
{{# latestWalkExtra}}
<div class="latest-walk-extra-area extra-area-{{@index}}">
<div class="goods clearfix">
{{# extraGoodsList}}
<div class="good">
<a href="{{url}}" target="_blank" title="{{product_name}}">
<img class="lazy" data-original="{{image2 thumb w=280 h=382}}" alt="{{product_name}}" />
</a>
<a class="name" href="{{url}}" target="_blank">{{product_name}}</a>
<p class="price">
<span class="market-price">¥{{round market_price 2}}</span>
<span class="sale-price">¥{{round sales_price 2}}</span>
</p>
</div>
{{/ extraGoodsList}}
</div>
</div>
{{/ latestWalkExtra}}
</div>
{{/unless}}
... ...
... ... @@ -33,6 +33,7 @@
font-size: 30px;
font-weight: 700;
text-align: center;
margin-top: 0;
.en {
width: 100%;
... ... @@ -118,4 +119,55 @@
}
}
}
.bottom-tab-cont {
padding-bottom: 20px;
.latest-walk-extra-area {
display: none;
}
.goods {
width: 110%;
height: auto;
margin: 20px 0;
.good {
float: left;
width: 220px;
margin-right: 14px;
font-size: 12px;
text-align: center;
img {
width: 220px;
height: 300px;
display: block;
}
.name {
display: block;
max-width: 150px;
height: 18px;
line-height: 16px;
margin: 5px auto;
color: #222;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.market-price {
color: #999;
margin-right: 5px;
text-decoration: line-through;
}
.sale-price {
color: #000;
font-weight: 700;
}
}
}
}
}
... ...