优惠券完成

This commit is contained in:
2020-08-22 16:45:26 +08:00
parent 92771d8174
commit 52e6489a2c
4 changed files with 44 additions and 11 deletions

View File

@@ -70,13 +70,13 @@
<scroll-view class="coupon-choose" scroll-y style="height: 50vh;" v-if="this.couponType.type == 1">
<view class="title">优惠券详情</view>
<view class="text">平台优惠券</view>
<Coupon :couponInfo="coupon" @use="useCoupon($event)" :goodsClass="goodsClass" v-for="(coupon, index) in orderInfo.store_voucher_all_list" :key="index"></Coupon>
<Coupon :couponInfo="coupon" @use="useCoupon($event)" :goodsClass="goodsClass" v-for="(coupon, index) in orderInfo.store_voucher_all_list" :key="index" :type="true" :sel="coupon.sel"></Coupon>
<u-empty text="无可用优惠券" mode="coupon" v-if="!orderInfo.store_voucher_all_list.length" style="height: 200rpx"></u-empty>
</scroll-view>
<scroll-view class="coupon-choose" scroll-y style="height: 50vh;" v-if="this.couponType.type == 2">
<view class="title">优惠券详情</view>
<view class="text">店铺优惠券</view>
<Coupon :couponInfo="coupon" @use="useCoupon($event)" :goodsClass="goodsClass" v-for="(coupon, index) in orderInfo.store_voucher_list[this.couponType.store_id]" :key="index"></Coupon>
<Coupon :couponInfo="coupon" @use="useCoupon($event)" :goodsClass="goodsClass" v-for="(coupon, index) in orderInfo.store_voucher_list[this.couponType.store_id]" :key="index" :type="true" :sel="coupon.sel"></Coupon>
<u-empty text="无可用优惠券" mode="coupon" v-if="!orderInfo.store_voucher_list[this.couponType.store_id].length" style="height: 200rpx"></u-empty>
</scroll-view>
</u-popup>
@@ -282,15 +282,42 @@ export default {
this.couponStatus = true;
},
useCoupon(coupon) {
if(this.couponType.type == 1) this.choiceCoupon = coupon;
console.log(coupon)
if(this.couponType.type == 1){
this.choiceCoupon = {}
for(let i in this.orderInfo.store_voucher_all_list){
if(this.orderInfo.store_voucher_all_list[i].voucher_id == coupon.voucher_id && !this.orderInfo.store_voucher_all_list[i].sel){
this.orderInfo.store_voucher_all_list[i].sel = true
this.choiceCoupon = coupon;
}else{
this.orderInfo.store_voucher_all_list[i].sel = false
}
}
this.$forceUpdate()
}
if(this.couponType.type == 2) {
Object.assign(this.storeCoupon, {
[this.couponType.store_id]: coupon
})
this.storeCoupon = {}
for(let i in this.orderInfo.store_voucher_list[this.couponType.store_id]){
console.log(this.orderInfo.store_voucher_list[this.couponType.store_id][i])
if(this.orderInfo.store_voucher_list[this.couponType.store_id][i].voucher_id == coupon.voucher_id && !this.orderInfo.store_voucher_list[this.couponType.store_id][i].sel){
this.orderInfo.store_voucher_list[this.couponType.store_id][i].sel = true
Object.assign(this.storeCoupon, {
[this.couponType.store_id]: coupon
})
}else{
this.orderInfo.store_voucher_list[this.couponType.store_id][i].sel = false
}
}
this.$forceUpdate()
}
// console.log(this.choiceCoupon);
// console.log(this.storeCoupon);
this.couponStatus = false;
// this.couponStatus = false;
this.setTotalPrice(); // 计算总价
},
getFreight() {