Commit 7c40d20a by zhangzhen

代码优化

parent fafe41f3
...@@ -1085,25 +1085,11 @@ ...@@ -1085,25 +1085,11 @@
}).then(res => { }).then(res => {
if (res.data.code == 200) { if (res.data.code == 200) {
if (res.data && res.data.data.length) { if (res.data && res.data.data.length) {
this.couponList = res.data.data; this.useCouponList = res.data.data ;
let list = res.data.data.filter(item => item.isAvailable === 0) let i = this.useCouponList.findIndex(item => item.isAvailable ===0)
this.selectCouponIndex = i>=0? i: -1;
if (list.length) { }else{
this.selectCouponIndex = -1;
list = list.map(item => {
return {
...item,
subPrice: item.subPrice || 0
}
})
list.sort((a, b) => b.subPrice - a.subPrice)
this.useCouponList = list;
let i = this.useCouponList.findIndex(item => item.duration == this.duration)
this.selectCouponIndex = i >= 0 ? i : 0
} else {
this.useCouponList = list;
this.selectCouponIndex = -1
}
} }
this.onComputePrice(); this.onComputePrice();
} else if (res.data.code == 401) { } else if (res.data.code == 401) {
......
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