Commit b0a87bef authored by youjie's avatar youjie

自动勾选优惠券

parent 6d8f845c
......@@ -624,11 +624,33 @@
if (res.resultCode == 1) {
this.couponList = res.data
this.calcPzCouponHandler()
this.calcMaxCouponHandle()
}
},
(err) => {}
);
},
calcMaxCouponHandle(){
if(this.couponList && this.couponList.length>0){
let maxCouponId = 0
let discount = 0
const money = this.price
this.couponList.forEach(x=>{
if(x.couponsType==1 && x.denomination>discount) {
discount=x.denomination
maxCouponId = x.id
}
if(x.couponsType==2){
let disMoney = money*(1-x.denomination)
if(discount<disMoney){
discount=disMoney
maxCouponId = x.id
}
}
})
if(maxCouponId>0) this.closeCouponHandler([maxCouponId])
}
},
usePzCouponHandler() {
this.showPz = false
this.closeCouponHandler(this.pzCoupon.id)
......
......@@ -1098,6 +1098,7 @@
console.log("coupon_post_GetUserCanUseCouponList_res", res);
this.couponList = res.data
this.calcPzCouponHandler()
this.calcMaxCouponHandle()
}
},
(err) => {
......@@ -1105,6 +1106,27 @@
}
);
},
calcMaxCouponHandle(){
if(this.couponList && this.couponList.length>0){
let maxCouponId = 0
let discount = 0
const money = this.price
this.couponList.forEach(x=>{
if(x.couponsType==1 && x.denomination>discount) {
discount=x.denomination
maxCouponId = x.id
}
if(x.couponsType==2){
let disMoney = money*(1-x.denomination)
if(discount<disMoney){
discount=disMoney
maxCouponId = x.id
}
}
})
if(maxCouponId>0) this.closeCouponHandler([maxCouponId])
}
},
usePzCouponHandler(){
this.showPz = false
this.closeCouponHandler([this.pzCoupon.id])
......
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