|
@@ -265,45 +265,32 @@ var shoppingCart = new Vue({
|
|
|
shop.cartList.forEach(function(pros){
|
|
|
if(_self.submitIds.includes(pros.productId*1)){
|
|
|
_self.totalCouponList.map(function (coupon,index){//循环优惠券
|
|
|
- var couponType = coupon.couponType;
|
|
|
- if(couponType == 0){// 活动券
|
|
|
- if(coupon.productType == 1){// 活动券-全商城商品
|
|
|
- if(_self.totalPrice>=coupon.touchPrice){
|
|
|
- eligibleCoupons.push(coupon)
|
|
|
- eligibleCoupons.sort((a,b)=> b.couponAmount - a.couponAmount )
|
|
|
- }
|
|
|
- }else if(coupon.productType == 2){// 活动券-指定商品
|
|
|
- if(coupon.productIds && coupon.productIds.includes(pros.productId)){
|
|
|
- if(_self.totalPrice>=coupon.touchPrice){
|
|
|
- eligibleCoupons.push(coupon)
|
|
|
- eligibleCoupons.sort((a,b)=> b.couponAmount - a.couponAmount )
|
|
|
+ switch(coupon.couponType){
|
|
|
+ case 0:// 活动券
|
|
|
+ if(coupon.productType == 1){// 活动券-全商城商品
|
|
|
+ eligibleCoupons = _self.setCouponsArr(coupon)
|
|
|
+ }else if(coupon.productType == 2){// 活动券-指定商品
|
|
|
+ if(coupon.productIds && coupon.productIds.includes(pros.productId)){
|
|
|
+ eligibleCoupons = _self.setCouponsArr(coupon)
|
|
|
}
|
|
|
- }else{
|
|
|
- return false
|
|
|
}
|
|
|
- }
|
|
|
- // 品类券适用于产品或者仪器,购买产品类或仪器类的商品,商品金额达到优惠标准即可使用优惠券
|
|
|
- }else if(couponType == 1){// 品类券 categoryType(commodityType) : 1 产品 2 仪器
|
|
|
- if( coupon.categoryType && coupon.categoryType == pros.commodityType){
|
|
|
- if(_self.totalPrice>=coupon.touchPrice){
|
|
|
- eligibleCoupons.push(coupon)
|
|
|
- eligibleCoupons.sort((a,b)=> b.couponAmount - a.couponAmount )
|
|
|
+ break;
|
|
|
+ case 1:// 品类券适用于产品或者仪器 categoryType(commodityType) : 1 产品 2 仪器
|
|
|
+ if( coupon.categoryType && coupon.categoryType == pros.commodityType){
|
|
|
+ eligibleCoupons = _self.setCouponsArr(coupon)
|
|
|
}
|
|
|
- }
|
|
|
- // 适用于商城全部商品
|
|
|
- }else if(couponType == 2 || couponType == 4){// 用户专享券和新用户券
|
|
|
- if(_self.totalPrice>=coupon.touchPrice){
|
|
|
- eligibleCoupons.push(coupon)
|
|
|
- eligibleCoupons.sort((a,b)=> b.couponAmount - a.couponAmount )
|
|
|
- }
|
|
|
- // 店铺券适用于某个供应商的全部商品
|
|
|
- }else if(couponType == 3){// 店铺券 supplierId
|
|
|
- if(coupon.shopId && pros.supplierId == coupon.shopId){
|
|
|
- if(_self.totalPrice>=coupon.touchPrice){
|
|
|
- eligibleCoupons.push(coupon)
|
|
|
- eligibleCoupons.sort((a,b)=> b.couponAmount - a.couponAmount )
|
|
|
+ break;
|
|
|
+ case 2:// 用户专享券 适用于商城全部商品
|
|
|
+ eligibleCoupons = _self.setCouponsArr(coupon)
|
|
|
+ break;
|
|
|
+ case 3:// 店铺券适用于某个供应商的全部商品
|
|
|
+ if(coupon.shopId && pros.supplierId == coupon.shopId){
|
|
|
+ eligibleCoupons = _self.setCouponsArr(coupon)
|
|
|
}
|
|
|
- }
|
|
|
+ break;
|
|
|
+ case 4://新用户券 适用于商城全部商品
|
|
|
+ eligibleCoupons = _self.setCouponsArr(coupon)
|
|
|
+ break;
|
|
|
}
|
|
|
})
|
|
|
}else{
|
|
@@ -318,6 +305,17 @@ var shoppingCart = new Vue({
|
|
|
_self.couponPrice = 0
|
|
|
}
|
|
|
},
|
|
|
+ setCouponsArr: function(coupon){
|
|
|
+ var _self = this;
|
|
|
+ const list = []
|
|
|
+ if(_self.totalPrice >= coupon.touchPrice){
|
|
|
+ list.push(coupon)
|
|
|
+ list.sort((a,b)=> b.couponAmount - a.couponAmount )
|
|
|
+ return list
|
|
|
+ }else{
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ },
|
|
|
cartNumberSub: function(cart){
|
|
|
cart.number -= cart.step;
|
|
|
if (cart.number<cart.min){
|