Commit 77a9e36b authored by youjie's avatar youjie

叠加券优化

parent b0a96eb9
......@@ -69,6 +69,8 @@
value:'',
ts: [],
stacking: 0,
TotalDiscounts: 0,
money: 0,
};
},
mounted() {
......@@ -95,6 +97,7 @@
}
})
this.OverlayCalculation()
this.checkOrderCoupon()
},
methods: {
......@@ -129,7 +132,7 @@
}else{
this.$emit('close', -1)
}
console.log(this.currentChosen,'-----')
// console.log(this.currentChosen,'-----')
},
// 不可叠加使用优惠券
radioChange(e){
......@@ -147,6 +150,7 @@
this.currentChosen = [];
this.value = 0
}
this.OverlayCalculation()
},
// 叠加使用优惠券
multipleChoice(e,i){
......@@ -165,6 +169,35 @@
let list = this.currentChosen.findIndex(x=>x==this.ts[i].id)
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 @@
<view style="font-size: 12px;width:1px;flex:1">请选择优惠券</view>
<view style="display: flex;align-items: center;">
<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" v-else :style="{ color: mainColor }">已优惠 {{currentCoupon.discountMoney}}</text>
<!-- <u-icon name="ellipsis" size="36" v-if="couponList.length > 0"></u-icon> -->
......@@ -667,7 +667,7 @@
<view class="empty-block"></view>
</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 class="big-title">
<text>重要提示</text>
......@@ -780,7 +780,7 @@
GuestList: [],
couponList: [],
showCoupon: false,
useCouponId: 0,
useCouponIds: [],
currentCoupon: {
discountMoney: 0
},
......@@ -973,18 +973,27 @@
},
closeCouponHandler(e) {
if (e != -1) {
this.useCouponId = e;
if(this.useCouponId){
this.currentCoupon = this.couponList.find(x => x.id == this.useCouponId)
if (this.currentCoupon.couponsType == 1) {
this.currentCoupon.discountMoney = this.currentCoupon.denomination
} else {
this.currentCoupon.discountMoney = (parseFloat(this.price) * (1 - parseFloat(this.currentCoupon.denomination / 10)))
.toFixed(2)
}
}else{
this.currentCoupon.discountMoney = 0
}
this.useCouponIds = e;
//叠加使用优惠券
let TotalDiscountAmount = 0
this.couponList.forEach(x=>{
let findIndex = this.useCouponIds.findIndex(y=>x.id==y)
if(findIndex!=-1){
let discountMoney = 0
if(x.couponsType==1){
discountMoney = x.denomination
}else{
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;
},
......
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