Commit 77a9e36b authored by youjie's avatar youjie

叠加券优化

parent b0a96eb9
...@@ -69,6 +69,8 @@ ...@@ -69,6 +69,8 @@
value:'', value:'',
ts: [], ts: [],
stacking: 0, stacking: 0,
TotalDiscounts: 0,
money: 0,
}; };
}, },
mounted() { mounted() {
...@@ -95,6 +97,7 @@ ...@@ -95,6 +97,7 @@
} }
}) })
this.OverlayCalculation()
this.checkOrderCoupon() this.checkOrderCoupon()
}, },
methods: { methods: {
...@@ -129,7 +132,7 @@ ...@@ -129,7 +132,7 @@
}else{ }else{
this.$emit('close', -1) this.$emit('close', -1)
} }
console.log(this.currentChosen,'-----') // console.log(this.currentChosen,'-----')
}, },
// 不可叠加使用优惠券 // 不可叠加使用优惠券
radioChange(e){ radioChange(e){
...@@ -147,6 +150,7 @@ ...@@ -147,6 +150,7 @@
this.currentChosen = []; this.currentChosen = [];
this.value = 0 this.value = 0
} }
this.OverlayCalculation()
}, },
// 叠加使用优惠券 // 叠加使用优惠券
multipleChoice(e,i){ multipleChoice(e,i){
...@@ -165,6 +169,35 @@ ...@@ -165,6 +169,35 @@
let list = this.currentChosen.findIndex(x=>x==this.ts[i].id) let list = this.currentChosen.findIndex(x=>x==this.ts[i].id)
if(list==-1) this.currentChosen.push(e) if(list==-1) this.currentChosen.push(e)
} }
this.OverlayCalculation()
},
OverlayCalculation(){
if(this.currentChosen.length==0){
this.TotalDiscounts = 0
this.money = 0
this.ts.forEach(x => {
if(x.overlapUse&&x.err){
x.err = null
}
})
return
}
let alreadyStacked = this.ts.filter(x => {
return x.check
})
alreadyStacked.forEach(x => {
this.TotalDiscounts+=x.denomination
this.money = this.price-this.TotalDiscounts
})
this.ts.forEach(x => {
if(x.overlapUse){
if(!x.check&&x.denomination>this.money){
x.err = '订单金额不满足'
}else {
x.err = null
}
}
})
} }
}, },
}; };
......
...@@ -653,7 +653,7 @@ ...@@ -653,7 +653,7 @@
<view style="font-size: 12px;width:1px;flex:1">请选择优惠券</view> <view style="font-size: 12px;width:1px;flex:1">请选择优惠券</view>
<view style="display: flex;align-items: center;"> <view style="display: flex;align-items: center;">
<text style="color:#F20707;font-size: 12px;" @click="showCouponHandler"> <text style="color:#F20707;font-size: 12px;" @click="showCouponHandler">
<text style="flex: 1;" v-if="useCouponId == 0 &&couponList.length>0">{{couponList.length}}张可用优惠券</text> <text style="flex: 1;" v-if="useCouponIds == 0 &&couponList.length>0">{{couponList.length}}张可用优惠券</text>
<text class="content" style="color:grey" v-else-if="couponList.length==0">暂无优惠券</text> <text class="content" style="color:grey" v-else-if="couponList.length==0">暂无优惠券</text>
<text class="content" v-else :style="{ color: mainColor }">已优惠 {{currentCoupon.discountMoney}}</text> <text class="content" v-else :style="{ color: mainColor }">已优惠 {{currentCoupon.discountMoney}}</text>
<!-- <u-icon name="ellipsis" size="36" v-if="couponList.length > 0"></u-icon> --> <!-- <u-icon name="ellipsis" size="36" v-if="couponList.length > 0"></u-icon> -->
...@@ -667,7 +667,7 @@ ...@@ -667,7 +667,7 @@
<view class="empty-block"></view> <view class="empty-block"></view>
</template> </template>
<coupon v-if="couponList.length > 0 && showCoupon" :list="couponList" :current="useCouponId" @close="closeCouponHandler" :current-price="realCurrentPriceInfo" :order="orderMsg"></coupon> <coupon v-if="couponList.length > 0 && showCoupon" :price="price" :list="couponList" :current="useCouponIds" @close="closeCouponHandler" :current-price="realCurrentPriceInfo" :order="orderMsg"></coupon>
<view style="padding: 50rpx 40rpx" v-if="tips != ''"> <view style="padding: 50rpx 40rpx" v-if="tips != ''">
<view class="big-title"> <view class="big-title">
<text>重要提示</text> <text>重要提示</text>
...@@ -780,7 +780,7 @@ ...@@ -780,7 +780,7 @@
GuestList: [], GuestList: [],
couponList: [], couponList: [],
showCoupon: false, showCoupon: false,
useCouponId: 0, useCouponIds: [],
currentCoupon: { currentCoupon: {
discountMoney: 0 discountMoney: 0
}, },
...@@ -973,18 +973,27 @@ ...@@ -973,18 +973,27 @@
}, },
closeCouponHandler(e) { closeCouponHandler(e) {
if (e != -1) { if (e != -1) {
this.useCouponId = e; this.useCouponIds = e;
if(this.useCouponId){ //叠加使用优惠券
this.currentCoupon = this.couponList.find(x => x.id == this.useCouponId) let TotalDiscountAmount = 0
if (this.currentCoupon.couponsType == 1) { this.couponList.forEach(x=>{
this.currentCoupon.discountMoney = this.currentCoupon.denomination let findIndex = this.useCouponIds.findIndex(y=>x.id==y)
} else { if(findIndex!=-1){
this.currentCoupon.discountMoney = (parseFloat(this.price) * (1 - parseFloat(this.currentCoupon.denomination / 10))) let discountMoney = 0
.toFixed(2) if(x.couponsType==1){
} discountMoney = x.denomination
}else{ }else{
this.currentCoupon.discountMoney = 0 discountMoney = (parseFloat(this.price) * (1 - parseFloat(x.denomination / 10)))
} .toFixed(2)
}
TotalDiscountAmount += discountMoney
}
})
if(TotalDiscountAmount)this.currentCoupon.discountMoney = TotalDiscountAmount
else this.currentCoupon.discountMoney = 0
}else{
this.currentCoupon.discountMoney = 0
this.useCouponIds = []
} }
this.showCoupon = false; this.showCoupon = false;
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment