Authored by 周少峰

Merge branch 'hotfix/sale-activity'

... ... @@ -9,6 +9,8 @@
const mRoot = '../models';
const sale = require(`${mRoot}/sale`); // sale model
const _ = require('lodash');
/**
* sale 首页
* @param {[type]} req [description]
... ... @@ -150,6 +152,9 @@ exports.special = (req, res, next) => {
return next();
}
_.omit(params, 'specialsale_id');
params.productPool = specialId;
sale.getSaleSpecialData(specialId, params, req.yoho.channel).then(result => {
res.render('sale/special', result);
}).catch(next);
... ...
... ... @@ -208,7 +208,7 @@ const _getBrandDataByProductBaseInfo = (data, additionalData) => {
return {};
}
let brandId = data.brand_info.id;
let brandId = data.brand_info.brand_id;
let bgImg = '';
let logo = '';
let bannerInfo = null;
... ...
... ... @@ -106,14 +106,20 @@ const getListData = (params, channel) => {
finalResult.list = Object.assign(
searchHandler.handlePathNavData(result[1].data.sort, params, 'sort', channel), {
leftContent: searchHandler.handleSortData(result[1].data.sort, dps)
leftContent: searchHandler.handleSortData(result[1].data.sort, dps, params)
});
}
// 获取商品数据和顶部筛选条件
if (result[2].code === 200) {
let filters = Object.assign(searchHandler.handleFilterDataAll(result[2].data, params),
finalResult.list.leftContent.sort);
filters.checkedConditions.conditions = _.concat(filters.checkedConditions.conditions,
finalResult.list.leftContent.checked);
Object.assign(finalResult.list, {
filters: searchHandler.handleFilterDataAll(result[2].data, params),
filters: filters,
opts: searchHandler.handleOptsData(params, result[2].data.total, result[2].data.filter),
totalCount: result[2].data.total,
footPager: searchHandler.handlePagerData(result[2].data.total, params),
... ... @@ -184,14 +190,20 @@ const getListNewData = (params, channel) => {
if (result[1].code === 200) {
finalResult.list = Object.assign(
searchHandler.handlePathNavData(result[1].data.sort, params, 'new', channel), {
leftContent: searchHandler.handleSortData(result[1].data.sort, dps)
leftContent: searchHandler.handleSortData(result[1].data.sort, dps, params)
});
}
// 获取商品数据和顶部筛选条件
if (result[2].code === 200) {
let filters = Object.assign(searchHandler.handleFilterDataAll(result[2].data, params),
finalResult.list.leftContent.sort);
filters.checkedConditions.conditions = _.concat(filters.checkedConditions.conditions,
finalResult.list.leftContent.checked);
Object.assign(finalResult.list, {
filters: searchHandler.handleFilterDataAll(result[2].data, params),
filters: filters,
opts: searchHandler.handleOptsData(params, result[2].data.total, result[2].data.filter),
totalCount: result[2].data.total,
footPager: searchHandler.handlePagerData(result[2].data.total, params),
... ... @@ -295,14 +307,20 @@ const getBrandData = (params, extra, channel) => {
});
Object.assign(finalResult.brand, {
leftContent: searchHandler.handleSortData(result[1].data.sort, dps)
leftContent: searchHandler.handleSortData(result[1].data.sort, dps, params)
}, searchHandler.handlePathNavData(extra, params, 'brand', channel));
}
// 获取商品数据和顶部筛选条件
if (result[2].code === 200) {
let filters = Object.assign(searchHandler.handleFilterDataAll(result[2].data, params),
finalResult.brand.leftContent.sort);
filters.checkedConditions.conditions = _.concat(filters.checkedConditions.conditions,
finalResult.brand.leftContent.checked);
Object.assign(finalResult.brand, {
filters: searchHandler.handleFilterDataAll(result[2].data, params),
filters: filters,
opts: searchHandler.handleOptsData(params, result[2].data.total, result[2].data.filter),
totalCount: result[2].data.total,
footPager: searchHandler.handlePagerData(result[2].data.total, params),
... ...
... ... @@ -39,7 +39,7 @@ const handleFilterUrl = (originParam, newParam, delParam) => {
delete tempOriginParam.uid;
_.forEach(tempOriginParam, function(value, key) {
if (!delParam[key]) {
if (!delParam[key] && value) {
dest += `${key}=${value}&`;
}
});
... ... @@ -465,8 +465,12 @@ exports.handleOptsData = (params, total, extra) => {
* @param extra 可以任意传值用来处理特殊情况
* @returns {{}}
*/
exports.handleSortData = (origin, params) => {
let leftContent = {};
exports.handleSortData = (origin, params, originParams) => {
let leftContent = {
sort: {misort: []},
checked: []
};
let list = [],
allCount = 0;
... ... @@ -477,8 +481,6 @@ exports.handleSortData = (origin, params) => {
href: handleFilterUrl(params, {}, {msort: true, misort: true})
}];
//
_.forEach(origin, value => {
let category = {
name: value.sort_name,
... ... @@ -511,6 +513,25 @@ exports.handleSortData = (origin, params) => {
category.active = true;
}
if (subValue.sort_id === params.misort && subValue.sub && subValue.sub.length > 2) {
_.forEach(subValue.sub, smallSort => {
leftContent.sort.misort.push({
id: smallSort.sort_id,
name: smallSort.sort_name,
checked: smallSort.sort_id === _.get(originParams, 'sort'),
href: handleFilterUrl(originParams, {sort: smallSort.sort_id})
});
if (smallSort.sort_id === _.get(originParams, 'sort')) {
leftContent.checked.push({
name: smallSort.sort_name,
href: handleFilterUrl(originParams, {sort: ''})
});
}
});
}
});
list.push(category);
... ...
... ... @@ -25,7 +25,7 @@ exports.getSearchData = (params, channel) => {
// 调用接口
let apiMethod = [
headerModel.requestHeaderData(channel),
searchApi.getSortList(Object.assign({}, searchParams, {msort: '', misort: ''})),
searchApi.getSortList(Object.assign({}, searchParams, {msort: '', misort: '', sort: ''})),
searchApi.getProductList(searchParams),
searchApi.getShopList(params)
];
... ... @@ -54,16 +54,23 @@ exports.getSearchData = (params, channel) => {
});
finalResult.search = {
leftContent: searchHandler.handleSortData(result[1].data.sort, dps)
leftContent: searchHandler.handleSortData(result[1].data.sort, dps, params)
};
}
// 获取商品数据和顶部筛选条件
if (result[2].code === 200) {
let filters = Object.assign(searchHandler.handleFilterDataAll(result[2].data, params),
finalResult.search.leftContent.sort);
filters.checkedConditions.conditions = _.concat(filters.checkedConditions.conditions,
finalResult.search.leftContent.checked);
Object.assign(finalResult.search,
searchHandler.handlePathNavData({total: result[2].data.total }, params, 'search', channel),
{
filters: searchHandler.handleFilterDataAll(result[2].data, params),
filters: filters,
opts: searchHandler.handleOptsData(params, result[2].data.total, result[2].data.filter),
totalCount: result[2].data.total,
footPager: searchHandler.handlePagerData(result[2].data.total, params),
... ...
... ... @@ -16,8 +16,8 @@ module.exports = {
siteUrl: 'http://www.yohobuy.com',
domains: {
favApi: 'http://192.168.102.31:8092/brower',
api: 'http://api-test1.yohops.com:9999/',
service: 'http://service-test1.yohops.com:9999/',
api: 'http://api.yoho.cn/',
service: 'http://service.yoho.cn/',
search: 'http://192.168.102.216:8080/yohosearch/'
},
subDomains: {
... ...
... ... @@ -50,20 +50,6 @@
</div>
{{/if}}
{{#if ageLevel}}
<div class="channel section">
<span class="title">人群:</span>
<div class="attr-content clearfix">
{{#each ageLevel}}
<a class="attr {{#if checked}}checked{{/if}}" href="{{href}}">
{{name}}
</a>
{{/each}}
</div>
</div>
{{/if}}
{{#if sort}}
<div class="sort section">
<span class="title">分类:</span>
... ... @@ -143,6 +129,20 @@
{{> product/filter-brands}}
</script>
{{#if ageLevel}}
<div class="channel section">
<span class="title">人群:</span>
<div class="attr-content clearfix">
{{#each ageLevel}}
<a class="attr {{#if checked}}checked{{/if}}" href="{{href}}">
{{name}}
</a>
{{/each}}
</div>
</div>
{{/if}}
{{#if price}}
<div class="price section">
<span class="title">价格:</span>
... ...