year hace 2 semanas
padre
commit
58b298f5bb
Se han modificado 1 ficheros con 15 adiciones y 8 borrados
  1. 15 8
      src/app/[locale]/(TabBar)/deposit/component/withdraw/index.tsx

+ 15 - 8
src/app/[locale]/(TabBar)/deposit/component/withdraw/index.tsx

@@ -51,6 +51,7 @@ const Withdraw = () => {
     const gameModelRef = React.useRef<ModalProps>(null);
     const game = React.useRef<GameListRep | null>(null);
     const pointModelRef = React.useRef<ModalProps | null>(null);
+    const loadingRef = React.useRef<any>(null);
 
     React.useEffect(() => {
         getData();
@@ -229,15 +230,17 @@ const Withdraw = () => {
             return;
         }
 
-        if (wallet.point > 0) {
-            pointModelRef.current?.onOpen();
-            return;
-        }
-
+        // if (wallet.point > 0) {
+        //     pointModelRef.current?.onOpen();
+        //     return;
+        // }
+        loadingRef.current = Toast.show({ icon: "loading", duration: 0 });
         const { data } = await userInfoApi();
 
         // 如果有未完成游戏
         if (data.play_list && data.play_list.length > 0) {
+            loadingRef.current?.close();
+            loadingRef.current = null;
             game.current = data.play_list[0];
             gameModelRef.current?.onOpen();
             return;
@@ -247,7 +250,9 @@ const Withdraw = () => {
     };
 
     const extractHandler = async () => {
-        const loadingRef = Toast.show({ icon: "loading", duration: 0 });
+        if (!loadingRef.current) {
+            loadingRef.current = Toast.show({ icon: "loading", duration: 0 });
+        }
         try {
             const values = formInstanceRef.current?.getFieldsValue();
             const { passport, name, last_name, amount, account_no } = values;
@@ -263,13 +268,15 @@ const Withdraw = () => {
             };
 
             const withResult = await getWithDrawApi(params);
-            loadingRef.close();
+            loadingRef.current?.close();
+            loadingRef.current = null;
             if (withResult && withResult.code === 200) {
                 Toast.show(t("code.200"));
             }
             await clearWallet();
         } catch (error: any) {
-            loadingRef.close();
+            loadingRef.current?.close();
+            loadingRef.current = null;
             Toast.show(t(`code.${error.data.code}`));
         }
     };