Kaynağa Gözat

fix: handle weixin pay success callback function

wangyuan 2 yıl önce
ebeveyn
işleme
07b9db1aff
1 değiştirilmiş dosya ile 21 ekleme ve 7 silme
  1. 21 7
      pages/buy/buy.js

+ 21 - 7
pages/buy/buy.js

@@ -23,7 +23,7 @@ Page({
   /**
    * 生命周期函数--监听页面显示
    */
-  onShow() {
+  onLoad() {
     this.getGoodsList()
     this.getAccountNmberFn()
     this.setData({
@@ -99,6 +99,7 @@ Page({
   },
   // 调用微信支付
   handleWXPay () {
+    var that = this
     var data = {
       goodsId: this.data.goodsId,
       orderAmount: this.data.orderAmount,
@@ -117,14 +118,27 @@ Page({
         package: res.data.packageStr,
         signType: res.data.signType,
         paySign: res.data.paySign,
-        success (res) { 
-          wx.showToast({
-            title: '支付成功',
-            icon: 'success'
+        success (res) {
+          that.getAccountNmberFn() 
+          wx.showModal({
+            title: '支付成功,立即去预约',
+            confirmText: '去预约',
+            confirmColor: '#333',
+            cancelColor: '#666',
+            success (modalRes) {
+              if (modalRes.confirm) {
+                wx.navigateTo({
+                  url: '/pages/appointment/appointment'
+                })
+              }
+            }
           })
         },
-        fail (res) { 
-          console.log('weixin pay fail', res);
+        fail (res) {
+          wx.showToast({
+            title: '支付失败',
+            icon: "error"
+          })
         }
       })
     }).catch(e => {