Authored by 周少峰

Merge branch 'release/4.6' of http://git.yoho.cn/fe/yohobuy-node into release/4.6

@@ -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 }
@@ -98,7 +98,7 @@ exports.getOutletsIndexData = (params, channel) => { @@ -98,7 +98,7 @@ exports.getOutletsIndexData = (params, channel) => {
98 } 98 }
99 99
100 // 处理即将上架品牌数据 100 // 处理即将上架品牌数据
101 - if (result[6].code === 200) { 101 + if (result[6].code === 200 && !_.isEmpty(result[6].data)) {
102 finalResult.limitedBuy.extra.comeSoon = outletsProcess.handleComeSoonData(result[6].data); 102 finalResult.limitedBuy.extra.comeSoon = outletsProcess.handleComeSoonData(result[6].data);
103 } 103 }
104 104
@@ -248,8 +248,9 @@ exports.getOutletsCategoryData = (params, channel) => { @@ -248,8 +248,9 @@ exports.getOutletsCategoryData = (params, channel) => {
248 if (!_.isEmpty(params.bannerImage)) { 248 if (!_.isEmpty(params.bannerImage)) {
249 finalResult.saleList.topBanner = {}; 249 finalResult.saleList.topBanner = {};
250 finalResult.saleList.topBanner.list = []; 250 finalResult.saleList.topBanner.list = [];
251 - finalResult.saleList.topBanner.list[0] = {};  
252 - finalResult.saleList.topBanner.list[0].img = params.bannerImage; 251 + finalResult.saleList.topBanner.list[0] = {
  252 + img: params.bannerImage
  253 + };
253 } 254 }
254 return finalResult; 255 return finalResult;
255 }); 256 });
@@ -409,14 +409,14 @@ exports.handleSaleActivityData = (origin, channel) => { @@ -409,14 +409,14 @@ exports.handleSaleActivityData = (origin, channel) => {
409 dest.big = []; 409 dest.big = [];
410 dest.normal = []; 410 dest.normal = [];
411 _.forEach(origin, function(value, key) { 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; 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) {
@@ -63,8 +63,9 @@ exports.getSaleGoodsData = (params) => { @@ -63,8 +63,9 @@ exports.getSaleGoodsData = (params) => {
63 if (result[0].code === 200) { 63 if (result[0].code === 200) {
64 finalResult.goods = productProcess.processProductList(result[0].data.product_list); 64 finalResult.goods = productProcess.processProductList(result[0].data.product_list);
65 _.forEach(finalResult.goods, (value, key) => { 65 _.forEach(finalResult.goods, (value, key) => {
66 - finalResult.goods[key].tags.isNew = false; // 屏蔽 new 标签  
67 - finalResult.goods[key].tags.isSale = false; 66 + delete finalResult.goods[key].tags.isNew; // 屏蔽 new 标签
  67 + delete finalResult.goods[key].tags.isSale;// 屏蔽 sale 标签
  68 + delete finalResult.goods[key].discount; // 屏蔽折扣信息
68 }); 69 });
69 } 70 }
70 71
@@ -315,47 +316,54 @@ exports.getSaleOthersData = (params, channel) => { @@ -315,47 +316,54 @@ exports.getSaleOthersData = (params, channel) => {
315 exports.getSaleDiscountData = (params, channel) => { 316 exports.getSaleDiscountData = (params, channel) => {
316 return api.all([ 317 return api.all([
317 headerModel.requestHeaderData(channel), 318 headerModel.requestHeaderData(channel),
318 - saleApi.getSaleGoodsList(params),  
319 - saleApi.getSaleActivityList(params, channel),  
320 - saleApi.getSaleGoodsList({channel: channel, saleType: '3', limit: '1'}) 319 + saleApi.getSaleGoodsList({channel: channel, saleType: '3', limit: '1'}),
  320 + saleApi.getSaleActivityList(params, channel)
321 ]).then(result => { 321 ]).then(result => {
322 let finalResult = result[0]; 322 let finalResult = result[0];
323 323
324 - // 处理商品数据,顶部分类 324 + // 处理折扣专场标题 banner 数据
325 if (result[1].code === 200) { 325 if (result[1].code === 200) {
326 - finalResult.saleList = {};  
327 - finalResult.saleList.goods = productProcess.processProductList(result[1].data.product_list);  
328 - finalResult.saleList.totalCount = result[1].data.total;  
329 -  
330 - _.forEach(finalResult.saleList.goods, (value, key) => {  
331 - delete finalResult.saleList.goods[key].tags.isNew; // 屏蔽 new 标签  
332 - delete finalResult.saleList.goods[key].tags.isSale;// 屏蔽 sale 标签  
333 - 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 + }
334 }); 332 });
335 } 333 }
336 334
337 - // 处理折扣专场标题 banner 数据 335 + // 处理分页等筛选信息
338 if (result[2].code === 200) { 336 if (result[2].code === 200) {
  337 +
339 if (_.size(result[2].data) === 1) { 338 if (_.size(result[2].data) === 1) {
340 finalResult.saleTitle = saleHandler.handleDiscountTitleData(result[2].data[0]); 339 finalResult.saleTitle = saleHandler.handleDiscountTitleData(result[2].data[0]);
341 finalResult.topBanner = {}; 340 finalResult.topBanner = {};
342 finalResult.topBanner.list = []; 341 finalResult.topBanner.list = [];
343 - finalResult.topBanner.list[0] = {};  
344 - finalResult.topBanner.list[0].img = result[2].data[0].web_url;  
345 - } 342 + finalResult.topBanner.list[0] = {
  343 + img: result[2].data[0].web_url
  344 + };
346 } 345 }
347 346
348 - // 处理分页等筛选信息  
349 - if (result[3].code === 200) {  
350 - finalResult.leftContent =  
351 - publicHandler.handleSaleSortData(result[3].data.filter.group_sort, params, 'discount');  
352 - finalResult.saleList.pager = publicHandler.handleSalePagerData(result[3].data.total, params);  
353 - finalResult.saleList.opts = publicHandler.handleSaleOptsData(params, result[3].data.total);  
354 - } 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;
355 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 + }
356 361
357 return finalResult; 362 return finalResult;
358 }); 363 });
  364 + }
  365 + return finalResult;
  366 + });
359 }; 367 };
360 368
361 /** 369 /**
@@ -409,17 +417,18 @@ exports.getSalebreakingYardsData = (params, channel) => { @@ -409,17 +417,18 @@ exports.getSalebreakingYardsData = (params, channel) => {
409 Object.assign(subResult[1].data.filter, {size: result[2].data}), 417 Object.assign(subResult[1].data.filter, {size: result[2].data}),
410 params); 418 params);
411 } 419 }
412 -  
413 - finalResult.goods = productProcess.processProductList(subResult[1].data.product_list);  
414 - finalResult.opts = publicHandler.handleSaleOptsData(params, subResult[1].data.total);  
415 - finalResult.totalCount = subResult[1].data.total;  
416 - 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 + });
417 426
418 // 处理所有商品标题数据 427 // 处理所有商品标题数据
419 - finalResult.saleTitle = {};  
420 -  
421 - finalResult.saleTitle.name = '所有商品';  
422 - finalResult.saleTitle.count = subResult[1].data.count; 428 + finalResult.saleTitle = {
  429 + name: '所有商品',
  430 + count: subResult[1].data.count
  431 + };
423 432
424 _.forEach(finalResult.goods, (value, key) => { 433 _.forEach(finalResult.goods, (value, key) => {
425 delete finalResult.goods[key].tags.isNew; // 屏蔽 new 标签 434 delete finalResult.goods[key].tags.isNew; // 屏蔽 new 标签