Ver código fonte

微信h5支付部分逻辑完成

cuiyalong 5 anos atrás
pai
commit
c56c2a1955

+ 7 - 7
src/utils/wx-js-sdk-register.ts

@@ -254,11 +254,11 @@ class WeiXinSDK {
   }
 
   // 微信js-sdk支付
-  chooseWXPay (config: object, callbacks?: any) {
-    // 执行分享
+  chooseWXPay (options: any) {
+    // 执行支付
     wx.chooseWXPay({
       appId: this.config.configData.appId,
-      ...config,
+      ...options.config,
       // timestamp: config.timestamp,
       // nonceStr: config.nonceStr,
       // package: config.package,
@@ -266,19 +266,19 @@ class WeiXinSDK {
       // paySign: config.paySign,
       success: () => {
         // 用户确认支付后执行的回调函数
-        callbacks && callbacks.success && callbacks.success()
+        options && options.success && options.success()
       },
       cancel: () => {
         // 用户取消支付后执行的回调函数
-        callbacks && callbacks.cancel && callbacks.cancel()
+        options && options.cancel && options.cancel()
       },
       fail: () => {
         // 接口调用失败时执行的回调函数
-        callbacks && callbacks.fail && callbacks.fail()
+        options && options.fail && options.fail()
       },
       complete: () => {
         // 接口调用完成时执行的回调函数,无论成功或失败都会执行。
-        callbacks && callbacks.complete && callbacks.complete()
+        options && options.complete && options.complete()
       }
     })
   }

+ 10 - 5
src/views/buy/Buy.vue

@@ -166,7 +166,7 @@ export default class BuyReport extends Vue {
 
   // 用户信息(需要提交)
   userInfo = {
-    email: 'cuiyalong@topnet.net.cn',
+    email: '',
     phone: '',
     code: '',
     company: ''
@@ -191,7 +191,8 @@ export default class BuyReport extends Vue {
       text: '邮箱格式输入错误'
     },
     phone: {
-      reg: /^(0|86|17951)?(13[0-9]|15[012356789]|166|17[3678]|18[0-9]|14[57])[0-9]{8}$/,
+      // 新曾19*号段
+      reg: /^(0|86|17951)?(13[0-9]|15[012356789]|166|17[3678]|18[0-9]|14[57]|19[0-9])[0-9]{8}$/,
       text: '手机号格式输入错误'
     },
     code: {
@@ -216,7 +217,10 @@ export default class BuyReport extends Vue {
       } else {
         // 判断是不是company
         if (key === 'code') {
-          pass = this.sendedEmail && this.emailCodePass
+          // 如果显示输入验证码时候才判断code是否pass
+          if (this.showSendEmailCode) {
+            pass = this.sendedEmail && this.emailCodePass
+          }
         } else if (key === 'company') {
           pass = !!info[key]
         }
@@ -228,7 +232,7 @@ export default class BuyReport extends Vue {
   }
 
   get confirmDisabled () {
-    return !this.iAgree || (!this.allRegPass && this.showSendEmailCode)
+    return !this.iAgree || !this.allRegPass
   }
 
   get showSendEmailCode () {
@@ -320,7 +324,7 @@ export default class BuyReport extends Vue {
 
   toServiceTerms (e) {
     this.saveState()
-    // location.href = e.target.href
+    location.href = e.target.href
   }
 
   sendCode (cb) {
@@ -381,6 +385,7 @@ export default class BuyReport extends Vue {
     this.orderSubmit(data).then(res => {
       if (res.error_code === 0 && res.data.ordercode) {
         this.$toast.clear()
+        this.saveState()
         this.$router.push(`/pay/${res.data.ordercode}`)
       }
     })

+ 0 - 1
src/views/main/IntroducePage.vue

@@ -58,7 +58,6 @@ export default class Introduce extends Vue {
 
 <style lang="scss">
   .introduce{
-    height: 100%;
     overflow: hidden!important;
     .banner{
       position: relative;

+ 29 - 26
src/views/pay/Pay.vue

@@ -97,7 +97,6 @@ export default class Pay extends Vue {
 
   mounted () {
     this.getInfo()
-    console.log(this.$wxSdk)
   }
 
   radioCheck (type) {
@@ -125,30 +124,31 @@ export default class Pay extends Vue {
 
   // 确认支付
   confirmPay () {
-    this.$toast.loading({
-      message: '加载中...',
-      forbidClick: true,
-      duration: 0
-    })
-    const data = {
-      payway: this.payWay,
-      ordercode: this.orderInfo.ordercode
-    }
-    this.getPaySign(data).then(res => {
-      if (res.error_code === 0) {
-        this.$toast.clear()
-        if (res.status === 1) {
-          // 获取参数成功,判断是微信h5还是非微信h5
-          if (this.env.isWeiXinBrowser) {
-            this.wxPayCallBack(res.data.payStr)
-          } else {
-            this.appPayCallBack(res.data.payStr)
-          }
-        } else {
-          this.$toast(res.error_msg || '获取支付信息失败')
-        }
-      }
-    })
+    this.wxPayCallBack('')
+    // this.$toast.loading({
+    //   message: '加载中...',
+    //   forbidClick: true,
+    //   duration: 0
+    // })
+    // const data = {
+    //   payway: this.payWay,
+    //   ordercode: this.orderInfo.ordercode
+    // }
+    // this.getPaySign(data).then(res => {
+    //   if (res.error_code === 0) {
+    //     this.$toast.clear()
+    //     if (res.status === 1) {
+    //       // 获取参数成功,判断是微信h5还是非微信h5
+    //       if (this.env.isWeiXinBrowser) {
+    //         this.wxPayCallBack(res.data.payStr)
+    //       } else {
+    //         this.appPayCallBack(res.data.payStr)
+    //       }
+    //     } else {
+    //       this.$toast(res.error_msg || '获取支付信息失败')
+    //     }
+    //   }
+    // })
   }
 
   // 微信h5支付逻辑
@@ -180,6 +180,9 @@ export default class Pay extends Vue {
         signType: sign.signType,
         paySign: sign.paySign,
         appId: sign.appId
+      },
+      success: () => {
+        console.log(123)
       }
     })
   }
@@ -213,7 +216,7 @@ export default class Pay extends Vue {
         if (res.error_code === 0 && res.data.status === 1) {
           // 支付完成订单,关闭定时器
           clearInterval(checkPaySuccessTimer)
-          this.$router.push(`/pay-success/${ordercode}`)
+          this.$router.replace(`/pay-success/${ordercode}`)
         }
       })
     }, 3000)