洪海涛 8 năm trước cách đây
mục cha
commit
81fe07d508
1 tập tin đã thay đổi với 32 bổ sung21 xóa
  1. 32 21
      www/vue/src/components/placeOrder.vue

+ 32 - 21
www/vue/src/components/placeOrder.vue

@@ -118,18 +118,20 @@
       if (config.productInfo.length === 0) {
         this.$router.push({path: '/'})
       }
-      // 获取优惠券信息
-//      console.log(typeof config.orderInfo.coupons.coupon.alias_name)
-//      if (config.orderInfo.coupons !== undefined) {
-//        if (config.orderInfo.coupons.coupon.alias_name !== undefined) {
-//          this.couponName = config.orderInfo.coupons.coupon.alias_name
-//          this.couponValue = config.orderInfo.coupons.coupon.value
-//        } else if (config.orderInfo.coupons.coupon.alias_name === undefined) {
-//          this.$router.push({path: '/'})
-//        }
-//      }
-      // 渲染界面前,判断用户是否已经选择了地址
-      // config.addressContent 是全局变量,用来保存用户的
+      console.log(config.orderInfo.coupons)
+      // 判断是否已经获取优惠券信息
+      if (config.orderInfo.coupons !== undefined) {
+        if (config.orderInfo.coupons.coupon.alias_name !== undefined) {
+          this.couponName = config.orderInfo.coupons.coupon.alias_name
+          this.couponValue = config.orderInfo.coupons.coupon.value
+        } else if (config.orderInfo.coupons.coupon.alias_name === undefined) {
+          this.$router.push({path: '/'})
+        }
+      }
+      /*
+      渲染界面前,判断用户是否已经选择了地址
+      config.addressContent 是全局变量,用来保存用户的地址
+      */
       if (config.addressContent !== '暂无地址信息') {
         // 默认地址事件
         if (config.shopAddress.length === 0) {
@@ -149,9 +151,10 @@
       if (config.orderPrice === '') {
         config.orderPrice = 0
       }
-      config.order.extra = JSON.stringify(config.productInfo.extra[0])
-      console.log(JSON.stringify(config.productInfo.extra))
-      console.log(config.order.extra)
+      // 初始化extra 选项
+      if (config.order.extra === undefined) {
+        config.order.extra = JSON.stringify(config.productInfo.extra[0])
+      }
     },
     computed: {
       ...mapState({
@@ -165,7 +168,7 @@
         this.orderPrice = config.orderPrice = payCharge(parseInt(config.productInfo.extra[val].price), config.xNumberValue, this.couponValue)
       },
       'couponValue' (val, oldVal) {
-        console.log(val)
+//        console.log(val)
       }
     },
     methods: {
@@ -244,7 +247,7 @@
           return false
         }
         // 判断布艺沙发下单数量少于5套
-        console.log(config.productInfo.extra[config.isActive].type)
+//        console.log(config.productInfo.extra[config.isActive].type)
         if (config.productInfo.extra[config.isActive].type === '整套布艺沙发') {
           if (config.xNumberValue <= 5) {
             this.$vux.alert.show({
@@ -278,11 +281,12 @@
         return true
       },
       btnOrder: function () {
+        // 用户同意壹管家会员服务协议
         if (this.agreement) {
           if (this.JudgmentOrder()) {
             // 判断用户余额大于等于订单金额,满足条件走余额支付
-            config.order.userId = config.userId
-            config.order.memo = this.remarks
+            config.order.userId = config.userId // 用户id
+            config.order.memo = this.remarks // 备注内容
             config.order.id = config.productInfo.id
             config.order.products = JSON.stringify({
               product_id: config.productInfo.id, // 产品ID
@@ -299,7 +303,7 @@
             let productParamJson = [{'product_id': config.productInfo.id, 'count': config.xNumberValue}]
             productParamJson = JSON.stringify(productParamJson)
             config.order.extra = '[' + config.order.extra + ']'
-            // 优惠券回空赋值 ''
+            // 优惠为空时赋值 ''
             if (config.orderInfo.coupons.id === undefined) {
               config.orderInfo.coupons.id = []
             } else {
@@ -330,13 +334,20 @@
               }
             })
           }
+        } else {
+          // 弹出提示框
+          this.$vux.alert.show({
+            title: '',
+            content: '您还没有同意壹管家用户服务协议!'
+          })
+          return
         }
       },
       btnAction: function (index, event) {
         this.xNumberValue = config.xNumberValue = 0
         localStorage.setItem('extra', index)
         config.order.extra = JSON.stringify(config.productInfo.extra[index])
-        console.log(config.order.extra)
+//        console.log(config.order.extra)
         config.orderInfo.coupons = []
         this.couponName = '暂无优惠券'
         this.couponValue = 0