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-header">
<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 class="balance-amount">{{ formatMoney(walletDetail.balance) }}</view>
</view>
@@ -22,8 +24,8 @@
</view>
<!-- 充值弹窗 -->
<up-popup :show="showRechargeModal" mode="center" @close="showRechargeModal=false">
<view class="recharge-popup">
<up-popup :show="showRechargeModal" mode="center" @close="showRechargeModal=false" :customStyle="{ borderRadius: '24rpx' }">
<view class="recharge-popup" @tap.stop>
<view class="popup-header">
<view class="popup-title">账户充值</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({
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;