Parcourir la source

commit -m 优惠券测试修复

zhengjinyi il y a 3 ans
Parent
commit
1ac6380419

+ 0 - 1
components/cm-module/cart-components/index.vue

@@ -701,7 +701,6 @@
 				// 计算优惠券
 				if(this.totalCouponList.length>0){
 					let eligibleCoupons = this.calculationCoupon()
-					console.log('eligibleCoupons',eligibleCoupons)
 					if(eligibleCoupons.length>0){
 						this.eligibleCoupons.splice(0,this.eligibleCoupons.length);
 						this.eligibleCoupons.push(eligibleCoupons[0])

+ 8 - 2
components/cm-module/creatOrder/coupon.vue

@@ -112,8 +112,14 @@
 		created(){
 			this.initData(this.couponList)
 		},
-		computed: {
-
+		watch: {
+			couponList: {
+				handler: function (el) {//监听对象的变换使用 function,箭头函数容易出现this指向不正确
+					console.log(el)
+					this.couponList = el
+				},
+				deep: true
+			}
 		},
 		methods:{
 			initData(data){

+ 1 - 0
components/cm-module/creatOrder/exchangeCoupon.vue

@@ -66,6 +66,7 @@
 					this.$parent.ExchangeCouponData = response.data
 					this.$parent.isExchangePopup = false
 					this.$parent.isCouponModel = true
+					this.$parent.isCouponShow = false
 				})
 				.catch(error =>{
 					this.$util.msg(error.msg,2000);

+ 1 - 0
components/cm-module/creatOrder/sellerExchangeCoupon.vue

@@ -66,6 +66,7 @@
 					this.$parent.ExchangeCouponData = response.data
 					this.$parent.isExchangePopup = false
 					this.$parent.isCouponModel = true
+					this.$parent.isCouponShow = false
 				})
 				.catch(error =>{
 					this.$util.msg(error.msg,2000);

+ 21 - 12
pages/seller/order/create-order.vue

@@ -296,9 +296,11 @@
 						this.isFreight = true
 						this.freightData = response.data
 						if(response.data.freePostFlag== 1){
-							this.payAllPrice = this.allPrice+response.data.freight
+							this.payAllPrice = this.allPrice + response.data.freight
+							this.attributePallPrice()
 						}else{
 							this.payAllPrice = this.allPrice
+							this.attributePallPrice()
 						}
 					})
 				})
@@ -328,7 +330,7 @@
 			handleChoiceaFreightData(data){//获取运费信息
 				if(data.freePostFlag == '1'){
 					this.freightData = data
-					this.payAllPrice = this.allPrice+parseInt(data.freight)
+					this.payAllPrice = this.allPrice + parseInt(data.freight)
 					this.attributePallPrice()
 				}else{
 					this.freightData = data
@@ -355,16 +357,19 @@
 					}else{
 						this.balanceDeductionFlag = 2
 						if(this.freightData.freePostFlag == 1 || this.freightData.freePostFlag == '1'){
-							this.payAllPrice = this.allPrice+parseInt(this.freightData.freight)
+							this.payAllPrice = this.allPrice+parseInt(this.freightData.freight) - this.couponAmount
 						}else{
-							this.payAllPrice = this.allPrice
+							this.payAllPrice = this.allPrice - this.couponAmount
 						}
 					}
+					console.log('最终订单支付金额',this.payAllPrice)
+					console.log('优惠券金额',this.couponAmount)
 				}else{
 					return
 				}
 			},	
 			attributePallPrice(){//计算价格
+				console.log('运费',this.freightData.freight)
 				if(this.freightData.freePostFlag == 1 || this.freightData.freePostFlag == '1'){
 					this.attributeHashfreight(this.freightData.freight)
 				}else{
@@ -375,36 +380,40 @@
 				if(this.ischecked){
 					if(this.userMoney>this.payAllPrice){
 						this.payAllPrice = 0.00
-						this.deductMoney = this.allPrice							//勾选后使用抵余额
-						this.surplusMoney = this.userMoney - this.deductMoney	    //勾选后的剩余抵扣
+						this.deductMoney = this.allPrice - this.couponAmount		// 勾选后使用抵余额
+						this.surplusMoney = this.userMoney - this.deductMoney	    // 勾选后的剩余抵扣
 					}else{
 						this.payAllPrice = this.allPrice - this.userMoney - this.couponAmount       	//勾选后的总价
-						this.deductMoney = this.userMoney				            //勾选后使用抵余额
-						this.surplusMoney = this.userMoney - this.deductMoney	    //勾选后的剩余抵扣
+						this.deductMoney = this.userMoney				            // 勾选后使用抵余额
+						this.surplusMoney = this.userMoney - this.deductMoney	    // 勾选后的剩余抵扣
 					}
 				}else{
 					this.payAllPrice = this.allPrice  - this.couponAmount;
 					this.deductMoney = 0.00;
 					this.surplusMoney = this.userMoney;
 				}
+				console.log('最终订单支付金额',this.payAllPrice)
+				console.log('优惠券金额',this.couponAmount)
 			},
 			attributeHashfreight(freight){//计算需要邮费的支付价格
-				this.payAllPrice = this.allPrice+parseInt(freight)//计算不包邮的价格 总价等于商品价格+邮费
+				this.payAllPrice = this.allPrice + parseInt(freight) - this.couponAmount//计算不包邮的价格 总价等于商品价格+邮费
 				if(this.ischecked){
 					if(this.userMoney>this.payAllPrice){							//余额大于支付金额
 						this.payAllPrice =0.00
-						this.deductMoney = this.allPrice+parseInt(freight)			//勾选后使用抵余额
+						this.deductMoney = this.allPrice + parseInt(freight) - this.couponAmount			//勾选后使用抵余额
 						this.surplusMoney = this.userMoney - this.deductMoney	    //勾选后的剩余抵扣
 					}else{
-						this.payAllPrice = this.allPrice+parseInt(freight) - this.userMoney  - this.couponAmount       	//勾选后的总价
+						this.payAllPrice = this.allPrice + parseInt(freight) - this.userMoney  - this.couponAmount       	//勾选后的总价
 						this.deductMoney = this.userMoney				            //勾选后使用抵余额
 						this.surplusMoney = this.userMoney - this.deductMoney	    //勾选后的剩余抵扣
 					}
 				}else{
-					this.payAllPrice = this.allPrice+parseInt(freight) - this.couponAmount
+					this.payAllPrice = this.allPrice + parseInt(freight) - this.couponAmount
 					this.deductMoney = 0.00
 					this.surplusMoney = this.userMoney
 				}
+				console.log('最终订单支付金额',this.payAllPrice)
+				console.log('优惠券金额',this.couponAmount)
 			},
 			orderSubmitMit(){//提交订单
 				if(this.addressID == ''){

+ 3 - 3
pages/user/order/create-order.vue

@@ -317,7 +317,7 @@
 						if(this.ischecked){
 							if(this.userMoney>=this.payAllPrice){
 								this.payAllPrice = 0.00
-								this.deductMoney = this.allPrice							// 当前使用金额等于订单金额
+								this.deductMoney = this.allPrice - this.couponAmount		// 当前使用金额等于订单金额
 								this.surplusMoney = this.userMoney - this.deductMoney	    // 剩余金额等于余额-当前使用金额
 							}else{
 								this.payAllPrice = this.allPrice - this.userMoney - this.couponAmount       	// 订单最终支付金额等于订单金额-账户余额
@@ -396,7 +396,7 @@
 				console.log('优惠券金额',this.couponAmount)
 			},
 			attributeHashfreight(freight){// 计算需要邮费的支付价格
-				this.payAllPrice = this.allPrice - this.couponAmount + parseInt(freight) // 计算不包邮的价格 总价等于商品价格+邮费
+				this.payAllPrice = this.allPrice + parseInt(freight) - this.couponAmount // 计算不包邮的价格 总价等于商品价格+邮费
 				if(this.ischecked){
 					if(this.userMoney>=this.payAllPrice){// 全部抵扣
 						this.payAllPrice =0.00
@@ -419,7 +419,7 @@
 						}
 					}
 				}else{
-					this.payAllPrice = this.allPrice+parseInt(freight) - this.couponAmount
+					this.payAllPrice = this.allPrice + parseInt(freight) - this.couponAmount
 					this.deductMoney = 0.00 // 当前使用金额
 					this.surplusMoney = this.userMoney // 剩余余额
 				}