From 6a734d758720185f538e672c879121adb6732274 Mon Sep 17 00:00:00 2001 From: litian <C21AF165> Date: 星期二, 02 四月 2024 09:20:45 +0800 Subject: [PATCH] 代码合并,问题修改,学习 --- packagePersonal/pages/myOrder/index.js | 116 ++++++++++++++++----------------------------------------- 1 files changed, 33 insertions(+), 83 deletions(-) diff --git a/packagePersonal/pages/myOrder/index.js b/packagePersonal/pages/myOrder/index.js index f89f220..129bb1f 100644 --- a/packagePersonal/pages/myOrder/index.js +++ b/packagePersonal/pages/myOrder/index.js @@ -263,91 +263,41 @@ orderNum: orderNum, }; app.MG.store.getOrderByOrderNum(data).then(res => { - if (res && res.state != "WaitPay") { - app.MG.store.confirmOrder(data).then(conRes => { - if (conRes.orderNumber) { - const resOrderNum = { - orderNum: conRes.orderNumber, - }; - if (conRes.payPrice != 0) { - app.MG.store.makeWeChatPay(resOrderNum).then(payRes => { - const payVal = JSON.parse(payRes); - wx.requestPayment({ - "appId": payVal.appId, - "timeStamp": payVal.timeStamp, - "nonceStr": payVal.nonceStr, - "package": payVal.package, - "signType": payVal.signType, - "paySign": payVal.paySign, - "success": function (res) { - if (res.errMsg == 'requestPayment:ok') { - that.setData({ - isPaySuccess: true - }) - } - console.log(res, "鎴愬姛") - }, - "fail": function (res) { - console.log(res, "澶辫触") - }, - "complete": function (res) { - if (res.errMsg == 'requestPayment:ok') { - that.getDataList(false) - } - if (that.data.isPaySuccess && that.data.isPayComplete) { - that.navToBack() - } - } + app.MG.store.makeWeChatPay({ + orderNum: res.orderNumber, + platform: "WeChatAppCustom" + }) + .then(payRes => { + const payVal = JSON.parse(payRes); + wx.requestPayment({ + "appId": payVal.appId, + "timeStamp": payVal.timeStamp, + "nonceStr": payVal.nonceStr, + "package": payVal.package, + "signType": payVal.signType, + "paySign": payVal.paySign, + "success": function (res) { + if (res.errMsg == 'requestPayment:ok') { + that.setData({ + isPaySuccess: true }) - }); - } else { - wx.showToast({ - title: '棰嗗彇鎴愬姛', - }) - // 鍙坊鍔犺繑鍥炰笂绾� - setTimeout(() => { - that.navToBack() - }, 2000); - } - } - }); - } else { - app.MG.store - .makeWeChatPay({ - orderNum: orderNum - }) - .then(payRes => { - const payVal = JSON.parse(payRes); - wx.requestPayment({ - "appId": payVal.appId, - "timeStamp": payVal.timeStamp, - "nonceStr": payVal.nonceStr, - "package": payVal.package, - "signType": payVal.signType, - "paySign": payVal.paySign, - "success": function (res) { - if (res.errMsg == 'requestPayment:ok') { - that.setData({ - isPaySuccess: true - }) - } - }, - "fail": function (res) { - console.log(res, "澶辫触") - }, - "complete": function (res) { - if (res.errMsg == 'requestPayment:ok') { - that.setData({ - isPayComplete: true - }) - } - if (that.data.isPaySuccess && that.data.isPayComplete) { - that.navToBack() - } } - }) - }); - } + }, + "fail": function (res) { + console.log(res, "澶辫触") + }, + "complete": function (res) { + if (res.errMsg == 'requestPayment:ok') { + that.setData({ + isPayComplete: true + }) + } + if (that.data.isPaySuccess && that.data.isPayComplete) { + that.navToBack() + } + } + }) + }); }); }, -- Gitblit v1.9.1