|
@@ -244,7 +244,14 @@ var shoppingCart = new Vue({
|
|
|
_self.totalCount = totalCount;
|
|
|
// 计算优惠券
|
|
|
if(_self.totalCouponList.length>0){
|
|
|
- _self.calculationCoupon();
|
|
|
+ let eligibleCoupons = _self.calculationCoupon();
|
|
|
+ if(eligibleCoupons.length>0){
|
|
|
+ _self.eligibleCoupons.splice(0,_self.eligibleCoupons.length);
|
|
|
+ _self.eligibleCoupons.push(eligibleCoupons[0])
|
|
|
+ _self.couponPrice = _self.eligibleCoupons.sort((a,b)=> b.couponAmount - a.couponAmount)[0].couponAmount
|
|
|
+ }else{
|
|
|
+ _self.couponPrice = 0
|
|
|
+ }
|
|
|
}
|
|
|
// 最后满减金额 = 店铺减去金额 + 单品减去金额 + 凑单减去金额
|
|
|
_self.totalDiscountAmount = _self.reducedPrice + _self.couponPrice;
|
|
@@ -256,7 +263,6 @@ var shoppingCart = new Vue({
|
|
|
_self.isDiscount = false;
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
},
|
|
|
calculationCoupon:function(){// 优惠券计算
|
|
|
var _self = this;
|
|
@@ -310,13 +316,7 @@ var shoppingCart = new Vue({
|
|
|
}
|
|
|
})
|
|
|
})
|
|
|
- if(eligibleCoupons.length>0){
|
|
|
- _self.eligibleCoupons.splice(0,_self.eligibleCoupons.length);
|
|
|
- _self.eligibleCoupons.push(eligibleCoupons[0])
|
|
|
- _self.couponPrice = _self.eligibleCoupons.sort((a,b)=> b.couponAmount - a.couponAmount)[0].couponAmount
|
|
|
- }else{
|
|
|
- _self.couponPrice = 0
|
|
|
- }
|
|
|
+ return eligibleCoupons;
|
|
|
},
|
|
|
setCouponsArr: function(coupon){//处理
|
|
|
var list = [];
|