Showing
3 changed files
with
75 additions
and
72 deletions
@@ -212,26 +212,21 @@ exports.handleOutletsBannersData = (origin, params) => { | @@ -212,26 +212,21 @@ exports.handleOutletsBannersData = (origin, params) => { | ||
212 | * @return {[type]} [description] | 212 | * @return {[type]} [description] |
213 | */ | 213 | */ |
214 | exports.handleOutletsActivityData = (origin, name) => { | 214 | exports.handleOutletsActivityData = (origin, name) => { |
215 | - | ||
216 | - let dest = {}; | ||
217 | - | ||
218 | - let nowTime = Math.round(new Date().getTime() / 1000); | ||
219 | - | ||
220 | - dest.name = name || '限时嗨购'; // 需要根据 name 传值修改 | ||
221 | - dest.topic = []; | 215 | + let dest = { |
216 | + name: name || '限时嗨购', | ||
217 | + topic: [] | ||
218 | + }; | ||
222 | 219 | ||
223 | // 处理奥莱活动列表数据 | 220 | // 处理奥莱活动列表数据 |
224 | _.forEach(origin, value => { | 221 | _.forEach(origin, value => { |
225 | let activity = { | 222 | let activity = { |
226 | - href: helpers.urlFormat('/product/outlets/special/detail', {productPool: value.productPoolId}) | 223 | + href: helpers.urlFormat('/product/outlets/special/detail', {id: value.id}), |
224 | + img: value.webCoverUrl, | ||
225 | + logo: value.logoUrl, | ||
226 | + title: value.title, | ||
227 | + limit: parseInt(value.endLeftTime, 10) * 1000 | ||
227 | }; | 228 | }; |
228 | 229 | ||
229 | - activity.href = helpers.urlFormat('/product/outlets/special/detail', {productPool: value.productPoolId}); | ||
230 | - activity.img = value.webCoverUrl; | ||
231 | - activity.logo = value.logoUrl; | ||
232 | - activity.title = value.title; | ||
233 | - activity.limit = (value.endTime - nowTime) * 1000; | ||
234 | - | ||
235 | if (value.promotionName) { | 230 | if (value.promotionName) { |
236 | Object.assign(activity, discountSplit(value.promotionName)); | 231 | Object.assign(activity, discountSplit(value.promotionName)); |
237 | } | 232 | } |
@@ -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 | ||
@@ -163,8 +163,8 @@ const handleBrandCheckedData = (params, origin) => { | @@ -163,8 +163,8 @@ const handleBrandCheckedData = (params, origin) => { | ||
163 | if (!_.isEmpty(origin)) { | 163 | if (!_.isEmpty(origin)) { |
164 | _.forEach(origin, (value) => { | 164 | _.forEach(origin, (value) => { |
165 | if (typeof _.find(intBrands, o => { | 165 | if (typeof _.find(intBrands, o => { |
166 | - return _.isEqual(o, value.id); | ||
167 | - }) !== 'undefined') { | 166 | + return _.isEqual(o, value.id); |
167 | + }) !== 'undefined') { | ||
168 | 168 | ||
169 | let checked = {}; // push 到已选择数组 | 169 | let checked = {}; // push 到已选择数组 |
170 | 170 | ||
@@ -211,16 +211,16 @@ const handleSalebreakingYardsSortData = (origin, params) => { | @@ -211,16 +211,16 @@ const handleSalebreakingYardsSortData = (origin, params) => { | ||
211 | if (!_.isEmpty(params.sort)) { | 211 | if (!_.isEmpty(params.sort)) { |
212 | 212 | ||
213 | // 是否有分类筛选参数,如果有 | 213 | // 是否有分类筛选参数,如果有 |
214 | - _.forEach(params.sort.split(','), function(sortParam) { | ||
215 | - _.forEach(origin, function(value) { | 214 | + _.forEach(params.sort.split(','), function (sortParam) { |
215 | + _.forEach(origin, function (value) { | ||
216 | 216 | ||
217 | // 判断是否在这组数据里面 | 217 | // 判断是否在这组数据里面 |
218 | if (!_.isEmpty(_.find(value.sort_id.split(','), o => { | 218 | if (!_.isEmpty(_.find(value.sort_id.split(','), o => { |
219 | - return o === sortParam; | ||
220 | - }))) { | 219 | + return o === sortParam; |
220 | + }))) { | ||
221 | 221 | ||
222 | // 如果在某组数据里面,组合数据退出循环 | 222 | // 如果在某组数据里面,组合数据退出循环 |
223 | - _.forEach(value.sub, function(subValue) { | 223 | + _.forEach(value.sub, function (subValue) { |
224 | let size = {}; | 224 | let size = {}; |
225 | 225 | ||
226 | size.checked = | 226 | size.checked = |
@@ -235,8 +235,8 @@ const handleSalebreakingYardsSortData = (origin, params) => { | @@ -235,8 +235,8 @@ const handleSalebreakingYardsSortData = (origin, params) => { | ||
235 | }); | 235 | }); |
236 | }); | 236 | }); |
237 | } else { // 如果没有筛选参数,返回所有分类 | 237 | } else { // 如果没有筛选参数,返回所有分类 |
238 | - _.forEach(origin, function(value) { | ||
239 | - _.forEach(value.sub, function(subValue) { | 238 | + _.forEach(origin, function (value) { |
239 | + _.forEach(value.sub, function (subValue) { | ||
240 | let size = {}; | 240 | let size = {}; |
241 | 241 | ||
242 | size.checked = (parseInt(params.size, 10) === parseInt(subValue.size_id, 10)) ? true : false; | 242 | size.checked = (parseInt(params.size, 10) === parseInt(subValue.size_id, 10)) ? true : false; |
@@ -301,7 +301,7 @@ exports.handleSaleFilterData = (origin, params) => { | @@ -301,7 +301,7 @@ exports.handleSaleFilterData = (origin, params) => { | ||
301 | if (!_.isEmpty(origin.brand)) { | 301 | if (!_.isEmpty(origin.brand)) { |
302 | let count = 0; | 302 | let count = 0; |
303 | 303 | ||
304 | - _.forEach(origin.brand, function(value) { | 304 | + _.forEach(origin.brand, function (value) { |
305 | let brand = {}; | 305 | let brand = {}; |
306 | 306 | ||
307 | brand.checked = (parseInt(params.brand, 10) === parseInt(value.id, 10)) ? true : false; | 307 | brand.checked = (parseInt(params.brand, 10) === parseInt(value.id, 10)) ? true : false; |
@@ -328,13 +328,13 @@ exports.handleSaleFilterData = (origin, params) => { | @@ -328,13 +328,13 @@ exports.handleSaleFilterData = (origin, params) => { | ||
328 | } | 328 | } |
329 | 329 | ||
330 | // 来排排序 | 330 | // 来排排序 |
331 | - dest.brand.brandsShow = _.sortBy(dest.brand.brandsShow, function(o) { | 331 | + dest.brand.brandsShow = _.sortBy(dest.brand.brandsShow, function (o) { |
332 | return o.index; | 332 | return o.index; |
333 | }); | 333 | }); |
334 | 334 | ||
335 | // 处理 价格 筛选数据 | 335 | // 处理 价格 筛选数据 |
336 | if (!_.isEmpty(origin.priceRange)) { | 336 | if (!_.isEmpty(origin.priceRange)) { |
337 | - _.forEach(origin.priceRange, function(value, key) { | 337 | + _.forEach(origin.priceRange, function (value, key) { |
338 | let price = { | 338 | let price = { |
339 | checked: (params.price === key) ? true : false, | 339 | checked: (params.price === key) ? true : false, |
340 | href: handleFilterUrl(params, {price: key}), | 340 | href: handleFilterUrl(params, {price: key}), |
@@ -408,15 +408,15 @@ exports.handleSaleActivityData = (origin, channel) => { | @@ -408,15 +408,15 @@ exports.handleSaleActivityData = (origin, channel) => { | ||
408 | 408 | ||
409 | dest.big = []; | 409 | dest.big = []; |
410 | dest.normal = []; | 410 | dest.normal = []; |
411 | - _.forEach(origin, function(value, key) { | ||
412 | - let activity = {}; | ||
413 | - | ||
414 | - activity.link = | ||
415 | - helpers.urlFormat('/product/sale/discount/detail', {productPool: value.product_pool, channel: channel}); | ||
416 | - activity.img = value.cover_url; | ||
417 | - activity.time = processTime(parseInt(value.left_time, 10) * 1000); | ||
418 | - activity.brand = value.logo_url; | ||
419 | - activity.title = value.title; | 411 | + _.forEach(origin, function (value, key) { |
412 | + let activity = { | ||
413 | + link: helpers.urlFormat('/product/sale/discount/detail', {id: value.id, channel: channel}), | ||
414 | + img: value.cover_url, | ||
415 | + time: processTime(parseInt(value.left_time, 10) * 1000), | ||
416 | + brand: value.logo_url, | ||
417 | + title: value.title | ||
418 | + }; | ||
419 | + | ||
420 | activity = Object.assign(activity, discountSplit(value.promotion_name)); | 420 | activity = Object.assign(activity, discountSplit(value.promotion_name)); |
421 | 421 | ||
422 | if (key < 3) { | 422 | if (key < 3) { |
@@ -455,9 +455,9 @@ exports.handleSaleBannerData = (origin) => { | @@ -455,9 +455,9 @@ exports.handleSaleBannerData = (origin) => { | ||
455 | var dest = {}; | 455 | var dest = {}; |
456 | 456 | ||
457 | dest.list = []; | 457 | dest.list = []; |
458 | - _.forEach(origin, function(value) { | 458 | + _.forEach(origin, function (value) { |
459 | if (value.template_name === 'focus') { | 459 | if (value.template_name === 'focus') { |
460 | - _.forEach(value.data, function(subValue) { | 460 | + _.forEach(value.data, function (subValue) { |
461 | let banner = {}; | 461 | let banner = {}; |
462 | 462 | ||
463 | banner.bannerHeight = 450; | 463 | banner.bannerHeight = 450; |
@@ -482,9 +482,9 @@ exports.handleSaleBannerSmallData = (origin) => { | @@ -482,9 +482,9 @@ exports.handleSaleBannerSmallData = (origin) => { | ||
482 | var dest = []; | 482 | var dest = []; |
483 | let count = 0; | 483 | let count = 0; |
484 | 484 | ||
485 | - _.forEach(origin, function(value) { | 485 | + _.forEach(origin, function (value) { |
486 | if (value.template_name === 'threePicture') { | 486 | if (value.template_name === 'threePicture') { |
487 | - _.forEach(value.data, function(picList) { | 487 | + _.forEach(value.data, function (picList) { |
488 | if (count++ < 3) { | 488 | if (count++ < 3) { |
489 | let smallPic = {}; | 489 | let smallPic = {}; |
490 | 490 |
@@ -316,45 +316,52 @@ exports.getSaleOthersData = (params, channel) => { | @@ -316,45 +316,52 @@ exports.getSaleOthersData = (params, channel) => { | ||
316 | exports.getSaleDiscountData = (params, channel) => { | 316 | exports.getSaleDiscountData = (params, channel) => { |
317 | return api.all([ | 317 | return api.all([ |
318 | headerModel.requestHeaderData(channel), | 318 | headerModel.requestHeaderData(channel), |
319 | - saleApi.getSaleGoodsList(params), | ||
320 | - saleApi.getSaleActivityList(params, channel), | ||
321 | - saleApi.getSaleGoodsList({channel: channel, saleType: '3', limit: '1'}) | 319 | + saleApi.getSaleGoodsList({channel: channel, saleType: '3', limit: '1'}), |
320 | + saleApi.getSaleActivityList(params, channel) | ||
322 | ]).then(result => { | 321 | ]).then(result => { |
323 | let finalResult = result[0]; | 322 | let finalResult = result[0]; |
324 | 323 | ||
325 | - // 处理商品数据,顶部分类 | 324 | + // 处理折扣专场标题 banner 数据 |
326 | if (result[1].code === 200) { | 325 | if (result[1].code === 200) { |
327 | - finalResult.saleList = {}; | ||
328 | - finalResult.saleList.goods = productProcess.processProductList(result[1].data.product_list); | ||
329 | - finalResult.saleList.totalCount = result[1].data.total; | ||
330 | - | ||
331 | - _.forEach(finalResult.saleList.goods, (value, key) => { | ||
332 | - delete finalResult.saleList.goods[key].tags.isNew; // 屏蔽 new 标签 | ||
333 | - delete finalResult.saleList.goods[key].tags.isSale;// 屏蔽 sale 标签 | ||
334 | - delete finalResult.saleList.goods[key].discount; // 屏蔽折扣信息 | 326 | + Object.assign(finalResult, { |
327 | + leftContent: publicHandler.handleSaleSortData(result[1].data.filter.group_sort, params, 'discount'), | ||
328 | + saleList: { | ||
329 | + pager: publicHandler.handleSalePagerData(result[1].data.total, params), | ||
330 | + opts: publicHandler.handleSaleOptsData(params, result[1].data.total) | ||
331 | + } | ||
335 | }); | 332 | }); |
336 | } | 333 | } |
337 | 334 | ||
338 | - // 处理折扣专场标题 banner 数据 | 335 | + // 处理分页等筛选信息 |
339 | if (result[2].code === 200) { | 336 | if (result[2].code === 200) { |
337 | + | ||
340 | if (_.size(result[2].data) === 1) { | 338 | if (_.size(result[2].data) === 1) { |
341 | finalResult.saleTitle = saleHandler.handleDiscountTitleData(result[2].data[0]); | 339 | finalResult.saleTitle = saleHandler.handleDiscountTitleData(result[2].data[0]); |
342 | finalResult.topBanner = {}; | 340 | finalResult.topBanner = {}; |
343 | finalResult.topBanner.list = []; | 341 | finalResult.topBanner.list = []; |
344 | - finalResult.topBanner.list[0] = {}; | ||
345 | - finalResult.topBanner.list[0].img = result[2].data[0].web_url; | 342 | + finalResult.topBanner.list[0] = { |
343 | + img: result[2].data[0].web_url | ||
344 | + }; | ||
346 | } | 345 | } |
347 | - } | ||
348 | 346 | ||
349 | - // 处理分页等筛选信息 | ||
350 | - if (result[3].code === 200) { | ||
351 | - finalResult.leftContent = | ||
352 | - publicHandler.handleSaleSortData(result[3].data.filter.group_sort, params, 'discount'); | ||
353 | - finalResult.saleList.pager = publicHandler.handleSalePagerData(result[3].data.total, params); | ||
354 | - finalResult.saleList.opts = publicHandler.handleSaleOptsData(params, result[3].data.total); | ||
355 | - } | 347 | + return api.all([ |
348 | + saleApi.getSaleGoodsList(Object.assign(params, {productPool: result[2].data[0].product_pool})) | ||
349 | + ]).then(subResult => { | ||
350 | + // 处理商品数据,顶部分类 | ||
351 | + if (subResult[0].code === 200) { | ||
352 | + finalResult.saleList.goods = productProcess.processProductList(subResult[0].data.product_list); | ||
353 | + finalResult.saleList.totalCount = subResult[0].data.total; | ||
356 | 354 | ||
355 | + _.forEach(finalResult.saleList.goods, (value, key) => { | ||
356 | + delete finalResult.saleList.goods[key].tags.isNew; // 屏蔽 new 标签 | ||
357 | + delete finalResult.saleList.goods[key].tags.isSale;// 屏蔽 sale 标签 | ||
358 | + delete finalResult.saleList.goods[key].discount; // 屏蔽折扣信息 | ||
359 | + }); | ||
360 | + } | ||
357 | 361 | ||
362 | + return finalResult; | ||
363 | + }); | ||
364 | + } | ||
358 | return finalResult; | 365 | return finalResult; |
359 | }); | 366 | }); |
360 | }; | 367 | }; |
@@ -410,17 +417,18 @@ exports.getSalebreakingYardsData = (params, channel) => { | @@ -410,17 +417,18 @@ exports.getSalebreakingYardsData = (params, channel) => { | ||
410 | Object.assign(subResult[1].data.filter, {size: result[2].data}), | 417 | Object.assign(subResult[1].data.filter, {size: result[2].data}), |
411 | params); | 418 | params); |
412 | } | 419 | } |
413 | - | ||
414 | - finalResult.goods = productProcess.processProductList(subResult[1].data.product_list); | ||
415 | - finalResult.opts = publicHandler.handleSaleOptsData(params, subResult[1].data.total); | ||
416 | - finalResult.totalCount = subResult[1].data.total; | ||
417 | - finalResult.pager = publicHandler.handleSalePagerData(subResult[1].data.total, params); | 420 | + Object.assign(finalResult, { |
421 | + goods: productProcess.processProductList(subResult[1].data.product_list), | ||
422 | + opts: publicHandler.handleSaleOptsData(params, subResult[1].data.total), | ||
423 | + totalCount: subResult[1].data.total, | ||
424 | + pager: publicHandler.handleSalePagerData(subResult[1].data.total, params) | ||
425 | + }); | ||
418 | 426 | ||
419 | // 处理所有商品标题数据 | 427 | // 处理所有商品标题数据 |
420 | - finalResult.saleTitle = {}; | ||
421 | - | ||
422 | - finalResult.saleTitle.name = '所有商品'; | ||
423 | - finalResult.saleTitle.count = subResult[1].data.count; | 428 | + finalResult.saleTitle = { |
429 | + name: '所有商品', | ||
430 | + count: subResult[1].data.count | ||
431 | + }; | ||
424 | 432 | ||
425 | _.forEach(finalResult.goods, (value, key) => { | 433 | _.forEach(finalResult.goods, (value, key) => { |
426 | delete finalResult.goods[key].tags.isNew; // 屏蔽 new 标签 | 434 | delete finalResult.goods[key].tags.isNew; // 屏蔽 new 标签 |
-
Please register or login to post a comment