fix: 修改强充
All checks were successful
构建并部署前端到生产环境 / build-and-deploy (push) Successful in 46s

This commit is contained in:
sexygoat
2026-04-15 09:34:20 +08:00
parent e79d17058a
commit 1336b86fc2
2 changed files with 43 additions and 23 deletions

View File

@@ -27,7 +27,7 @@
<view class="tab-header">
<view class="tab-indicator" :style="{ left: currentTab === 0 ? '8rpx' : '50%' }"></view>
<view class="tab-item" :class="{ active: currentTab === 0 }" @tap="onTabTap(0)">
<text>充值记录</text>
<text>充值订单</text>
</view>
<view class="tab-item" :class="{ active: currentTab === 1 }" @tap="onTabTap(1)">
<text>钱包流水</text>
@@ -39,7 +39,7 @@
<scroll-view scroll-y class="list-content">
<view v-if="rechargeList.length === 0 && !rechargeLoading" class="empty-state">
<view class="empty-icon">📋</view>
<view class="empty-title">暂无充值记录</view>
<view class="empty-title">暂无充值订单</view>
</view>
<view v-else>

View File

@@ -141,7 +141,42 @@
[currentPackage.value.package_id]
);
// 检查是否有订单信息
// 判断是否为强充订单
if (orderResult.order_type === 'recharge' && orderResult.recharge && orderResult.pay_config) {
// 强充订单:显示提示信息并直接使用返回的 pay_config 支付
if (!orderResult.pay_config.package) {
uni.hideLoading();
uni.showToast({ title: '支付参数获取失败', icon: 'none' });
return;
}
// 获取强充信息
const forceRechargeAmount = orderResult.linked_package_info?.force_recharge_amount || 0;
const packageNames = orderResult.linked_package_info?.package_names || [];
uni.hideLoading();
showModal.value = false;
// 提示用户需要强充
const packageNameStr = packageNames.length > 0 ? packageNames.join('、') : '套餐';
const message = `购买${packageNameStr}需要先充值 ¥${formatMoney(forceRechargeAmount)},充值成功后将自动购买套餐`;
uni.showModal({
title: '需要充值',
content: message,
confirmText: '去充值',
cancelText: '取消',
success: async (res) => {
if (res.confirm) {
// 调起微信支付
await handleWechatPay(orderResult.pay_config, true);
}
}
});
return;
}
// 检查是否有订单信息(非强充订单)
if (!orderResult || !orderResult.order) {
uni.hideLoading();
showModal.value = false;
@@ -151,23 +186,6 @@
const orderId = orderResult.order.order_id;
// 判断是否为强充订单
if (orderResult.order_type === 'recharge' && orderResult.pay_config) {
// 强充订单:直接使用返回的 pay_config 支付
if (!orderResult.pay_config.package) {
uni.hideLoading();
uni.showToast({ title: '支付参数获取失败', icon: 'none' });
return;
}
uni.hideLoading();
showModal.value = false;
// 调起微信支付
await handleWechatPay(orderResult.pay_config);
return;
}
// 第二步:获取支付参数
uni.showLoading({ title: '准备支付...', mask: true });
@@ -218,7 +236,7 @@
}
};
const handleWechatPay = async (payConfig) => {
const handleWechatPay = async (payConfig, isForceRecharge = false) => {
// 验证参数
if (!payConfig.package || !payConfig.package.startsWith('prepay_id=')) {
uni.showToast({ title: '支付参数无效', icon: 'none' });
@@ -241,7 +259,8 @@
}, function(res) {
if (res.err_msg === 'get_brand_wcpay_request:ok') {
console.log('支付成功', res);
uni.showToast({ title: '支付成功', icon: 'success' });
const successMsg = isForceRecharge ? '充值成功,套餐将自动购买' : '支付成功';
uni.showToast({ title: successMsg, icon: 'success', duration: 2000 });
setTimeout(() => {
loadWalletBalance();
}, 1500);
@@ -263,7 +282,8 @@
paySign: payConfig.pay_sign,
success: (res) => {
console.log('支付成功', res);
uni.showToast({ title: '支付成功', icon: 'success' });
const successMsg = isForceRecharge ? '充值成功,套餐将自动购买' : '支付成功';
uni.showToast({ title: successMsg, icon: 'success', duration: 2000 });
setTimeout(() => {
loadWalletBalance();
}, 1500);