Kaynağa Gözat

座位预定-支付宝支付

panyong 3 yıl önce
ebeveyn
işleme
104c241604
1 değiştirilmiş dosya ile 51 ekleme ve 2 silme
  1. 51 2
      htmldev/dashboard/src/views/place/list/index.vue

+ 51 - 2
htmldev/dashboard/src/views/place/list/index.vue

@@ -309,18 +309,67 @@ export default {
         Toast('请预订人名字')
         return
       }
+      const myToast = Toast.loading({
+        message: '加载中...',
+        duration: 1000 * 100,
+        forbidClick: true
+      })
       this.booLock = true
       try {
-        const { status, msg } = await apiPlacePreOrder(postData)
+        const { status, data, msg } = await apiPlacePreOrder(postData)
         this.booLock = false
+        myToast.clear()
         if (status) {
-          this.$router.push({ name: 'PlaceReserve' })
+          const officialOrderNumber = data.official_order_number
+          // 支付宝支付
+          if (this.order_pay_type === 2) {
+            const div = document.createElement('div')
+            div.innerHTML = officialOrderNumber
+            document.body.appendChild(div)
+            document.forms[0].submit()
+          } else {
+            // 微信支付
+            // window.location.replace
+          }
         } else {
           Toast(msg)
         }
       } catch (err) {
         this.booLock = false
       }
+    },
+    weixinPay (data) {
+      var vm = this
+      if (typeof WeixinJSBridge === 'undefined') {
+        if (document.addEventListener) {
+          document.addEventListener('WeixinJSBridgeReady', vm.onBridgeReady(data), false)
+        } else if (document.attachEvent) {
+          document.attachEvent('WeixinJSBridgeReady', vm.onBridgeReady(data))
+          document.attachEvent('onWeixinJSBridgeReady', vm.onBridgeReady(data))
+        }
+      } else {
+        vm.onBridgeReady(data)
+      }
+    },
+    onBridgeReady (data) {
+      /* eslint-disable-next-line */
+      WeixinJSBridge.invoke(
+        'getBrandWCPayRequest',
+        {
+          appId: data.appid,
+          timeStamp: data.timestamp,
+          nonceStr: data.nonce_str,
+          package: data.prepay_id,
+          signType: data.signType,
+          paySign: data.paySign
+        },
+        function (res) {
+          if (res.err_msg === 'get_brand_wcpay_request:ok') {
+          } else {
+            Toast.fail('支付失败!')
+          }
+        }
+      )
     }
   }
 }