Authored by yyq

hot

/*
* @Author: yyq
* @Date: 2018-05-07
*/
'use strict';
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 => {
res.render('seo/hot', result);
}).catch(next);;
};
module.exports = {
hot
};
... ...
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`);
const _setHotKeywordData = (result, params, channel) => {
let changeQuery = Object.assign({}, params);
let finalResult = {
headerData: Object.assign(result[0].headerData, {
header: true
})
};
_.unset(changeQuery, 'query');
// 获取商品数据和顶部筛选条件
if (result[1].code === 200) {
let data = result[1].data;
Object.assign(finalResult,
searchHandler.handlePathNavData({total: data.total}, params, 'search', channel),
{
product: {
opts: searchHandler.handleOptsData(changeQuery, data.total),
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,
hasNextPage: searchHandler.handleNextPage(changeQuery, data.total)
}
}
);
finalResult.hotBrands = _.get(data, 'filter.brand', []);
finalResult.hotBrands.forEach((val) => {
val.href = '#'; // TODO
return val;
});
console.log(_.get(data, 'filter.brand', []));
// finalResult.criteo = {skn: searchHandler.getCriteo(_.get(finalResult.search, 'goods'))};
}
// console.log(finalResult);
return finalResult;
};
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
this.searchApi = new SearchApi(ctx);
}
getHotKeywordDate(params, channel) {
let searchParams = searchHandler.getSearchParams(params);
switch (channel) {
case 'boys':
searchParams.physical_channel = 1;
break;
case 'girls':
searchParams.physical_channel = 2;
break;
case 'kids':
searchParams.physical_channel = 3;
break;
case 'lifestyle':
searchParams.physical_channel = 4;
break;
default:
break;
}
searchParams.need_filter = 'yes';
searchParams.query = '夹克';
return Promise.all([
headerModel.requestHeaderData(channel),
this.searchApi.getSeoProductList(searchParams, 'fuzzySearch')
]).then(result => {
return _setHotKeywordData(result, params, channel);
});
}
};
... ...
... ... @@ -53,6 +53,9 @@ const globalCtrl = require(`${cRoot}/global`);
// 店铺controller
const shop = require(`${cRoot}/shop`);
// seo controller
const seo = require(`${cRoot}/seo`);
// 商品促销routers
router.get('/sale', sale.index); // sale 首页
router.get('/sale/vip', sale.vip); // VIP 活动专区
... ... @@ -118,6 +121,7 @@ router.get('/search/history', search.searchHistory); // 搜索历史提示
router.get('/search/less/recommend', search.searchLessRecommend);// 搜索少或无 有可能喜欢
router.get('/search/keyword/:id', search.keyword);
router.get('/search/chanpin/:id', search.keyId);
router.get('/search/hot/:id.html', '/hot/:id.html', seo.hot);
// 新品到着
router.get('/list/new', list.newWithChannel);
... ...
<div class="yoho-page seo-hot-page">
{{> common/path-nav}}
<div class="clearfix">
<div class="left-content">
<div class="hot-sort">
<div class="sort-intro">
<div class="inline">
<p class="name">
<span class="cn">夹克</span>
<span class="en">JACKETS & COATS</span>
</p>
<p class="desc">夹克(英语:Jacket),是一种长度至腰部或臀部的上半身衣着。夹克自诞生以来,款式演变千姿百态,形成了庞大的家族。 随着日新月异的世界发展, 夹克以各种各样的姿态永恒不衰,成为经典服饰之一。</p>
<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>
</ul>
</div>
</div>
<img class="thumb" src="//img12.static.yhbimg.com/adpic/2017/05/03/18/0228ed1fb3baf7c9198bfd65024812908a.jpg?imageView2/2/interlace/1/q/75">
</div>
{{# product}}
{{> product/standard-content}}
{{/ product}}
</div>
<div class="right-content">
<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>
</p>
</div>
<div class="hot-block">
<p class="title">热门品牌</p>
{{# hotBrands}}
<a 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}}
</div>
</div>
</div>
{{> product/latest-walk goodsInfo=@root.recommendKeywordsInfo}}
</div>
... ...
... ... @@ -16,6 +16,7 @@
@import "new-arrive";
@import "good-slide";
@import "../variables";
@import "seo/index";
.product-page {
.list-left {
... ...
.seo-hot-page {
width: 1150px;
margin: 0 auto;
.left-content {
float: left;
width: 970px;
}
.hot-sort {
width: 100%;
position: relative;
.sort-intro {
width: 488px;
height: 300px;
line-height: 300px;
border: 1px solid #eaeceb;
box-sizing: border-box;
}
.inline {
width: 100%;
padding: 0 50px;
line-height: 1;
text-align: center;
display: inline-block;
box-sizing: border-box;
vertical-align: middle;
}
.name {
font-size: 30px;
font-weight: 700;
text-align: center;
.en {
width: 100%;
font-size: 14px;
display: block;
}
}
.desc {
margin-top: 15px;
color: #666;
font-size: 12px;
line-height: 1.5;
}
.key {
margin-top: 30px;
> li {
width: 33.33%;
text-align: center;
float: left;
font-size: 12px;
line-height: 20px;
text-decoration: underline;
}
a {
color: #069;
}
}
.thumb {
width: 480px;
height: 300px;
position: absolute;
top: 0;
right: 0;
}
}
.right-content {
float: right;
width: 160px;
$border-color: #dfdfdf;
.hot-block {
font-size: 12px;
border: 1px solid $border-color;
margin-bottom: 20px;
.title {
line-height: 40px;
font-weight: bold;
background-color: #eaeceb;
padding-left: 10px;
}
.hot-key {
line-height: 26px;
padding: 12px 6px 12px 10px;
border-top: 1px solid $border-color;
> a {
margin-right: 4px;
display: inline-block;
}
}
.brand-item {
height: 100px;
padding: 15px 10px;
display: block;
box-sizing: border-box;
border-top: 1px solid $border-color;
img {
width: 100%;
height: 100%;
display: block;
}
}
}
}
}
... ...