lrf 2 years ago
parent
commit
4d5dc7e907
2 changed files with 23 additions and 3 deletions
  1. 1 1
      pages/matchInfo/sign.js
  2. 22 2
      pages/usermyorder/index.js

+ 1 - 1
pages/matchInfo/sign.js

@@ -103,7 +103,7 @@ Page({
                         "success": async function (res) {
                             wx.showToast({ title: `支付成功`, icon: 'success', duration: 2000 });
                             const aee = await app.$post(`/newCourt/api/payOrder/${arr.data.data._id}`, { status: '1' });
-                            if (aee.errcode == '0') { that.watchLogin(); that.toclose(); that.back() }
+                            if (aee.errcode == '0') { that.watchLogin(); that.toClose(); that.back() }
                         },
                         "fail": function (res) {
                             wx.showToast({ title: `支付未成功`, icon: 'error', duration: 2000 })

+ 22 - 2
pages/usermyorder/index.js

@@ -13,8 +13,28 @@ Page({
         wx.navigateBack({ delta: 1 })
     },
     // 支付
-    toPay: function (e) {
-
+    toPay: async function (e) {
+        const that = this;
+        const id = e.currentTarget.dataset?.item?._id;
+        const res = await app.$post('/newCourt/api/payOrder/toRePay', { id })
+        if (res.errcode == '0') {
+            wx.requestPayment({
+                "timeStamp": res.data.wxSign.timestamp,
+                "nonceStr": res.data.wxSign.nonceStr,
+                "package": `prepay_id=${res.data.wxSign.prepay_id}`,
+                "signType": res.data.wxSign.signType,
+                "paySign": res.data.wxSign.paySign,
+                "success": async function (res) {
+                    wx.showToast({ title: `支付成功`, icon: 'success', duration: 2000 });
+                    const aee = await app.$post(`/newCourt/api/payOrder/${res.data.data._id}`, { status: '1' });
+                    if (aee.errcode == '0') { that.watchLogin(); }
+                },
+                "fail": function (res) {
+                    wx.showToast({ title: `支付未成功`, icon: 'error', duration: 2000 })
+                    that.watchLogin()
+                },
+            })
+        }
     },
     // 退款
     toRefund: async function (e) {