Merge pull request '解决登录问题' (#9) from anln_deal_issue into main

Reviewed-on: https://git.wishpal.cn/wishpal_ironfan/tiefen_space_h5/pulls/9
This commit is contained in:
yezian 2024-12-04 16:44:08 +08:00
commit 30b28e7f2a
1 changed files with 16 additions and 1 deletions

View File

@ -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 }) {
<LoginBtn
loginInfo={loginInfo}
isLoading={isLoading}
setLoginInfo={setLoginInfo}
handleSubmit={handleSubmit}
type={activeIndex ? "password" : "mobile"}
@ -437,6 +444,7 @@ function Login({ handleLogin }) {
</span>
</div>
<LoginBtn
isLoading={isLoading}
loginInfo={loginInfo}
setLoginInfo={setLoginInfo}
handleSubmit={handleSubmit}
@ -450,7 +458,13 @@ function Login({ handleLogin }) {
);
}
const LoginBtn = ({ loginInfo, setLoginInfo, type, handleSubmit }) => {
const LoginBtn = ({
loginInfo,
setLoginInfo,
type,
handleSubmit,
isLoading,
}) => {
const router = useRouter();
useEffect(() => {}, []);
return (
@ -493,6 +507,7 @@ const LoginBtn = ({ loginInfo, setLoginInfo, type, handleSubmit }) => {
<Button
shape="rounded"
size="middle"
loading={isLoading}
block
onClick={() => handleSubmit(type)}
style={{