...
|
...
|
@@ -10,6 +10,13 @@ const _ = require('lodash'); |
|
|
const helpers = global.yoho.helpers;
|
|
|
const queryString = require('querystring');
|
|
|
|
|
|
// 打折、新品、限量
|
|
|
const checksName = {
|
|
|
new: '新品',
|
|
|
specialoffer: '打折',
|
|
|
limited: '限量'
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 处理用于筛选的 URL , 拼接 URL 参数
|
|
|
* @param originParam 当前 URL 中的参数
|
...
|
...
|
@@ -127,6 +134,29 @@ const handleBrandCheckedData = (params, origin) => { |
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 新品、折扣、限量
|
|
|
*/
|
|
|
const hadleChecks = (name, params) => {
|
|
|
let tempParam = _.cloneDeep(params);
|
|
|
|
|
|
tempParam[name] = 'Y';
|
|
|
let checksOpts = {
|
|
|
name: checksName[name],
|
|
|
checked: false,
|
|
|
href: handleFilterUrl(tempParam)
|
|
|
};
|
|
|
|
|
|
if (params[name] && params[name] === 'Y') {
|
|
|
checksOpts.checked = false;
|
|
|
delete tempParam[name];
|
|
|
checksOpts.href = handleFilterUrl(tempParam);
|
|
|
}
|
|
|
|
|
|
return checksOpts;
|
|
|
};
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 处理 opts 排序数据
|
|
|
* @param params
|
|
|
* @param total
|
...
|
...
|
@@ -135,7 +165,8 @@ const handleBrandCheckedData = (params, origin) => { |
|
|
*/
|
|
|
exports.handleOptsData = (params, total, extra) => {
|
|
|
let dest = {
|
|
|
sortType: []
|
|
|
sortType: [],
|
|
|
checks: []
|
|
|
};
|
|
|
|
|
|
// 用来标记是否是折扣专场,折扣专场只需要前三个排序参数
|
...
|
...
|
@@ -276,6 +307,20 @@ exports.handleOptsData = (params, total, extra) => { |
|
|
total : parseInt(dest.start, 10) + paramsLimit - 1;
|
|
|
}
|
|
|
|
|
|
// 新品
|
|
|
if (extra.new === 'Y') {
|
|
|
dest.checks.push(hadleChecks('new', params));
|
|
|
}
|
|
|
|
|
|
// 打折
|
|
|
if (extra.specialoffer === 'Y') {
|
|
|
dest.checks.push(hadleChecks('specialoffer', params));
|
|
|
}
|
|
|
|
|
|
// 限量
|
|
|
if (extra.limited === 'Y') {
|
|
|
dest.checks.push(hadleChecks('limited', params));
|
|
|
}
|
|
|
return dest;
|
|
|
};
|
|
|
|
...
|
...
|
@@ -365,6 +410,7 @@ exports.handleFilterData = (origin, params) => { |
|
|
},
|
|
|
price: [],
|
|
|
gender: [],
|
|
|
color: [],
|
|
|
checkedConditions: {
|
|
|
conditions: []
|
|
|
}
|
...
|
...
|
@@ -502,6 +548,20 @@ exports.handleFilterData = (origin, params) => { |
|
|
handleCheckedData(params, dest.size, 'size'));
|
|
|
}
|
|
|
|
|
|
// 处理颜色筛选数据
|
|
|
if (!_.isEmpty(origin.color)) {
|
|
|
_.forEach(origin.color, (value, key) => {
|
|
|
let color = {
|
|
|
checked: params.price === key,
|
|
|
href: handleFilterUrl(params, {color: value.color_id}),
|
|
|
name: value.color_name,
|
|
|
rgb: value.color_value ? 'url(' + value.color_value + ')' : '#' + value.color_code
|
|
|
};
|
|
|
|
|
|
dest.color.push(color);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 清除所有选中数据
|
|
|
let remainParams = {};
|
|
|
|
...
|
...
|
|