|
@@ -10,6 +10,13 @@ const _ = require('lodash'); |
|
@@ -10,6 +10,13 @@ const _ = require('lodash'); |
10
|
const helpers = global.yoho.helpers;
|
10
|
const helpers = global.yoho.helpers;
|
11
|
const queryString = require('querystring');
|
11
|
const queryString = require('querystring');
|
12
|
|
12
|
|
|
|
13
|
+// 打折、新品、限量
|
|
|
14
|
+const checksName = {
|
|
|
15
|
+ new: '新品',
|
|
|
16
|
+ specialoffer: '打折',
|
|
|
17
|
+ limited: '限量'
|
|
|
18
|
+};
|
|
|
19
|
+
|
13
|
/**
|
20
|
/**
|
14
|
* 处理用于筛选的 URL , 拼接 URL 参数
|
21
|
* 处理用于筛选的 URL , 拼接 URL 参数
|
15
|
* @param originParam 当前 URL 中的参数
|
22
|
* @param originParam 当前 URL 中的参数
|
|
@@ -127,6 +134,29 @@ const handleBrandCheckedData = (params, origin) => { |
|
@@ -127,6 +134,29 @@ const handleBrandCheckedData = (params, origin) => { |
127
|
};
|
134
|
};
|
128
|
|
135
|
|
129
|
/**
|
136
|
/**
|
|
|
137
|
+ * 新品、折扣、限量
|
|
|
138
|
+ */
|
|
|
139
|
+const hadleChecks = (name, params) => {
|
|
|
140
|
+ let tempParam = _.cloneDeep(params);
|
|
|
141
|
+
|
|
|
142
|
+ tempParam[name] = 'Y';
|
|
|
143
|
+ let checksOpts = {
|
|
|
144
|
+ name: checksName[name],
|
|
|
145
|
+ checked: false,
|
|
|
146
|
+ href: handleFilterUrl(tempParam)
|
|
|
147
|
+ };
|
|
|
148
|
+
|
|
|
149
|
+ if (params[name] && params[name] === 'Y') {
|
|
|
150
|
+ checksOpts.checked = false;
|
|
|
151
|
+ delete tempParam[name];
|
|
|
152
|
+ checksOpts.href = handleFilterUrl(tempParam);
|
|
|
153
|
+ }
|
|
|
154
|
+
|
|
|
155
|
+ return checksOpts;
|
|
|
156
|
+};
|
|
|
157
|
+
|
|
|
158
|
+
|
|
|
159
|
+/**
|
130
|
* 处理 opts 排序数据
|
160
|
* 处理 opts 排序数据
|
131
|
* @param params
|
161
|
* @param params
|
132
|
* @param total
|
162
|
* @param total
|
|
@@ -135,7 +165,8 @@ const handleBrandCheckedData = (params, origin) => { |
|
@@ -135,7 +165,8 @@ const handleBrandCheckedData = (params, origin) => { |
135
|
*/
|
165
|
*/
|
136
|
exports.handleOptsData = (params, total, extra) => {
|
166
|
exports.handleOptsData = (params, total, extra) => {
|
137
|
let dest = {
|
167
|
let dest = {
|
138
|
- sortType: []
|
168
|
+ sortType: [],
|
|
|
169
|
+ checks: []
|
139
|
};
|
170
|
};
|
140
|
|
171
|
|
141
|
// 用来标记是否是折扣专场,折扣专场只需要前三个排序参数
|
172
|
// 用来标记是否是折扣专场,折扣专场只需要前三个排序参数
|
|
@@ -276,6 +307,20 @@ exports.handleOptsData = (params, total, extra) => { |
|
@@ -276,6 +307,20 @@ exports.handleOptsData = (params, total, extra) => { |
276
|
total : parseInt(dest.start, 10) + paramsLimit - 1;
|
307
|
total : parseInt(dest.start, 10) + paramsLimit - 1;
|
277
|
}
|
308
|
}
|
278
|
|
309
|
|
|
|
310
|
+ // 新品
|
|
|
311
|
+ if (extra.new === 'Y') {
|
|
|
312
|
+ dest.checks.push(hadleChecks('new', params));
|
|
|
313
|
+ }
|
|
|
314
|
+
|
|
|
315
|
+ // 打折
|
|
|
316
|
+ if (extra.specialoffer === 'Y') {
|
|
|
317
|
+ dest.checks.push(hadleChecks('specialoffer', params));
|
|
|
318
|
+ }
|
|
|
319
|
+
|
|
|
320
|
+ // 限量
|
|
|
321
|
+ if (extra.limited === 'Y') {
|
|
|
322
|
+ dest.checks.push(hadleChecks('limited', params));
|
|
|
323
|
+ }
|
279
|
return dest;
|
324
|
return dest;
|
280
|
};
|
325
|
};
|
281
|
|
326
|
|
|
@@ -365,6 +410,7 @@ exports.handleFilterData = (origin, params) => { |
|
@@ -365,6 +410,7 @@ exports.handleFilterData = (origin, params) => { |
365
|
},
|
410
|
},
|
366
|
price: [],
|
411
|
price: [],
|
367
|
gender: [],
|
412
|
gender: [],
|
|
|
413
|
+ color: [],
|
368
|
checkedConditions: {
|
414
|
checkedConditions: {
|
369
|
conditions: []
|
415
|
conditions: []
|
370
|
}
|
416
|
}
|
|
@@ -502,6 +548,20 @@ exports.handleFilterData = (origin, params) => { |
|
@@ -502,6 +548,20 @@ exports.handleFilterData = (origin, params) => { |
502
|
handleCheckedData(params, dest.size, 'size'));
|
548
|
handleCheckedData(params, dest.size, 'size'));
|
503
|
}
|
549
|
}
|
504
|
|
550
|
|
|
|
551
|
+ // 处理颜色筛选数据
|
|
|
552
|
+ if (!_.isEmpty(origin.color)) {
|
|
|
553
|
+ _.forEach(origin.color, (value, key) => {
|
|
|
554
|
+ let color = {
|
|
|
555
|
+ checked: params.price === key,
|
|
|
556
|
+ href: handleFilterUrl(params, {color: value.color_id}),
|
|
|
557
|
+ name: value.color_name,
|
|
|
558
|
+ rgb: value.color_value ? 'url(' + value.color_value + ')' : '#' + value.color_code
|
|
|
559
|
+ };
|
|
|
560
|
+
|
|
|
561
|
+ dest.color.push(color);
|
|
|
562
|
+ });
|
|
|
563
|
+ }
|
|
|
564
|
+
|
505
|
// 清除所有选中数据
|
565
|
// 清除所有选中数据
|
506
|
let remainParams = {};
|
566
|
let remainParams = {};
|
507
|
|
567
|
|