This commit is contained in:
@@ -70,7 +70,9 @@
|
||||
|
||||
<view class="popup-footer">
|
||||
<button class="btn-apple btn-secondary" @tap="showModal=false">取消</button>
|
||||
<button class="btn-apple btn-primary" @tap="confirmPay">确认支付</button>
|
||||
<button class="btn-apple btn-primary" :disabled="paySubmitting" @tap="confirmPay">
|
||||
{{ paySubmitting ? '处理中...' : '确认支付' }}
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
</up-popup>
|
||||
@@ -91,6 +93,7 @@
|
||||
let loading = ref(false);
|
||||
let paymentMethod = ref('wechat');
|
||||
let walletBalance = ref(0);
|
||||
let paySubmitting = ref(false);
|
||||
|
||||
const formatMoney = (amount) => {
|
||||
if (!amount && amount !== 0) return '0.00';
|
||||
@@ -135,7 +138,9 @@
|
||||
};
|
||||
|
||||
const confirmPay = async () => {
|
||||
if (!currentPackage.value) return;
|
||||
if (paySubmitting.value || !currentPackage.value) return;
|
||||
paySubmitting.value = true;
|
||||
let releaseInModalCallback = false;
|
||||
|
||||
uni.showLoading({ title: '创建订单...', mask: true });
|
||||
|
||||
@@ -200,6 +205,7 @@
|
||||
// 提示用户需要强充
|
||||
const packageNameStr = packageNames.length > 0 ? packageNames.join('、') : '套餐';
|
||||
const message = `购买${packageNameStr}需要先充值 ¥${formatMoney(forceRechargeAmount)},充值成功后将自动购买套餐`;
|
||||
releaseInModalCallback = true;
|
||||
|
||||
uni.showModal({
|
||||
title: '需要充值',
|
||||
@@ -207,10 +213,17 @@
|
||||
confirmText: '去充值',
|
||||
cancelText: '取消',
|
||||
success: async (res) => {
|
||||
if (res.confirm) {
|
||||
// 调起微信支付
|
||||
await handleWechatPay(orderResult.pay_config, true);
|
||||
try {
|
||||
if (res.confirm) {
|
||||
// 调起微信支付
|
||||
await handleWechatPay(orderResult.pay_config, true);
|
||||
}
|
||||
} finally {
|
||||
paySubmitting.value = false;
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
paySubmitting.value = false;
|
||||
}
|
||||
});
|
||||
return;
|
||||
@@ -273,6 +286,10 @@
|
||||
// 其他错误提示
|
||||
const errorMsg = e.msg || e.message || '操作失败,请稍后重试';
|
||||
uni.showToast({ title: errorMsg, icon: 'none' });
|
||||
} finally {
|
||||
if (!releaseInModalCallback) {
|
||||
paySubmitting.value = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -515,20 +532,24 @@
|
||||
padding: 30rpx;
|
||||
border-top: 1rpx solid var(--border-light);
|
||||
|
||||
.btn-apple {
|
||||
flex: 1;
|
||||
height: 88rpx;
|
||||
display: flex;
|
||||
.btn-apple {
|
||||
flex: 1;
|
||||
height: 88rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: var(--radius-medium);
|
||||
font-size: 28rpx;
|
||||
font-weight: 500;
|
||||
border: none;
|
||||
font-size: 28rpx;
|
||||
font-weight: 500;
|
||||
border: none;
|
||||
|
||||
&.btn-secondary {
|
||||
background: var(--gray-200);
|
||||
color: var(--text-primary);
|
||||
&[disabled] {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
&.btn-secondary {
|
||||
background: var(--gray-200);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
&.btn-primary {
|
||||
@@ -538,4 +559,4 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user