修复购物车在更新最新后端代码的时候导致的bug

master
lemon橪 2021-12-23 18:36:00 +08:00
parent 09ec1e8c06
commit 896749d812
3 changed files with 29 additions and 18 deletions

View File

@ -303,11 +303,11 @@
<view class="spec"> <view class="spec">
<!-- 促销弹窗 --> <!-- 促销弹窗 -->
<u-popup <u-popup
v-model="promotionFlag" v-model="promotionShow"
:height="setup.height" :height="setup.height"
:mode="setup.mode" :mode="setup.mode"
:border-radius="setup.radius" :border-radius="setup.radius"
@close="promotionFlag = false" @close="promotionShow = false"
:mask-close-able="setup.close" :mask-close-able="setup.close"
closeable closeable
> >
@ -404,7 +404,8 @@ export default {
data() { data() {
return { return {
setup, setup,
promotionFlag: false, promotionShow: false, //
promotionFlag: true, //
// #ifdef H5 // #ifdef H5
navbarListX: 110, //x navbarListX: 110, //x
navbarListY: 80, //y navbarListY: 80, //y
@ -914,13 +915,13 @@ export default {
* 规格弹窗开关 * 规格弹窗开关
*/ */
shutMask(flag, buyFlag, type) { shutMask(flag, buyFlag, type) {
this.promotionFlag = false; this.promotionShow = false;
this.buyMask = false; this.buyMask = false;
this.addressFlag = false; this.addressFlag = false;
if (flag) { if (flag) {
switch (flag) { switch (flag) {
case 1: // case 1: //
this.promotionFlag = true; this.promotionShow = true;
break; break;
case 3: case 3:

View File

@ -1,5 +1,5 @@
<template> <template>
<u-popup class="popup" v-model="addressFlag" :height="setup.height" :mode="setup.mode" :border-radius="setup.radius" @close="closeAddress()" :mask-close-able="setup.close" closeable> <u-popup class="popup" v-model="addressFlag" :height="setup.height" :mode="setup.mode" :border-radius="setup.radius" @close="closeAddress()" closeable>
<view class="header-title">选择地址</view> <view class="header-title">选择地址</view>
<view class="view-box" v-if="addressDetail"> <view class="view-box" v-if="addressDetail">
<view class="view-item" v-for="(item, index) in addressDetail" :key="index" @click="clickAddress(item)"> <view class="view-item" v-for="(item, index) in addressDetail" :key="index" @click="clickAddress(item)">

View File

@ -39,9 +39,8 @@
ref="swiperAction" class="cart-item" v-for="(skuItem, i) in item.skuList" :index="i" :key="skuItem.goodsSku.id" ref="swiperAction" class="cart-item" v-for="(skuItem, i) in item.skuList" :index="i" :key="skuItem.goodsSku.id"
@click="changeActionTab(skuItem)" @longpress="changeActionTab(skuItem)"> @click="changeActionTab(skuItem)" @longpress="changeActionTab(skuItem)">
<!-- 满减活动 --> <!-- 满减活动 -->
<div v-if="skuItem.promotions" v-for="(fullDiscount,fullDiscountIndex) in skuItem.promotions" <div v-if="Object.keys(skuItem.promotionMap).length != 0">
:key="fullDiscountIndex"> <div v-if="getPromotion(skuItem).includes('FULL_DISCOUNT')">
<div v-if="fullDiscount.promotionType == 'FULL_DISCOUNT'">
<div class="promotion-notice" v-if="item.promotionNotice"> <div class="promotion-notice" v-if="item.promotionNotice">
<span class="tips">满减</span> <span class="tips">满减</span>
<span style="flex:10;">{{item.promotionNotice}}</span> <span style="flex:10;">{{item.promotionNotice}}</span>
@ -76,7 +75,7 @@
<p class="sp-type">{{skuItem.goodsSku.simpleSpecs}}</p> <p class="sp-type">{{skuItem.goodsSku.simpleSpecs}}</p>
<p class="sp-number"> <p class="sp-number">
<view class="sp-price"> <view class="sp-price">
<div class="default-color" :class="{'main-color':skuItem.promotions.length ==0 }"> <div class="default-color" :class="{'main-color':Object.keys(skuItem.promotionMap).length ==0 }">
<span>{{ formatPrice(skuItem.goodsSku.price)[0] }}</span> <span>{{ formatPrice(skuItem.goodsSku.price)[0] }}</span>
<span>.{{ formatPrice(skuItem.goodsSku.price)[1] }}</span> <span>.{{ formatPrice(skuItem.goodsSku.price)[1] }}</span>
@ -95,9 +94,9 @@
</view> </view>
<!-- 如果当有促销并且促销是 限时抢购 --> <!-- 如果当有促销并且促销是 限时抢购 -->
<!-- promotions --> <!-- promotions -->
<div class="promotions-list" v-if="skuItem.promotions" <div class="promotions-list" v-if="Object.keys(skuItem.promotionMap).length != 0"
v-for="(seckill,seckillIndex) in skuItem.promotions" :key="seckillIndex"> >
<div class="promotions-item-seckill" v-if="seckill.promotionType == 'SECKILL'"> <div class="promotions-item-seckill" v-if="getPromotion(skuItem).includes('SECKILL')">
距秒杀结束: <u-count-down show-border :hide-zero-day="true" :color="$mainColor" border-color="#ededed" 距秒杀结束: <u-count-down show-border :hide-zero-day="true" :color="$mainColor" border-color="#ededed"
font-size="24" :timestamp="getCountDownTime(seckill.endTime)"> font-size="24" :timestamp="getCountDownTime(seckill.endTime)">
</u-count-down> </u-count-down>
@ -106,7 +105,7 @@
<!-- 如果有活动 并且是选中的状态,显示预估到手价格 --> <!-- 如果有活动 并且是选中的状态,显示预估到手价格 -->
<div class="priceDetail-flowPrice" :class="{'main-color':skuItem.priceDetailDTO}" <div class="priceDetail-flowPrice" :class="{'main-color':skuItem.priceDetailDTO}"
v-if="skuItem.priceDetailDTO && skuItem.invalid == 0 && skuItem.promotions.length!=0 && skuItem.checked && skuItem.checked"> v-if="skuItem.priceDetailDTO && skuItem.invalid == 0 && Object.keys(skuItem.promotionMap).length != 0 && skuItem.checked && skuItem.checked">
预估到手价 <span>{{ formatPrice(skuItem.priceDetailDTO.flowPrice)[0]}}</span> 预估到手价 <span>{{ formatPrice(skuItem.priceDetailDTO.flowPrice)[0]}}</span>
<span>.{{ formatPrice(skuItem.priceDetailDTO.flowPrice)[1] }} </span> <span>.{{ formatPrice(skuItem.priceDetailDTO.flowPrice)[1] }} </span>
</div> </div>
@ -490,6 +489,13 @@ export default {
}); });
}, },
//
getPromotion(item) {
return Object.keys(item.promotionMap).map((child) => {
return child.split("-")[0]
});
},
/** /**
* 获取购物车数据 * 获取购物车数据
*/ */
@ -512,12 +518,16 @@ export default {
// 便 // 便
item.skuList && item.skuList &&
item.skuList.forEach((sku) => { item.skuList.forEach((sku) => {
sku.promotions && if(Object.keys(sku.promotionMap).length != 0)
sku.promotions.forEach((pro, proIndex) => { {
if (pro.promotionType == "PINTUAN") { Object.keys(sku.promotionMap).forEach((pro, proIndex) => {
sku.promotions.splice(proIndex, 1); pro = pro.split('-')[0]
if (pro == "PINTUAN" ) {
Object.keys(sku.promotionMap).splice(proIndex, 1);
} }
}); });
}
}); });
} }
uni.stopPullDownRefresh(); uni.stopPullDownRefresh();