fix: 支付/钱包
All checks were successful
构建并部署前端到生产环境 / build-and-deploy (push) Successful in 44s

This commit is contained in:
sexygoat
2026-04-14 12:17:51 +08:00
parent 5e8ff94b7a
commit bd9f3e6141

View File

@@ -4,7 +4,9 @@
<view class="balance-section"> <view class="balance-section">
<view class="balance-header"> <view class="balance-header">
<view class="balance-label">账户余额()</view> <view class="balance-label">账户余额()</view>
<button class="btn-recharge" @tap="showRechargeModal = true">充值</button> <view class="recharge-btn-wrapper">
<button class="btn-recharge" @tap="showRechargeModal = true">充值</button>
</view>
</view> </view>
<view class="balance-amount">{{ formatMoney(walletDetail.balance) }}</view> <view class="balance-amount">{{ formatMoney(walletDetail.balance) }}</view>
</view> </view>
@@ -22,8 +24,8 @@
</view> </view>
<!-- 充值弹窗 --> <!-- 充值弹窗 -->
<up-popup :show="showRechargeModal" mode="center" @close="showRechargeModal=false"> <up-popup :show="showRechargeModal" mode="center" @close="showRechargeModal=false" :customStyle="{ borderRadius: '24rpx' }">
<view class="recharge-popup"> <view class="recharge-popup" @tap.stop>
<view class="popup-header"> <view class="popup-header">
<view class="popup-title">账户充值</view> <view class="popup-title">账户充值</view>
<view class="popup-close" @tap="showRechargeModal=false">×</view> <view class="popup-close" @tap="showRechargeModal=false">×</view>
@@ -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({ uni.requestPayment({
timeStamp: rechargeData.pay_config.timestamp, timeStamp: rechargeData.pay_config.timestamp,
nonceStr: rechargeData.pay_config.nonce_str, nonceStr: rechargeData.pay_config.nonce_str,
@@ -316,7 +351,6 @@
console.log('支付成功', res); console.log('支付成功', res);
uni.showToast({ title: '充值成功', icon: 'success' }); uni.showToast({ title: '充值成功', icon: 'success' });
setTimeout(() => { setTimeout(() => {
// 刷新钱包余额和充值记录
loadWalletDetail(); loadWalletDetail();
rechargePage.value = 1; rechargePage.value = 1;
rechargeNoMore.value = false; rechargeNoMore.value = false;
@@ -332,6 +366,7 @@
} }
} }
}); });
// #endif
} catch (e) { } catch (e) {
uni.hideLoading(); uni.hideLoading();
@@ -471,15 +506,17 @@
justify-content: space-between; justify-content: space-between;
margin-bottom: 8rpx; margin-bottom: 8rpx;
.balance-label { font-size: 24rpx; opacity: 0.75; } .balance-label { font-size: 24rpx; opacity: 0.75; }
.btn-recharge { .recharge-btn-wrapper {
background: rgba(255, 255, 255, 0.25); .btn-recharge {
border: 1rpx solid rgba(255, 255, 255, 0.5); background: rgba(255, 255, 255, 0.25);
color: #fff; border: 1rpx solid rgba(255, 255, 255, 0.5);
font-size: 24rpx; color: #fff;
padding: 8rpx 24rpx; font-size: 24rpx;
border-radius: 40rpx; padding: 8rpx 24rpx;
font-weight: 500; border-radius: 40rpx;
&::after { border: none; } font-weight: 500;
&::after { border: none; }
}
} }
} }
.balance-amount { font-size: 72rpx; font-weight: 700; letter-spacing: -2rpx; } .balance-amount { font-size: 72rpx; font-weight: 700; letter-spacing: -2rpx; }
@@ -594,9 +631,11 @@
.recharge-popup { .recharge-popup {
width: 600rpx; width: 600rpx;
max-width: 90vw;
background: var(--bg-primary); background: var(--bg-primary);
border-radius: var(--radius-large); border-radius: var(--radius-large);
overflow: hidden; overflow: hidden;
box-sizing: border-box;
.popup-header { .popup-header {
display: flex; display: flex;