|
@@ -31,7 +31,6 @@ var shoppingCart = new Vue({
|
|
couponPrice:0, // 优惠金额
|
|
couponPrice:0, // 优惠金额
|
|
totalDiscountAmount:0, // 总共减去金额
|
|
totalDiscountAmount:0, // 总共减去金额
|
|
isDiscount:false, // 控制显示优惠明细
|
|
isDiscount:false, // 控制显示优惠明细
|
|
-
|
|
|
|
},
|
|
},
|
|
watch:{
|
|
watch:{
|
|
listData: {
|
|
listData: {
|
|
@@ -80,6 +79,7 @@ var shoppingCart = new Vue({
|
|
_self.totalPrice = data.totalPrice;
|
|
_self.totalPrice = data.totalPrice;
|
|
_self.promotionsList = data.promotions;
|
|
_self.promotionsList = data.promotions;
|
|
_self.totalCouponList = data.couponList;
|
|
_self.totalCouponList = data.couponList;
|
|
|
|
+ _self.reducedPrice = data.reducedPrice;
|
|
// 默认全选
|
|
// 默认全选
|
|
_self.listData.forEach(function(supplier){
|
|
_self.listData.forEach(function(supplier){
|
|
supplier.isChecked = true;
|
|
supplier.isChecked = true;
|
|
@@ -178,60 +178,65 @@ var shoppingCart = new Vue({
|
|
});
|
|
});
|
|
});
|
|
});
|
|
},
|
|
},
|
|
- computedPrice: function(){
|
|
|
|
|
|
+ computedPrice: function() {
|
|
var _self = this;
|
|
var _self = this;
|
|
- this.$nextTick(function(){
|
|
|
|
|
|
+ this.$nextTick(function () {
|
|
var totalPrice = 0;
|
|
var totalPrice = 0;
|
|
var reducedPrice = 0;
|
|
var reducedPrice = 0;
|
|
var originalPrice = 0;
|
|
var originalPrice = 0;
|
|
var kindCount = 0;
|
|
var kindCount = 0;
|
|
var totalCount = 0;
|
|
var totalCount = 0;
|
|
- _self.listData.forEach(function(supplier){
|
|
|
|
|
|
+ _self.listData.forEach(function (supplier) {
|
|
var supplierPrice = 0;
|
|
var supplierPrice = 0;
|
|
var supplierReducedPrice = 0;
|
|
var supplierReducedPrice = 0;
|
|
- if(supplier.cartList.length>0){
|
|
|
|
- supplier.cartList.forEach(function(cart){
|
|
|
|
- if (_self.submitIds.includes(cart.productId*1)){
|
|
|
|
- supplierPrice += cart.price*cart.number;
|
|
|
|
|
|
+ var svipSupplierPrice = 0;
|
|
|
|
+ if (supplier.cartList.length > 0) {
|
|
|
|
+ supplier.cartList.forEach(function (cart) {
|
|
|
|
+ if (_self.submitIds.includes(cart.productId * 1)) {
|
|
|
|
+ supplierPrice += cart.price * cart.number;
|
|
kindCount += 1;
|
|
kindCount += 1;
|
|
totalCount += cart.number;
|
|
totalCount += cart.number;
|
|
// 单品满减
|
|
// 单品满减
|
|
- if(cart.promotions && cart.promotions.type*1===1 && cart.promotions.mode*1===2){
|
|
|
|
|
|
+ if (cart.promotions && cart.promotions.type * 1 === 1 && cart.promotions.mode * 1 === 2) {
|
|
// 单品满减-重新计算供应商总价/满减金额
|
|
// 单品满减-重新计算供应商总价/满减金额
|
|
- if(cart.price*cart.number >= cart.promotions.touchPrice){
|
|
|
|
|
|
+ if (cart.price * cart.number >= cart.promotions.touchPrice) {
|
|
supplierPrice -= cart.promotions.reducedPrice;
|
|
supplierPrice -= cart.promotions.reducedPrice;
|
|
supplierReducedPrice += cart.promotions.reducedPrice;
|
|
supplierReducedPrice += cart.promotions.reducedPrice;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ //sivp优惠价格
|
|
|
|
+ if(cart.svipProductFlag === 1){
|
|
|
|
+ svipSupplierPrice += (cart.originalPrice - cart.svipPriceTag) * cart.number;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
});
|
|
});
|
|
// 店铺满减
|
|
// 店铺满减
|
|
- if(supplier.promotions && supplier.promotions.mode*1===2){
|
|
|
|
|
|
+ if (supplier.promotions && supplier.promotions.mode * 1 === 2) {
|
|
// 店铺满减-计算供应商总价/满减金额
|
|
// 店铺满减-计算供应商总价/满减金额
|
|
- if(supplierPrice >= supplier.promotions.touchPrice){
|
|
|
|
|
|
+ if (supplierPrice >= supplier.promotions.touchPrice) {
|
|
supplierPrice -= supplier.promotions.reducedPrice;
|
|
supplierPrice -= supplier.promotions.reducedPrice;
|
|
supplierReducedPrice += supplier.promotions.reducedPrice;
|
|
supplierReducedPrice += supplier.promotions.reducedPrice;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
supplier.totalPrice = supplierPrice;
|
|
supplier.totalPrice = supplierPrice;
|
|
- supplier.reducedPrice = supplierReducedPrice;
|
|
|
|
- supplier.originalPrice = (supplierPrice+supplierReducedPrice);
|
|
|
|
|
|
+ supplier.reducedPrice = supplierReducedPrice + svipSupplierPrice; // 其他优惠价 + svip优惠价
|
|
|
|
+ supplier.originalPrice = (supplierPrice + supplierReducedPrice);
|
|
totalPrice += supplier.totalPrice;
|
|
totalPrice += supplier.totalPrice;
|
|
reducedPrice += supplier.reducedPrice;
|
|
reducedPrice += supplier.reducedPrice;
|
|
originalPrice += supplier.originalPrice;
|
|
originalPrice += supplier.originalPrice;
|
|
});
|
|
});
|
|
// 总促销计算
|
|
// 总促销计算
|
|
- _self.promotionsList.forEach(function(promotions){
|
|
|
|
|
|
+ _self.promotionsList.forEach(function (promotions) {
|
|
// 凑单满减
|
|
// 凑单满减
|
|
- if(promotions.mode*1===2 && promotions.type*1===2){
|
|
|
|
|
|
+ if (promotions.mode * 1 === 2 && promotions.type * 1 === 2) {
|
|
var total = 0;
|
|
var total = 0;
|
|
- promotions.productList.forEach(function(product){
|
|
|
|
- if (_self.submitIds.includes(product.productId*1)){
|
|
|
|
|
|
+ promotions.productList.forEach(function (product) {
|
|
|
|
+ if (_self.submitIds.includes(product.productId * 1)) {
|
|
total += product.number * product.price;
|
|
total += product.number * product.price;
|
|
}
|
|
}
|
|
});
|
|
});
|
|
- if(total>=promotions.touchPrice){
|
|
|
|
|
|
+ if (total >= promotions.touchPrice) {
|
|
totalPrice -= promotions.reducedPrice;
|
|
totalPrice -= promotions.reducedPrice;
|
|
reducedPrice += promotions.reducedPrice;
|
|
reducedPrice += promotions.reducedPrice;
|
|
}
|
|
}
|
|
@@ -243,26 +248,26 @@ var shoppingCart = new Vue({
|
|
_self.kindCount = kindCount;
|
|
_self.kindCount = kindCount;
|
|
_self.totalCount = totalCount;
|
|
_self.totalCount = totalCount;
|
|
// 计算优惠券
|
|
// 计算优惠券
|
|
- if(_self.totalCouponList.length>0){
|
|
|
|
|
|
+ if (_self.totalCouponList.length > 0) {
|
|
let eligibleCoupons = _self.calculationCoupon();
|
|
let eligibleCoupons = _self.calculationCoupon();
|
|
- if(eligibleCoupons.length>0){
|
|
|
|
- _self.eligibleCoupons.splice(0,_self.eligibleCoupons.length);
|
|
|
|
- _self.eligibleCoupons = eligibleCoupons.sort((a,b)=> b.couponAmount - a.couponAmount)
|
|
|
|
|
|
+ if (eligibleCoupons.length > 0) {
|
|
|
|
+ _self.eligibleCoupons.splice(0, _self.eligibleCoupons.length);
|
|
|
|
+ _self.eligibleCoupons = eligibleCoupons.sort((a, b) => b.couponAmount - a.couponAmount)
|
|
_self.couponPrice = this.eligibleCoupons[0].couponAmount
|
|
_self.couponPrice = this.eligibleCoupons[0].couponAmount
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
_self.couponPrice = 0
|
|
_self.couponPrice = 0
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// 最后满减金额 = 店铺减去金额 + 单品减去金额 + 凑单减去金额
|
|
// 最后满减金额 = 店铺减去金额 + 单品减去金额 + 凑单减去金额
|
|
_self.totalDiscountAmount = _self.reducedPrice + _self.couponPrice;
|
|
_self.totalDiscountAmount = _self.reducedPrice + _self.couponPrice;
|
|
- console.log('最终优惠金额',_self.totalDiscountAmount);
|
|
|
|
|
|
+ console.log('最终优惠金额', _self.totalDiscountAmount);
|
|
// 控制显示优惠明细
|
|
// 控制显示优惠明细
|
|
- if(_self.totalDiscountAmount > 0 ){
|
|
|
|
|
|
+ if (_self.totalDiscountAmount > 0) {
|
|
_self.isDiscount = true;
|
|
_self.isDiscount = true;
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
_self.isDiscount = false;
|
|
_self.isDiscount = false;
|
|
}
|
|
}
|
|
- });
|
|
|
|
|
|
+ })
|
|
},
|
|
},
|
|
calculationCoupon:function(){// 优惠券计算
|
|
calculationCoupon:function(){// 优惠券计算
|
|
var _self = this;
|
|
var _self = this;
|
|
@@ -321,7 +326,7 @@ var shoppingCart = new Vue({
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
})
|
|
})
|
|
- })
|
|
|
|
|
|
+ });
|
|
return eligibleCoupons;
|
|
return eligibleCoupons;
|
|
},
|
|
},
|
|
cartNumberSub: function(cart){
|
|
cartNumberSub: function(cart){
|