...
|
...
|
@@ -2,7 +2,7 @@ |
|
|
* @Author: Targaryen
|
|
|
* @Date: 2016-05-19 10:20:08
|
|
|
* @Last Modified by: Targaryen
|
|
|
* @Last Modified time: 2016-06-01 18:46:02
|
|
|
* @Last Modified time: 2016-06-02 12:53:05
|
|
|
*/
|
|
|
|
|
|
'use strict';
|
...
|
...
|
@@ -15,6 +15,34 @@ const saleHandler = require('./sale-handler'); |
|
|
const productProcess = require(`${utils}/product-process`);
|
|
|
const _ = require('lodash');
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 资源位code码
|
|
|
*/
|
|
|
const contentCode = {
|
|
|
boys: {
|
|
|
sale: 'f6400250a73a2a1a8764a0d9be73abf2',
|
|
|
breakCode: 'a97451680222cb1b215de14bbef64921',
|
|
|
vip: '0400ac0dffbb2fefe84949200cf2be4a'
|
|
|
},
|
|
|
girls: {
|
|
|
sale: 'd74adc70f939a6658b68386ee39199e7',
|
|
|
breakCode: '91e604f06449783a5bd93c6f4f99a396',
|
|
|
vip: 'e261419fde3613781a3ec9d367a2e534'
|
|
|
},
|
|
|
kids: {
|
|
|
sale: '01937a472a5a3ccf7204f734f2506865',
|
|
|
breakCode: '4c1dff47c68aace0608eb821fbaf40fd',
|
|
|
vip: '40db7c9a491548fa8d441815cc7a0617'
|
|
|
},
|
|
|
lifestyle: {
|
|
|
sale: '32944e49d627a031f1d7e14a1f90ccac',
|
|
|
breakCode: 'c605c9d2f1a426cecad232a7d41e6b97',
|
|
|
vip: '6ac5f0ee1cf0f2dab89c9cf80263028a'
|
|
|
}
|
|
|
};
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 获取Sale首页商品列表数据 仅 Ajax 调用 Controller 调用
|
|
|
* @return {[type]} [description]
|
...
|
...
|
@@ -107,27 +135,22 @@ exports.getSaleIndexData = () => { |
|
|
* 获取 VIP 会员专享和新降价专区数据 Controller 调用
|
|
|
* @return {[type]} [description]
|
|
|
*/
|
|
|
exports.getSaleOthersData = (params) => {
|
|
|
exports.getSaleOthersData = (params, channel) => {
|
|
|
|
|
|
let promiseObject;
|
|
|
|
|
|
// cCode 是资源位代码,根据页面不同传不同的 CODE,目前一样,待处理
|
|
|
// saleType: 1表示断码区,2表示会员专区,3 折扣专区,4表示奥莱
|
|
|
let cCode;
|
|
|
|
|
|
if (!_.isEmpty(params) && params.saleType === 2) {
|
|
|
cCode = '7c2b77093421efa8ae9302c91460db73';
|
|
|
promiseObject = [
|
|
|
saleApi.getSaleGoodsList(params),
|
|
|
saleApi.getSaleBannerList(cCode),
|
|
|
saleApi.getSaleBannerList(contentCode[channel].vip),
|
|
|
saleApi.getLeftContentList(),
|
|
|
saleApi.getUserProfile(params.uid)
|
|
|
];
|
|
|
} else {
|
|
|
cCode = '7c2b77093421efa8ae9302c91460db73';
|
|
|
promiseObject = [
|
|
|
saleApi.getSaleGoodsList(params),
|
|
|
saleApi.getSaleBannerList(cCode),
|
|
|
saleApi.getSaleBannerList(contentCode[channel].vip),
|
|
|
saleApi.getLeftContentList()
|
|
|
];
|
|
|
}
|
...
|
...
|
@@ -169,30 +192,32 @@ exports.getSaleOthersData = (params) => { |
|
|
}
|
|
|
}
|
|
|
|
|
|
// 处理 VIP 商品数据
|
|
|
if (result[3].code === 200 && parseInt(params.saleType, 10) === 2) {
|
|
|
_.forEach(finalResult.goods, (value, key) => {
|
|
|
|
|
|
switch (result[3].curLevel) {
|
|
|
case '1':
|
|
|
finalResult.goods[key].vipPrice = value.vip1_price;
|
|
|
finalResult.goods[key].vip1 = true;
|
|
|
break;
|
|
|
case '2':
|
|
|
finalResult.goods[key].vipPrice = value.vip2_price;
|
|
|
finalResult.goods[key].vip2 = true;
|
|
|
break;
|
|
|
case '3':
|
|
|
finalResult.goods[key].vipPrice = value.vip3_price;
|
|
|
finalResult.goods[key].vip3 = true;
|
|
|
break;
|
|
|
default:
|
|
|
finalResult.goods[key].vipPrice = value.vip_price;
|
|
|
finalResult.goods[key].vip = true;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
});
|
|
|
if (!_.isEmpty(result[3])) {
|
|
|
// 处理 VIP 商品数据
|
|
|
if (result[3].code === 200 && parseInt(params.saleType, 10) === 2) {
|
|
|
_.forEach(finalResult.goods, (value, key) => {
|
|
|
|
|
|
switch (result[3].curLevel) {
|
|
|
case '1':
|
|
|
finalResult.goods[key].vipPrice = value.vip1_price;
|
|
|
finalResult.goods[key].vip1 = true;
|
|
|
break;
|
|
|
case '2':
|
|
|
finalResult.goods[key].vipPrice = value.vip2_price;
|
|
|
finalResult.goods[key].vip2 = true;
|
|
|
break;
|
|
|
case '3':
|
|
|
finalResult.goods[key].vipPrice = value.vip3_price;
|
|
|
finalResult.goods[key].vip3 = true;
|
|
|
break;
|
|
|
default:
|
|
|
finalResult.goods[key].vipPrice = value.vip_price;
|
|
|
finalResult.goods[key].vip = true;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return finalResult;
|
...
|
...
|
@@ -203,10 +228,10 @@ exports.getSaleOthersData = (params) => { |
|
|
* 获取折扣专场数据 Controller 调用
|
|
|
* @return {[type]} [description]
|
|
|
*/
|
|
|
exports.getSaleDiscountData = (params) => {
|
|
|
exports.getSaleDiscountData = (params, channel) => {
|
|
|
return api.all([
|
|
|
saleApi.getSaleGoodsList(params),
|
|
|
saleApi.getSaleBannerList('7c2b77093421efa8ae9302c91460db73'),
|
|
|
saleApi.getSaleBannerList(contentCode[channel].sale),
|
|
|
saleApi.getSaleActivityList(params)
|
|
|
]).then(result => {
|
|
|
let finalResult = {};
|
...
|
...
|
@@ -219,7 +244,7 @@ exports.getSaleDiscountData = (params) => { |
|
|
finalResult.saleList.totalCount = result[0].data.total;
|
|
|
finalResult.saleList.pager = saleHandler.handleSalePagerData(result[0].data.total, params);
|
|
|
|
|
|
// 处理所有商品标题数据
|
|
|
// 处理所有商品标题数据
|
|
|
finalResult.saleTitle = {};
|
|
|
|
|
|
finalResult.saleTitle.name = '所有商品';
|
...
|
...
|
@@ -247,11 +272,11 @@ exports.getSaleDiscountData = (params) => { |
|
|
* @param {[type]} params [description]
|
|
|
* @return {[type]} [description]
|
|
|
*/
|
|
|
exports.getSalebreakingYardsData = (params) => {
|
|
|
exports.getSalebreakingYardsData = (params, channel) => {
|
|
|
return api.all([
|
|
|
saleApi.getSaleGoodsList(params),
|
|
|
saleApi.getSalebreakingYardsSortList(),
|
|
|
saleApi.getSaleBannerList('7c2b77093421efa8ae9302c91460db73'),
|
|
|
saleApi.getSaleBannerList(contentCode[channel].breakCode),
|
|
|
saleApi.getLeftContentList()
|
|
|
]).then(result => {
|
|
|
let finalResult = {};
|
...
|
...
|
|