Authored by 陈峰

接口改版

... ... @@ -99,6 +99,9 @@ let cartObj = {
allGiftBoxClick(e) {
let cartType = window.cookie('cartType') || 'ordinary';
if ($(e.currentTarget).find('.no-storage').length) {
return;
}
if ($(e.currentTarget).hasClass('advanceBuy')) {
window.location.href = '/cart/index/new/advanceBuy?cartType=' + cartType;
} else {
... ...
... ... @@ -62,7 +62,8 @@ const formatAdvanceGoods = (advanceGood, isGift) => {
return {
promotionId: advanceGood.promotion_id,
promotionTitle: advanceGood.promotion_title,
goods: _.get(advanceGood, 'goods_list', []).map(good => {
status: advanceGood.status,
goods: _.get(advanceGood, 'gift_goods_List', []).map(good => {
return {
id: good.product_skn,
name: good.product_name,
... ... @@ -181,9 +182,6 @@ const formatPromotion = (promo) => {
status: promo.status,
conditionUnit: promo.condition_unit,
conditionValue: promo.condition_value,
giftGoodsList: _.get(promo, 'gift_goods_List', []).map(gift => {
return formatAdvanceGoods(gift);
}),
giftPrice: promo.gift_price,
promotionId: promo.promotion_id,
promotionOriginTitle: promo.promotion_title,
... ... @@ -235,15 +233,15 @@ const procCartData = (data, onlyGift = false, onlyAdvanceBuy = false, isAdvanceC
let result = {};
if (onlyGift) {
// 赠品
result.freebie = data.gift_list.map(good => {
// 全场赠品
result.freebie = data.g_gift_list.map(good => {
return formatAdvanceGoods(good, true);
});
return result;
}
if (onlyAdvanceBuy) {
// 加价购
result.advanceBuy = data.price_gift.map(good => {
// 全场加价购
result.advanceBuy = data.g_price_gift_list.map(good => {
return formatAdvanceGoods(good);
});
return result;
... ... @@ -297,29 +295,25 @@ const procCartData = (data, onlyGift = false, onlyAdvanceBuy = false, isAdvanceC
});
// 赠品和加价购商品
if (data.gift_list.length || data.price_gift.length) {
if (_.get(data, 'g_gift_list', []).length || _.get(data, 'g_price_gift_list', []).length) {
result.freebieOrAdvanceBuy = true;
// 赠品
result.freebie = data.gift_list.map(good => {
return formatAdvanceGoods(good);
result.freebie = data.g_gift_list.filter(freebie => {
return freebie.status !== 30 || freebie.status !== 0;
});
result.giftCount = result.freebie.length;
result.giftHasStorage = _.some(result.freebie, freebie => {
return _.some(freebie.goods, good => {
return good.count > 0;
});
return freebie.status === 10;
});
// 加价购
result.advanceBuy = data.price_gift.map(good => {
return formatAdvanceGoods(good);
result.advanceBuy = data.g_price_gift_list.filter(advanceBuy => {
return advanceBuy.status !== 30 || advanceBuy.status !== 0;
});
result.advanceBuyCount = result.advanceBuy.length;
result.advanceHasStorage = _.some(result.advanceBuy, advanceBuy => {
return _.some(advanceBuy.goods, good => {
return good.count > 0;
});
return advanceBuy.status === 10;
});
}
... ...