diff --git a/app/login/page.js b/app/login/page.js index 5da505f..4b23a28 100644 --- a/app/login/page.js +++ b/app/login/page.js @@ -35,6 +35,7 @@ function Login({ handleLogin }) { const [activeIndex, setActiveIndex] = useState(0); const [veriCode, setVeriCode] = useState(""); const [isCounting, setIsCounting] = useState(false); + const [isLoading, setIsLoading] = useState(false); const [seconds, setSeconds] = useState(60); const [deviceType, setDeviceType] = useState(""); const [loginInfo, setLoginInfo] = useState({ @@ -145,6 +146,7 @@ function Login({ handleLogin }) { ...body, veri_code: veriCode, }; + setIsLoading(true); try { const data = await requireAPI( "POST", @@ -155,7 +157,9 @@ function Login({ handleLogin }) { body, } ); + if (data.ret === -1) { + setIsLoading(false); Toast.show({ icon: "fail", content: data.msg, @@ -172,12 +176,14 @@ function Login({ handleLogin }) { } else { save("firstLogin", 0); } + setIsLoading(false); router.push( !data?.data?.is_enabled && type != "password" ? "/my/setting/editPassword?is_enabled=" + data?.data?.is_enabled : "/" ); } catch (error) { + setIsLoading(false); // console.error(error); } }; @@ -349,6 +355,7 @@ function Login({ handleLogin }) { { +const LoginBtn = ({ + loginInfo, + setLoginInfo, + type, + handleSubmit, + isLoading, +}) => { const router = useRouter(); useEffect(() => {}, []); return ( @@ -493,6 +507,7 @@ const LoginBtn = ({ loginInfo, setLoginInfo, type, handleSubmit }) => {