From bd9f3e614141395553bc5a5d3e853e50cebd9b95 Mon Sep 17 00:00:00 2001 From: sexygoat <1538832180@qq.com> Date: Tue, 14 Apr 2026 12:17:51 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=94=AF=E4=BB=98/=E9=92=B1=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/my-wallet/my-wallet.vue | 65 ++++++++++++++++++++++++++++------- 1 file changed, 52 insertions(+), 13 deletions(-) diff --git a/pages/my-wallet/my-wallet.vue b/pages/my-wallet/my-wallet.vue index c8bf976..8d2373a 100644 --- a/pages/my-wallet/my-wallet.vue +++ b/pages/my-wallet/my-wallet.vue @@ -4,7 +4,9 @@ 账户余额(元) - + + + {{ formatMoney(walletDetail.balance) }} @@ -22,8 +24,8 @@ - - + + 账户充值 × @@ -306,6 +308,39 @@ } // 第三步:调起微信支付 + // #ifdef H5 + if (typeof WeixinJSBridge === 'undefined') { + uni.showToast({ title: '请在微信中打开', icon: 'none' }); + return; + } + + WeixinJSBridge.invoke('getBrandWCPayRequest', { + appId: rechargeData.pay_config.app_id, + timeStamp: rechargeData.pay_config.timestamp, + nonceStr: rechargeData.pay_config.nonce_str, + package: rechargeData.pay_config.package, + signType: rechargeData.pay_config.sign_type, + paySign: rechargeData.pay_config.pay_sign + }, function(res) { + if (res.err_msg === 'get_brand_wcpay_request:ok') { + console.log('支付成功', res); + uni.showToast({ title: '充值成功', icon: 'success' }); + setTimeout(() => { + loadWalletDetail(); + rechargePage.value = 1; + rechargeNoMore.value = false; + loadRechargeList(); + }, 1500); + } else if (res.err_msg === 'get_brand_wcpay_request:cancel') { + uni.showToast({ title: '已取消支付', icon: 'none' }); + } else { + console.error('支付失败', res); + uni.showToast({ title: '支付失败', icon: 'none' }); + } + }); + // #endif + + // #ifndef H5 uni.requestPayment({ timeStamp: rechargeData.pay_config.timestamp, nonceStr: rechargeData.pay_config.nonce_str, @@ -316,7 +351,6 @@ console.log('支付成功', res); uni.showToast({ title: '充值成功', icon: 'success' }); setTimeout(() => { - // 刷新钱包余额和充值记录 loadWalletDetail(); rechargePage.value = 1; rechargeNoMore.value = false; @@ -332,6 +366,7 @@ } } }); + // #endif } catch (e) { uni.hideLoading(); @@ -471,15 +506,17 @@ justify-content: space-between; margin-bottom: 8rpx; .balance-label { font-size: 24rpx; opacity: 0.75; } - .btn-recharge { - background: rgba(255, 255, 255, 0.25); - border: 1rpx solid rgba(255, 255, 255, 0.5); - color: #fff; - font-size: 24rpx; - padding: 8rpx 24rpx; - border-radius: 40rpx; - font-weight: 500; - &::after { border: none; } + .recharge-btn-wrapper { + .btn-recharge { + background: rgba(255, 255, 255, 0.25); + border: 1rpx solid rgba(255, 255, 255, 0.5); + color: #fff; + font-size: 24rpx; + padding: 8rpx 24rpx; + border-radius: 40rpx; + font-weight: 500; + &::after { border: none; } + } } } .balance-amount { font-size: 72rpx; font-weight: 700; letter-spacing: -2rpx; } @@ -594,9 +631,11 @@ .recharge-popup { width: 600rpx; + max-width: 90vw; background: var(--bg-primary); border-radius: var(--radius-large); overflow: hidden; + box-sizing: border-box; .popup-header { display: flex;