shish 6 anni fa
parent
commit
6b9aae1855
2 ha cambiato i file con 23 aggiunte e 5 eliminazioni
  1. 6 0
      mall/src/components/app-coupon-sel.vue
  2. 17 5
      mall/src/pages/order/buy.vue

+ 6 - 0
mall/src/components/app-coupon-sel.vue

@@ -108,6 +108,12 @@ export default {
       return arr;
       return arr;
     },
     },
     checkChange(e) {
     checkChange(e) {
+      console.log("切换radio");
+      this.$emit("calcDiscount", {
+        memberDiscount: 0.8,
+        couponDiscountAmount: 0
+      });
+
       this.selIndex = e.detail.value;
       this.selIndex = e.detail.value;
       if (this.selIndex == 1) {
       if (this.selIndex == 1) {
         this.couponId = 0;
         this.couponId = 0;

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

@@ -56,7 +56,11 @@
       <div class="module-com discount-wrap" v-if="!$util.isEmpty(discountArr)">
       <div class="module-com discount-wrap" v-if="!$util.isEmpty(discountArr)">
         <div class="module-tit">可选优惠</div>
         <div class="module-tit">可选优惠</div>
         <div class="module-det">
         <div class="module-det">
-          <app-coupon-sel ref="couponSel" :price="totalPrice" :discountArr="['member', 'coupon']" />
+          <app-coupon-sel
+            ref="couponSel"
+            @calcDiscount="calcDiscount"
+            :discountArr="['member', 'coupon']"
+          />
         </div>
         </div>
       </div>
       </div>
       <app-trademark />
       <app-trademark />
@@ -147,20 +151,24 @@ export default {
       //显示的距离
       //显示的距离
       showDistance: 0,
       showDistance: 0,
       totalPrice: 0,
       totalPrice: 0,
-      mayPayAmount: 0
+      memberDiscount: 1,
+      couponDiscountAmount: 0
     };
     };
   },
   },
   mounted() {},
   mounted() {},
   computed: {
   computed: {
     ...mapGetters({ orderShop: "getOrderShop" }),
     ...mapGetters({ orderShop: "getOrderShop" }),
-    ...mapGetters({ shopUser: "getShopUser" })
+    ...mapGetters({ shopUser: "getShopUser" }),
+    mayPayAmount:function(){
+      let price = (this.goodsInfo.price * this.goodsInfo.buyNum + this.freightPrice)/this.memberDiscount + this.couponDiscountAmount;
+      return price.toFixed(2);
+    }
   },
   },
   watch: {
   watch: {
     //运费变化则总金额和应付金额变化
     //运费变化则总金额和应付金额变化
     freightPrice(newVal) {
     freightPrice(newVal) {
       let price = this.goodsInfo.price * this.goodsInfo.buyNum + newVal;
       let price = this.goodsInfo.price * this.goodsInfo.buyNum + newVal;
       this.totalPrice = price.toFixed(2);
       this.totalPrice = price.toFixed(2);
-      this.mayPayAmount = price.toFixed(2);
     }
     }
   },
   },
   onLoad(option) {
   onLoad(option) {
@@ -188,13 +196,17 @@ export default {
       this.goodsInfo = goodsInfo;
       this.goodsInfo = goodsInfo;
 
 
       this.totalPrice = goodsInfo.price * this.option.goodsNum;
       this.totalPrice = goodsInfo.price * this.option.goodsNum;
-      this.mayPayAmount = this.totalPrice;
+      //this.mayPayAmount = this.totalPrice;
 
 
       // 初始化上个页面带入的值
       // 初始化上个页面带入的值
       Object.keys(this.form).forEach((i, index) => {
       Object.keys(this.form).forEach((i, index) => {
         this.form[i] = this.option[i];
         this.form[i] = this.option[i];
       });
       });
     },
     },
+    calcDiscount(discountData) {
+      console.log("执行了方法");
+      this.memberDiscount = 0.8
+    },
     // 生成订单
     // 生成订单
     createOrderFn() {
     createOrderFn() {
       let addForm = {};
       let addForm = {};