Authored by 郭成尧

首页VIP数据

... ... @@ -25,9 +25,6 @@ const sale = require(`${mRoot}/sale`);
*/
exports.index = (req, res) => {
let responseData = {};
let params = {};
params.uid = req.user.uid || 0;
headerModel.requestHeaderData()
.then(headerData => {
... ... @@ -42,7 +39,7 @@ exports.index = (req, res) => {
// res.render('sale/index', Object.assign(responseData, simulation.saleIndex()));
// 真实数据输出
sale.getSaleIndexData(params).then(result => {
sale.getSaleIndexData().then(result => {
responseData.result = result;
responseData.resultShow = JSON.stringify(result, null, 4);
... ... @@ -219,10 +216,12 @@ exports.getGoodsList = (req, res) => {
let responseData = {};
responseData.devEnv = true;
responseData.result = result;
responseData.footerTop = false;
responseData.layout = false;
responseData.result = result;
responseData.resultShow = JSON.stringify(result, null, 4);
res.render('goods', responseData);
});
};
... ...
... ... @@ -2,7 +2,7 @@
* @Author: Targaryen
* @Date: 2016-05-19 10:20:08
* @Last Modified by: Targaryen
* @Last Modified time: 2016-05-31 18:43:03
* @Last Modified time: 2016-06-01 11:38:12
*/
'use strict';
... ... @@ -21,11 +21,39 @@ const _ = require('lodash');
*/
exports.getSaleGoodsData = (params) => {
return saleApi.getSaleGoodsList(params).then(result => {
return api.all([
saleApi.getSaleGoodsList(params),
saleApi.getUserProfile(params.uid)
]).then(result => {
let finalResult = {};
if (result.code === 200) {
finalResult.goods = productProcess.processProductList(result.data.product_list);
if (result[0].code === 200) {
finalResult.goods = productProcess.processProductList(result[0].data.product_list);
}
if (result[1].code === 200 && parseInt(params.saleType, 10) === 2) {
_.forEach(finalResult.goods, (value, key) => {
switch (result[1].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;
});
... ... @@ -35,12 +63,11 @@ exports.getSaleGoodsData = (params) => {
* 获取 Sale 首页数据 Controller 调用
* @return {[type]} [description]
*/
exports.getSaleIndexData = (params) => {
exports.getSaleIndexData = () => {
return api.all([
saleApi.getSaleActivityList(),
saleApi.getSaleBannerList('7c2b77093421efa8ae9302c91460db73'),
saleApi.getUserProfile(params.uid)
saleApi.getSaleBannerList('7c2b77093421efa8ae9302c91460db73')
]).then(result => {
var finalResult = {};
... ... @@ -53,11 +80,6 @@ exports.getSaleIndexData = (params) => {
finalResult.activityEnter = saleHandler.handleSaleBannerSmallData(result[1].data);
}
// 处理会员等级
if (result[2].code === 200) {
finalResult.vip = result[2].curLevel > 0 ? result[2].curLevel : false;
}
finalResult.saleCategory = saleHandler.handleSaleCategoryData();
return finalResult;
... ... @@ -81,8 +103,9 @@ exports.getSaleOthersData = (params) => {
promiseObject = [
saleApi.getSaleGoodsList(params),
saleApi.getSaleBannerList(cCode),
saleApi.getLeftContentList(),
saleApi.getUserProfile(params.uid)
saleApi.getLeftContentList()
// saleApi.getUserProfile(params.uid) // 不处理 VIP
];
} else {
cCode = '7c2b77093421efa8ae9302c91460db73';
... ... @@ -124,13 +147,14 @@ exports.getSaleOthersData = (params) => {
}
}
if (!_.isEmpty(params) && params.saleType === 2) {
// 不处理 VIP
// if (!_.isEmpty(params) && params.saleType === 2) {
// 获取用户数据
if (result[3].code === 200) {
finalResult.vip = result[3].curLevel > 0 ? result[3].curLevel : false;
}
}
// // 获取用户数据
// if (result[3].code === 200) {
// finalResult.vip = result[3].curLevel > 0 ? result[3].curLevel : false;
// }
// }
return finalResult;
});
... ...