From 7766ca01a2b8c6d9bd3ecf17024dedcaac34fd3d Mon Sep 17 00:00:00 2001 From: hflllll Date: Thu, 12 Jun 2025 16:50:39 +0800 Subject: [PATCH] =?UTF-8?q?'=E6=8F=90=E7=8E=B0=E5=BE=85=E8=81=94=E8=B0=83'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages_order/mine/wallet.vue | 77 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 69 insertions(+), 8 deletions(-) diff --git a/pages_order/mine/wallet.vue b/pages_order/mine/wallet.vue index f9aecac..39645d3 100644 --- a/pages_order/mine/wallet.vue +++ b/pages_order/mine/wallet.vue @@ -185,19 +185,80 @@ export default { this.$api('cashout', { transferAmount: this.withdrawAmount, userName: this.realName }, res => { uni.hideLoading() if (res.code === 200) { - uni.showToast({ - title: '提现成功', - icon: 'success' - }) - this.$store.commit('getUserInfo') - this.withdrawAmount = '' - this.realName = '' + // 处理待收款用户确认的情况 + if (res.result && res.result.state === 'WAIT_USER_CONFIRM' && res.result.packageInfo && res.result.outBillNo) { + // 拉起微信收款确认页面 + if (!wx.canIUse('requestMerchantTransfer')) { + wx.showModal({ + content: '你的微信版本过低,请更新至最新版本。', + showCancel: false, + }); + return + } + + // 判断是否在开发者工具中 + const systemInfo = uni.getSystemInfoSync(); + const isDevTools = systemInfo.platform === 'devtools'; + + if (isDevTools) { + // 在开发者工具中,显示提示信息 + console.log('开发者工具中无法调试此API,请在真机上测试'); + uni.showModal({ + title: '提示', + content: '当前在开发者工具中,无法调试支付相关API,请在真机上测试。', + showCancel: false, + success: () => { + // 模拟成功,方便开发调试 + this.$store.commit('getUserInfo') + this.withdrawAmount = '' + this.realName = '' + this.isFormValid = true + } + }); + } else { + // 在真机环境中,调用API + wx.requestMerchantTransfer({ + mchId: res.result.outBillNo, + appId: wx.getAccountInfoSync().miniProgram.appId, + package: res.result.packageInfo, + success: (res) => { + uni.showToast({ + title: '提现申请已提交', + icon: 'success' + }) + this.$store.commit('getUserInfo') + this.withdrawAmount = '' + this.realName = '' + }, + fail: (res) => { + console.log('fail:', res); + uni.showToast({ + title: '提现失败,请稍后再试', + icon: 'none' + }) + this.isFormValid = true + }, + complete: (res) => { + console.log('requestMerchantTransfer完成:', res); + } + }); + } + } else { + uni.showToast({ + title: '提现成功', + icon: 'success' + }) + this.$store.commit('getUserInfo') + this.withdrawAmount = '' + this.realName = '' + } }else { uni.showToast({ - title: res.message, + title: 'res.message', icon: 'error' }) } + this.isFormValid = true }) },