|
@ -24,7 +24,6 @@ const Login = memo(() => { |
|
|
const { mutate: upLoginFun } = useAtomValue(upLoginAtom); |
|
|
const { mutate: upLoginFun } = useAtomValue(upLoginAtom); |
|
|
const [emailCodeData, setEmailCodeData] = useState({}); |
|
|
const [emailCodeData, setEmailCodeData] = useState({}); |
|
|
const { mutate: emailLoginMutate } = useAtomValue(emailLoginAtom); |
|
|
const { mutate: emailLoginMutate } = useAtomValue(emailLoginAtom); |
|
|
const { mutate: telegramCodeMutate } = useAtomValue(telegramCodeAtom); |
|
|
|
|
|
const { mutate: telegramLoginMutate } = useAtomValue(telegramLoginAtom); |
|
|
const { mutate: telegramLoginMutate } = useAtomValue(telegramLoginAtom); |
|
|
|
|
|
|
|
|
const uphandleSubmit = (values: any) => { |
|
|
const uphandleSubmit = (values: any) => { |
|
@ -32,21 +31,19 @@ const Login = memo(() => { |
|
|
upLoginFun(values); |
|
|
upLoginFun(values); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
const getEmailCode = () => { |
|
|
|
|
|
|
|
|
const getEmailCode = async () => { |
|
|
const email = emailform.getFieldValue("email"); |
|
|
const email = emailform.getFieldValue("email"); |
|
|
setCountdown(10); |
|
|
|
|
|
setIsButtonDisabled(true); |
|
|
|
|
|
setEmailCodeData(systemServ.emailCode({ is_register: false, email })); |
|
|
|
|
|
|
|
|
const result = await systemServ.emailCode({ is_register: false, email }); |
|
|
|
|
|
setEmailCodeData(result); |
|
|
}; |
|
|
}; |
|
|
const emailhandleSubmit = (values: any) => { |
|
|
const emailhandleSubmit = (values: any) => { |
|
|
emailLoginMutate(values); |
|
|
emailLoginMutate(values); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
const getTelegramCode = () => { |
|
|
|
|
|
|
|
|
const getTelegramCode = async () => { |
|
|
const telegram = telegramform.getFieldValue("telegram"); |
|
|
const telegram = telegramform.getFieldValue("telegram"); |
|
|
setCountdown(10); |
|
|
|
|
|
setIsButtonDisabled(true); |
|
|
|
|
|
telegramCodeMutate({ telegram }); |
|
|
|
|
|
|
|
|
const result = await systemServ.telegramCode({ telegram }); |
|
|
|
|
|
setEmailCodeData(result); |
|
|
}; |
|
|
}; |
|
|
const telegramhandleSubmit = (values: any) => { |
|
|
const telegramhandleSubmit = (values: any) => { |
|
|
telegramLoginMutate(values); |
|
|
telegramLoginMutate(values); |
|
@ -63,20 +60,24 @@ const Login = memo(() => { |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
useEffect(() => { |
|
|
localStorage.setItem("countdown", String(countdown)); |
|
|
|
|
|
}, [countdown]); |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
localStorage.setItem("isButtonDisabled", JSON.stringify(isButtonDisabled)); |
|
|
localStorage.setItem("isButtonDisabled", JSON.stringify(isButtonDisabled)); |
|
|
}, [isButtonDisabled]); |
|
|
}, [isButtonDisabled]); |
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
useEffect(() => { |
|
|
|
|
|
if ((emailCodeData as any)?.code === 0) { |
|
|
|
|
|
setCountdown(10); |
|
|
|
|
|
setIsButtonDisabled(true); |
|
|
|
|
|
} |
|
|
|
|
|
}, [emailCodeData]); |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
let timer: number; |
|
|
let timer: number; |
|
|
if (countdown > 0) { |
|
|
if (countdown > 0) { |
|
|
timer = setTimeout(() => setCountdown(countdown - 1), 1000); |
|
|
timer = setTimeout(() => setCountdown(countdown - 1), 1000); |
|
|
} else { |
|
|
} else { |
|
|
setIsButtonDisabled(false); |
|
|
setIsButtonDisabled(false); |
|
|
} |
|
|
} |
|
|
|
|
|
localStorage.setItem("countdown", String(countdown)); |
|
|
return () => clearTimeout(timer); |
|
|
return () => clearTimeout(timer); |
|
|
}, [countdown]); |
|
|
}, [countdown]); |
|
|
|
|
|
|
|
|