shish 6 лет назад
Родитель
Сommit
1f5599b7d7
2 измененных файлов с 30 добавлено и 15 удалено
  1. 24 10
      mall/src/components/app-coupon-sel.vue
  2. 6 5
      mall/src/pages/order/buy.vue

+ 24 - 10
mall/src/components/app-coupon-sel.vue

@@ -28,7 +28,6 @@
               @click="couponChange(item, index + 1)"
             >
               <div class="list-img">
-                <!-- 已过期 -->
                 <template v-if="couponSelInx && couponSelInx == (index + 1)">
                   <img :src="`${constant.imgUrl}/retail/coupon/is-check.png`" alt mode="widthFix" />
                 </template>
@@ -36,7 +35,6 @@
                   <img :src="`${constant.imgUrl}/retail/coupon/no-check.png`" alt mode="widthFix" />
                 </template>
               </div>
-              <!-- 列表 -->
               <div class="list-det">
                 <div class="list-det-left">
                   <div class="price-wrap">
@@ -90,6 +88,11 @@ export default {
         newArr.push("member");
         this.selIndex = 1;
         this.memberCheck = true;
+
+        this.$emit("calcDiscount", {
+          memberDiscount: this.data.member.discount,
+          couponDiscountAmount: 0
+        });
       }
       if (!this.$util.isEmpty(this.data.coupon)) {
         newArr.push("coupon");
@@ -108,23 +111,34 @@ export default {
       return arr;
     },
     checkChange(e) {
-      console.log("切换radio");
-      this.$emit("calcDiscount", {
-        memberDiscount: 0.8,
-        couponDiscountAmount: 0
-      });
-
       this.selIndex = e.detail.value;
+
       if (this.selIndex == 1) {
+        this.$emit("calcDiscount", {
+          memberDiscount: this.data.member.discount,
+          couponDiscountAmount: 0
+        });
+        this.couponSelInx = null
         this.couponId = 0;
       }
-      this.$emit("checkChange");
+
+      if (this.selIndex == 2) {
+        this.$emit("calcDiscount", {
+          memberDiscount: 1,
+          couponDiscountAmount: 0
+        });
+      }
     },
     // 优惠券选择
     couponChange(item, index) {
       this.couponSelInx = this.couponSelInx == index ? null : index;
       this.couponId = item.id;
-      this.$emit("couponChange");
+
+      this.$emit("calcDiscount", {
+        memberDiscount: 1,
+        couponDiscountAmount: item.amount
+      });
+
     }
   }
 };

+ 6 - 5
mall/src/pages/order/buy.vue

@@ -160,7 +160,7 @@ export default {
     ...mapGetters({ orderShop: "getOrderShop" }),
     ...mapGetters({ shopUser: "getShopUser" }),
     mayPayAmount:function(){
-      let price = (this.goodsInfo.price * this.goodsInfo.buyNum + this.freightPrice)/this.memberDiscount + this.couponDiscountAmount;
+      let price = (this.goodsInfo.price * this.goodsInfo.buyNum + this.freightPrice)*this.memberDiscount - this.couponDiscountAmount;
       return price.toFixed(2);
     }
   },
@@ -168,7 +168,7 @@ export default {
     //运费变化则总金额和应付金额变化
     freightPrice(newVal) {
       let price = this.goodsInfo.price * this.goodsInfo.buyNum + newVal;
-      this.totalPrice = price.toFixed(2);
+      this.totalPrice = price.toFixed(1);
     }
   },
   onLoad(option) {
@@ -196,16 +196,17 @@ export default {
       this.goodsInfo = goodsInfo;
 
       this.totalPrice = goodsInfo.price * this.option.goodsNum;
-      //this.mayPayAmount = this.totalPrice;
 
       // 初始化上个页面带入的值
       Object.keys(this.form).forEach((i, index) => {
         this.form[i] = this.option[i];
       });
+
     },
+    //最终会员优惠的折扣和优惠券优惠金额
     calcDiscount(discountData) {
-      console.log("执行了方法");
-      this.memberDiscount = 0.8
+      this.memberDiscount = discountData.memberDiscount
+      this.couponDiscountAmount = discountData.couponDiscountAmount
     },
     // 生成订单
     createOrderFn() {