fix: wrong loading state while top up

This commit is contained in:
wzxjohn
2025-07-10 20:31:40 +08:00
parent e8ae980104
commit d6ed2ab3e0

View File

@@ -168,6 +168,7 @@ const TopUp = () => {
showError(t('管理员未开启在线充值!')); showError(t('管理员未开启在线充值!'));
return; return;
} }
setPayWay(payment);
setPaymentLoading(true); setPaymentLoading(true);
try { try {
await getAmount(); await getAmount();
@@ -175,7 +176,6 @@ const TopUp = () => {
showError(t('充值数量不能小于') + minTopUp); showError(t('充值数量不能小于') + minTopUp);
return; return;
} }
setPayWay(payment);
setOpen(true); setOpen(true);
} catch (error) { } catch (error) {
showError(t('获取金额失败')); showError(t('获取金额失败'));
@@ -193,7 +193,6 @@ const TopUp = () => {
return; return;
} }
setConfirmLoading(true); setConfirmLoading(true);
setOpen(false);
try { try {
const res = await API.post('/api/user/pay', { const res = await API.post('/api/user/pay', {
amount: parseInt(topUpCount), amount: parseInt(topUpCount),
@@ -234,6 +233,7 @@ const TopUp = () => {
console.log(err); console.log(err);
showError(t('支付请求失败')); showError(t('支付请求失败'));
} finally { } finally {
setOpen(false);
setConfirmLoading(false); setConfirmLoading(false);
} }
}; };
@@ -255,7 +255,6 @@ const TopUp = () => {
} catch (error) { } catch (error) {
showError(t('获取金额失败')); showError(t('获取金额失败'));
} finally { } finally {
setPayWay('')
setPaymentLoading(false); setPaymentLoading(false);
} }
}; };