...
|
...
|
@@ -975,6 +975,72 @@ const _getCommonConsult = () => { |
|
|
});
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 获取秒杀列表
|
|
|
*/
|
|
|
const getSeckillData = (productSkn) => {
|
|
|
let params = {
|
|
|
method: 'app.seckill.data',
|
|
|
product_skn: productSkn
|
|
|
};
|
|
|
|
|
|
return api.get('', params, {
|
|
|
code: 200
|
|
|
}).then(result => {
|
|
|
let data = {};
|
|
|
|
|
|
if (result.data) {
|
|
|
data = result.data;
|
|
|
}
|
|
|
|
|
|
data = {
|
|
|
activityId: 4,
|
|
|
startTime: 1465194254,
|
|
|
endTime: 1475294254,
|
|
|
formatSecKillPrice: '¥133.00',
|
|
|
id: 4,
|
|
|
orderBy: 0,
|
|
|
productSkn: 512581470,
|
|
|
secKillPrice: 50,
|
|
|
secKillSku: [
|
|
|
{
|
|
|
activityId: 4,
|
|
|
id: 1,
|
|
|
productSkn: 512581470,
|
|
|
productSku: 1381111,
|
|
|
storageNum: 1
|
|
|
},
|
|
|
{
|
|
|
activityId: 4,
|
|
|
id: 2,
|
|
|
productSkn: 512581470,
|
|
|
productSku: 1382222,
|
|
|
storageNum: 2
|
|
|
},
|
|
|
{
|
|
|
activityId: 4,
|
|
|
id: 2,
|
|
|
productSkn: 512581470,
|
|
|
productSku: 1383333,
|
|
|
storageNum: 3
|
|
|
},
|
|
|
{
|
|
|
activityId: 4,
|
|
|
id: 2,
|
|
|
productSkn: 512581470,
|
|
|
productSku: 1384444,
|
|
|
storageNum: 0
|
|
|
}
|
|
|
],
|
|
|
secKillStatus: 0,
|
|
|
status: 2,
|
|
|
storageSum: 0
|
|
|
};
|
|
|
|
|
|
return data;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
let getProductData = (data) => {
|
|
|
let finalResult;
|
|
|
let params = {
|
...
|
...
|
@@ -996,6 +1062,7 @@ let getProductData = (data) => { |
|
|
}
|
|
|
|
|
|
return _getUserProfile(params.uid).then((user) => {
|
|
|
|
|
|
data.vipLevel = (user.data && user.data.vip_info && user.data.vip_info.cur_level) || '0';
|
|
|
data.isStudent = (user.data && user.data.vip_info && user.data.vip_info.is_student) ? true : false;
|
|
|
params.is_student = data.isStudent ? 1 : 0;
|
...
|
...
|
@@ -1015,8 +1082,50 @@ let getProductData = (data) => { |
|
|
productId: result.productId
|
|
|
}),
|
|
|
_getCommonConsult(),
|
|
|
comment.getConsults(result.productId, 1, 2)
|
|
|
comment.getConsults(result.productId, 1, 2),
|
|
|
getSeckillData(result.productSkn)
|
|
|
]).then((info) => {
|
|
|
|
|
|
// 根据app.product.data接口是否返回isSecKill,判断是否是秒杀
|
|
|
// let isSecKills = result.isSecKill === 'Y' ? true : false;
|
|
|
let isSecKills = true;// TODO
|
|
|
|
|
|
let gList = result.goodsList;
|
|
|
|
|
|
// 统计非秒杀库存数
|
|
|
let commonNum = 0;
|
|
|
|
|
|
gList.forEach(row => {
|
|
|
row.sizeList.forEach(val => {
|
|
|
commonNum = commonNum + val.storageNumber;
|
|
|
});
|
|
|
});
|
|
|
|
|
|
// 统计秒杀库存数
|
|
|
let leftCount = 0;
|
|
|
|
|
|
info[5].secKillSku.forEach(val => {
|
|
|
leftCount = leftCount + val.storageNum;
|
|
|
});
|
|
|
|
|
|
// 如果秒杀库存不为0,将商品库存链接至秒杀库存
|
|
|
let i = 0;
|
|
|
|
|
|
if (isSecKills && info[5] && leftCount) {
|
|
|
gList.forEach(row => {
|
|
|
row.sizeList.forEach(val => {
|
|
|
val.storageNumber = info[5].secKillSku[i].storageNum;
|
|
|
val.productSku = info[5].secKillSku[i].productSku;
|
|
|
i++;
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 秒杀详情页弹出层价格
|
|
|
if (isSecKills && leftCount && info[5]) {
|
|
|
result.formatMarketPrice = info[5].formatSecKillPrice;
|
|
|
}
|
|
|
|
|
|
result.promotionBoList = info[1];
|
|
|
finalResult = _detailDataPkg(result, data.uid, data.vipLevel, data.ua);
|
|
|
finalResult.enterStore = info[0];
|
...
|
...
|
@@ -1024,7 +1133,35 @@ let getProductData = (data) => { |
|
|
|
|
|
Object.assign(finalResult.feedbacks, info[2]);
|
|
|
|
|
|
/* 如果有咨询,显示咨询,否则显示常见问题 */
|
|
|
// 秒杀详情页
|
|
|
|
|
|
if (isSecKills && leftCount && info[5]) {
|
|
|
|
|
|
let end = info[5].status === 3 ? true : false;
|
|
|
|
|
|
if (!end) {
|
|
|
|
|
|
let notStart = info[5].status === 1 ? true : false;
|
|
|
|
|
|
let startIng = info[5].status === 2 ? true : false;
|
|
|
|
|
|
Object.assign(finalResult, {
|
|
|
isSecKill: {
|
|
|
notStart: notStart,
|
|
|
startIng: startIng,
|
|
|
end: end,
|
|
|
productSkn: data.productSkn,
|
|
|
secKillPrice: info[5].formatSecKillPrice,
|
|
|
noneLeft: leftCount === 0 && commonNum === 0 ? true : false
|
|
|
}
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/* 如果有咨询,显示咨询,否则显示常见问题 */
|
|
|
|
|
|
if (info[4].total) {
|
|
|
finalResult.feedbacks.consultsNum = parseInt(info[4].total, 10);
|
|
|
|
...
|
...
|
@@ -1040,6 +1177,7 @@ let getProductData = (data) => { |
|
|
consults: _.take(info[3], 2)
|
|
|
});
|
|
|
}
|
|
|
|
|
|
return finalResult;
|
|
|
});
|
|
|
|
...
|
...
|
@@ -1049,5 +1187,6 @@ let getProductData = (data) => { |
|
|
|
|
|
module.exports = {
|
|
|
getProductData,
|
|
|
getUserProfile: _getUserProfile
|
|
|
getUserProfile: _getUserProfile,
|
|
|
getSeckillData
|
|
|
}; |
...
|
...
|
|