Sfoglia il codice sorgente

fix: wrong loading state while top up

wzxjohn 8 mesi fa
parent
commit
d6ed2ab3e0
1 ha cambiato i file con 2 aggiunte e 3 eliminazioni
  1. 2 3
      web/src/pages/TopUp/index.js

+ 2 - 3
web/src/pages/TopUp/index.js

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