Authored by 刘传洋

new sale off filter

@@ -138,23 +138,26 @@ const handleBrandCheckedData = (params, origin) => { @@ -138,23 +138,26 @@ const handleBrandCheckedData = (params, origin) => {
138 /** 138 /**
139 * 新品、折扣、限量 139 * 新品、折扣、限量
140 */ 140 */
141 -const hadleChecks = (name, params) => {  
142 - let tempParam = _.cloneDeep(params); 141 +const hadleChecks = (name, params, filter) => {
  142 + let tempParam = _.cloneDeep(params),
  143 + checked= false;
143 144
144 - tempParam[name] = 'Y';  
145 - let checksOpts = {  
146 - name: checksName[name],  
147 - checked: false,  
148 - href: handleFilterUrl(tempParam)  
149 - }; 145 + if(!params[name] && !filter[name]) {
  146 + return null;
  147 + }
150 148
151 if (params[name] && params[name] === 'Y') { 149 if (params[name] && params[name] === 'Y') {
152 - checksOpts.checked = true; 150 + checked = true;
153 delete tempParam[name]; 151 delete tempParam[name];
154 - checksOpts.href = handleFilterUrl(tempParam); 152 + } else {
  153 + tempParam[name] = 'Y';
155 } 154 }
156 155
157 - return checksOpts; 156 + return {
  157 + name: checksName[name],
  158 + checked: checked,
  159 + href: handleFilterUrl(tempParam)
  160 + };
158 }; 161 };
159 162
160 /** 163 /**
@@ -335,19 +338,17 @@ exports.handleOptsData = (params, total, extra) => { @@ -335,19 +338,17 @@ exports.handleOptsData = (params, total, extra) => {
335 338
336 if (extra) { 339 if (extra) {
337 // 新品 340 // 新品
338 - if (extra.new === 'Y') {  
339 - dest.checks.push(hadleChecks('new', params));  
340 - } 341 + dest.checks.push(hadleChecks('new', params, extra));
341 342
342 // 打折 343 // 打折
343 - if (extra.specialoffer === 'Y') {  
344 - dest.checks.push(hadleChecks('specialoffer', params));  
345 - } 344 + dest.checks.push(hadleChecks('specialoffer', params, extra));
346 345
347 // 限量 346 // 限量
348 - if (extra.limited === 'Y') {  
349 - dest.checks.push(hadleChecks('limited', params));  
350 - } 347 + dest.checks.push(hadleChecks('limited', params, extra));
  348 +
  349 + dest.checks = _.filter(dest.checks, chk => {
  350 + return chk !== null;
  351 + });
351 } 352 }
352 return dest; 353 return dest;
353 }; 354 };