Showing
1 changed file
with
39 additions
and
45 deletions
@@ -80,7 +80,7 @@ const handleFilterUrl = (originParam, newParam) => { | @@ -80,7 +80,7 @@ const handleFilterUrl = (originParam, newParam) => { | ||
80 | 80 | ||
81 | tempOriginParam = Object.assign(tempOriginParam, originParam, newParam); | 81 | tempOriginParam = Object.assign(tempOriginParam, originParam, newParam); |
82 | 82 | ||
83 | - _.forEach(tempOriginParam, function(value, key) { | 83 | + _.forEach(tempOriginParam, function (value, key) { |
84 | dest = dest + key + '=' + value + '&'; | 84 | dest = dest + key + '=' + value + '&'; |
85 | }); | 85 | }); |
86 | 86 | ||
@@ -93,9 +93,7 @@ const handleFilterUrl = (originParam, newParam) => { | @@ -93,9 +93,7 @@ const handleFilterUrl = (originParam, newParam) => { | ||
93 | * @returns {Array|*[]} | 93 | * @returns {Array|*[]} |
94 | */ | 94 | */ |
95 | const handleSaleNewSaleSortData = (params) => { | 95 | const handleSaleNewSaleSortData = (params) => { |
96 | - var dest; | ||
97 | - | ||
98 | - dest = [{ | 96 | + return [{ |
99 | name: '1~3折', | 97 | name: '1~3折', |
100 | href: handleFilterUrl(params, {p_d: '0.1,0.3'}), | 98 | href: handleFilterUrl(params, {p_d: '0.1,0.3'}), |
101 | checked: params.p_d === '0.1,0.3' | 99 | checked: params.p_d === '0.1,0.3' |
@@ -108,8 +106,6 @@ const handleSaleNewSaleSortData = (params) => { | @@ -108,8 +106,6 @@ const handleSaleNewSaleSortData = (params) => { | ||
108 | href: handleFilterUrl(params, {p_d: '0.7,1'}), | 106 | href: handleFilterUrl(params, {p_d: '0.7,1'}), |
109 | checked: params.p_d === '0.7,1' | 107 | checked: params.p_d === '0.7,1' |
110 | }]; | 108 | }]; |
111 | - | ||
112 | - return dest; | ||
113 | }; | 109 | }; |
114 | 110 | ||
115 | /** | 111 | /** |
@@ -165,8 +161,8 @@ const handleBrandCheckedData = (params, origin) => { | @@ -165,8 +161,8 @@ const handleBrandCheckedData = (params, origin) => { | ||
165 | if (!_.isEmpty(origin)) { | 161 | if (!_.isEmpty(origin)) { |
166 | _.forEach(origin, (value) => { | 162 | _.forEach(origin, (value) => { |
167 | if (typeof _.find(intBrands, o => { | 163 | if (typeof _.find(intBrands, o => { |
168 | - return _.isEqual(o, value.id); | ||
169 | - }) !== 'undefined') { | 164 | + return _.isEqual(o, value.id); |
165 | + }) !== 'undefined') { | ||
170 | 166 | ||
171 | let checked = { | 167 | let checked = { |
172 | name: value.name | 168 | name: value.name |
@@ -221,22 +217,21 @@ const handleSalebreakingYardsSortData = (origin, params) => { | @@ -221,22 +217,21 @@ const handleSalebreakingYardsSortData = (origin, params) => { | ||
221 | if (!_.isEmpty(params.sort)) { | 217 | if (!_.isEmpty(params.sort)) { |
222 | 218 | ||
223 | // 是否有分类筛选参数,如果有 | 219 | // 是否有分类筛选参数,如果有 |
224 | - _.forEach(params.sort.split(','), function(sortParam) { | ||
225 | - _.forEach(origin, function(value) { | 220 | + _.forEach(params.sort.split(','), function (sortParam) { |
221 | + _.forEach(origin, function (value) { | ||
226 | 222 | ||
227 | // 判断是否在这组数据里面 | 223 | // 判断是否在这组数据里面 |
228 | if (!_.isEmpty(_.find(value.sort_id.split(','), o => { | 224 | if (!_.isEmpty(_.find(value.sort_id.split(','), o => { |
229 | - return o === sortParam; | ||
230 | - }))) { | 225 | + return o === sortParam; |
226 | + }))) { | ||
231 | 227 | ||
232 | // 如果在某组数据里面,组合数据退出循环 | 228 | // 如果在某组数据里面,组合数据退出循环 |
233 | - _.forEach(value.sub, function(subValue) { | ||
234 | - let size = {}; | ||
235 | - | ||
236 | - size.checked = | ||
237 | - parseInt(params.size, 10) === parseInt(subValue.size_id, 10); | ||
238 | - size.href = handleFilterUrl(params, {size: subValue.size_id}); | ||
239 | - size.name = subValue.size_name; | 229 | + _.forEach(value.sub, function (subValue) { |
230 | + let size = { | ||
231 | + checked: parseInt(params.size, 10) === parseInt(subValue.size_id, 10), | ||
232 | + href: handleFilterUrl(params, {size: subValue.size_id}), | ||
233 | + name: subValue.size_name | ||
234 | + }; | ||
240 | 235 | ||
241 | dest.push(size); | 236 | dest.push(size); |
242 | }); | 237 | }); |
@@ -245,13 +240,13 @@ const handleSalebreakingYardsSortData = (origin, params) => { | @@ -245,13 +240,13 @@ const handleSalebreakingYardsSortData = (origin, params) => { | ||
245 | }); | 240 | }); |
246 | }); | 241 | }); |
247 | } else { // 如果没有筛选参数,返回所有分类 | 242 | } else { // 如果没有筛选参数,返回所有分类 |
248 | - _.forEach(origin, function(value) { | ||
249 | - _.forEach(value.sub, function(subValue) { | ||
250 | - let size = {}; | ||
251 | - | ||
252 | - size.checked = parseInt(params.size, 10) === parseInt(subValue.size_id, 10); | ||
253 | - size.href = handleFilterUrl(params, {size: subValue.size_id}); | ||
254 | - size.name = subValue.size_name; | 243 | + _.forEach(origin, function (value) { |
244 | + _.forEach(value.sub, function (subValue) { | ||
245 | + let size = { | ||
246 | + checked: parseInt(params.size, 10) === parseInt(subValue.size_id, 10), | ||
247 | + href: handleFilterUrl(params, {size: subValue.size_id}), | ||
248 | + name: subValue.size_name | ||
249 | + }; | ||
255 | 250 | ||
256 | dest.push(size); | 251 | dest.push(size); |
257 | }); | 252 | }); |
@@ -273,7 +268,16 @@ exports.handleSaleFilterData = (origin, params) => { | @@ -273,7 +268,16 @@ exports.handleSaleFilterData = (origin, params) => { | ||
273 | brand: { | 268 | brand: { |
274 | default: [], | 269 | default: [], |
275 | brandsShow: [], | 270 | brandsShow: [], |
276 | - brandIndex: [], | 271 | + brandIndex: [ |
272 | + { | ||
273 | + index: 'all', | ||
274 | + name: '全部' | ||
275 | + }, | ||
276 | + { | ||
277 | + index: '0-9', | ||
278 | + name: '0~9' | ||
279 | + } | ||
280 | + ], | ||
277 | showMore: true, | 281 | showMore: true, |
278 | showMulti: true | 282 | showMulti: true |
279 | }, | 283 | }, |
@@ -285,16 +289,6 @@ exports.handleSaleFilterData = (origin, params) => { | @@ -285,16 +289,6 @@ exports.handleSaleFilterData = (origin, params) => { | ||
285 | }; | 289 | }; |
286 | 290 | ||
287 | // 品牌索引数据处理 | 291 | // 品牌索引数据处理 |
288 | - dest.brand.brandIndex[0] = { | ||
289 | - index: 'all', | ||
290 | - name: '全部' | ||
291 | - }; | ||
292 | - | ||
293 | - dest.brand.brandIndex[1] = { | ||
294 | - index: '0-9', | ||
295 | - name: '0~9' | ||
296 | - }; | ||
297 | - | ||
298 | for (let i = 65; i < 91; i++) { | 292 | for (let i = 65; i < 91; i++) { |
299 | dest.brand.brandIndex.push({ | 293 | dest.brand.brandIndex.push({ |
300 | index: String.fromCharCode(i).toLowerCase(), | 294 | index: String.fromCharCode(i).toLowerCase(), |
@@ -313,7 +307,7 @@ exports.handleSaleFilterData = (origin, params) => { | @@ -313,7 +307,7 @@ exports.handleSaleFilterData = (origin, params) => { | ||
313 | if (!_.isEmpty(origin.brand)) { | 307 | if (!_.isEmpty(origin.brand)) { |
314 | let count = 0; | 308 | let count = 0; |
315 | 309 | ||
316 | - _.forEach(origin.brand, function(value) { | 310 | + _.forEach(origin.brand, function (value) { |
317 | let brand = { | 311 | let brand = { |
318 | checked: (typeof _.find(intBrands, o => { | 312 | checked: (typeof _.find(intBrands, o => { |
319 | return _.isEqual(o, value.id); | 313 | return _.isEqual(o, value.id); |
@@ -342,13 +336,13 @@ exports.handleSaleFilterData = (origin, params) => { | @@ -342,13 +336,13 @@ exports.handleSaleFilterData = (origin, params) => { | ||
342 | } | 336 | } |
343 | 337 | ||
344 | // 来排排序 | 338 | // 来排排序 |
345 | - dest.brand.brandsShow = _.sortBy(dest.brand.brandsShow, function(o) { | 339 | + dest.brand.brandsShow = _.sortBy(dest.brand.brandsShow, function (o) { |
346 | return o.index; | 340 | return o.index; |
347 | }); | 341 | }); |
348 | 342 | ||
349 | // 处理 价格 筛选数据 | 343 | // 处理 价格 筛选数据 |
350 | if (!_.isEmpty(origin.priceRange)) { | 344 | if (!_.isEmpty(origin.priceRange)) { |
351 | - _.forEach(origin.priceRange, function(value, key) { | 345 | + _.forEach(origin.priceRange, function (value, key) { |
352 | let price = { | 346 | let price = { |
353 | checked: params.price === key, | 347 | checked: params.price === key, |
354 | href: handleFilterUrl(params, {price: key}), | 348 | href: handleFilterUrl(params, {price: key}), |
@@ -423,7 +417,7 @@ exports.handleSaleActivityData = (origin, channel) => { | @@ -423,7 +417,7 @@ exports.handleSaleActivityData = (origin, channel) => { | ||
423 | normal: [] | 417 | normal: [] |
424 | }; | 418 | }; |
425 | 419 | ||
426 | - _.forEach(origin, function(value, key) { | 420 | + _.forEach(origin, function (value, key) { |
427 | let activity = { | 421 | let activity = { |
428 | link: helpers.urlFormat('/product/sale/discount/detail', {id: value.id, channel: channel}), | 422 | link: helpers.urlFormat('/product/sale/discount/detail', {id: value.id, channel: channel}), |
429 | img: value.cover_url, | 423 | img: value.cover_url, |
@@ -470,9 +464,9 @@ exports.handleSaleBannerData = (origin) => { | @@ -470,9 +464,9 @@ exports.handleSaleBannerData = (origin) => { | ||
470 | list: [] | 464 | list: [] |
471 | }; | 465 | }; |
472 | 466 | ||
473 | - _.forEach(origin, function(value) { | 467 | + _.forEach(origin, function (value) { |
474 | if (value.template_name === 'focus') { | 468 | if (value.template_name === 'focus') { |
475 | - _.forEach(value.data, function(subValue) { | 469 | + _.forEach(value.data, function (subValue) { |
476 | let banner = { | 470 | let banner = { |
477 | bannerHeight: 450, | 471 | bannerHeight: 450, |
478 | href: subValue.url, | 472 | href: subValue.url, |
@@ -496,9 +490,9 @@ exports.handleSaleBannerSmallData = (origin) => { | @@ -496,9 +490,9 @@ exports.handleSaleBannerSmallData = (origin) => { | ||
496 | var dest = []; | 490 | var dest = []; |
497 | let count = 0; | 491 | let count = 0; |
498 | 492 | ||
499 | - _.forEach(origin, function(value) { | 493 | + _.forEach(origin, function (value) { |
500 | if (value.template_name === 'threePicture') { | 494 | if (value.template_name === 'threePicture') { |
501 | - _.forEach(value.data, function(picList) { | 495 | + _.forEach(value.data, function (picList) { |
502 | if (count++ < 3) { | 496 | if (count++ < 3) { |
503 | let smallPic = { | 497 | let smallPic = { |
504 | link: picList.url, | 498 | link: picList.url, |
-
Please register or login to post a comment