From 702d1cdc3624358ecfb249e671493ae11013b6da Mon Sep 17 00:00:00 2001 From: WindowBird <13870814+windows-bird@user.noreply.gitee.com> Date: Fri, 29 Aug 2025 12:00:06 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E7=94=A8=E5=BE=AE=E4=BF=A1=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E6=8E=A5=E5=8F=A3=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/dev.js | 2 +- pages/index/index.vue | 44 ++++++++++++++++++++++++++++++++--------- pages/lease/lease.vue | 46 +++++++++++++++++++++++++++++++++++++------ 3 files changed, 76 insertions(+), 16 deletions(-) diff --git a/config/dev.js b/config/dev.js index 6e66e15..02a66b7 100644 --- a/config/dev.js +++ b/config/dev.js @@ -2,7 +2,7 @@ export const DEV_CONFIG = { // 临时token,用于开发测试 TEMP_TOKEN: - 'eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjIwNTJiNTYxLWExYmYtNDhmZi04YzgxLTUxOTQwOTkzNGNkMyJ9.GtV24rNuYHsxmyzA8Di6Sy_QaK2wWTouhhEH8vmTk6pJKdhHrnnNev-SF8tSsOB-QVlBQ2mjX22-4znaERwmcg', + 'eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjQzMjljNzhjLTFmN2YtNGRkMS1iMDllLTZjNGRhZGI4MWUzZSJ9.S6TisMbcX1V1LqGilCG9BGye-p_36pWzgaF67O3DxN2exLR48oZLEAxYdbjNU5cqEtg4x5WJ3rpVs2gQer3xig', // 是否使用临时token USE_TEMP_TOKEN: true, diff --git a/pages/index/index.vue b/pages/index/index.vue index a8d5093..722cfa1 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -343,7 +343,7 @@ export default { suitId: this.selectedPackage.id, appId: '1', // 应用ID,根据实际情况调整 payAmount: this.selectedPackage.price || this.selectedPackage.amount, - channelId: '2', // 渠道ID,根据实际情况调整 + channelId: '3', // 渠道ID,根据实际情况调整 devId: this.selectedDevice.id, } @@ -351,16 +351,42 @@ export default { const response = await renewDevice(renewData) - uni.hideLoading() - if (response.code === 200) { - uni.showToast({ - title: '续费成功', - icon: 'success', + const data = response.data + const wxpPayParams = data.payParams + console.log(data) + + const payParams = { + package: wxpPayParams.packageVal, // 后端返回的字段名 + timeStamp: wxpPayParams.timeStamp, + nonceStr: wxpPayParams.nonceStr, + signType: wxpPayParams.signType, + paySign: wxpPayParams.paySign, + } + console.log('支付后端回调数据', payParams) + + wx.requestPayment({ + ...payParams, + success: function (res) { + uni.showToast({ + title: '支付成功', + icon: 'success', + duration: 2000, + }) + uni.navigateTo({ + url: `/pages/myOrder/orderDetail?id=${data.pay.bstId}`, + }) + }, + fail: function (res) { + uni.showToast({ + title: '支付失败', + icon: 'fail', + }) + }, + complete: function (res) { + console.log('微信支付调用结束') + }, }) - - await sleep(1000) - // 关闭弹窗 this.closeRenewModal() diff --git a/pages/lease/lease.vue b/pages/lease/lease.vue index 610efb0..11a4155 100644 --- a/pages/lease/lease.vue +++ b/pages/lease/lease.vue @@ -165,7 +165,7 @@ export default { devTypeId: '', // 设备类型ID period: '', suitId: '', // 租赁周期ID - channelId: '2', //渠道id + channelId: '3', //渠道id payAmount: 0, }, showDetails: false, @@ -382,14 +382,48 @@ export default { success: async res => { if (res.confirm) { // 这里可以调用支付API - const response = await createLeaseOrder(this.formData) - + //"17318322273" if (response.code === 200) { - uni.showToast({ - title: '支付成功', - icon: 'success', + const data = response.data + console.log(data) + + const payParams = { + package: response.data.payParams.packageVal, // 后端返回的字段名 + timeStamp: response.data.payParams.timeStamp, + nonceStr: response.data.payParams.nonceStr, + signType: response.data.payParams.signType, + paySign: response.data.payParams.paySign, + } + console.log('支付后端回调数据', payParams) + + wx.requestPayment({ + ...payParams, + success: function (res) { + uni.showToast({ + title: '支付成功', + icon: 'success', + duration: 2000, + }) + uni.navigateTo({ + url: `/pages/myOrder/orderDetail?id=${data.pay.bstId}`, + }) + }, + fail: function (res) { + uni.showToast({ + title: '支付失败', + icon: 'fail', + }) + }, + complete: function (res) { + console.log('微信支付调用结束') + }, }) + + // uni.showToast({ + // title: '支付成功', + // icon: 'success', + // }) } else { uni.showToast({ title: response.msg || '添加失败',