登录添加加载状态
This commit is contained in:
parent
08520b0b4f
commit
923bd04f34
|
@ -23,6 +23,7 @@ export default function PasswordLogin() {
|
|||
const [regionCode, setRegionCode] = useState("86");
|
||||
const [mobilePhone, setMobilePhone] = useState("");
|
||||
const [password, setPassword] = useState("");
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
|
||||
//获取之前缓存的用户的手机号
|
||||
useEffect(() => {
|
||||
|
@ -88,6 +89,7 @@ export default function PasswordLogin() {
|
|||
password: encryptedPassword,
|
||||
...base,
|
||||
});
|
||||
setIsLoading(true);
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${apiUrl}/api/login/login_by_pswd?signature=${signature}`,
|
||||
|
@ -111,6 +113,7 @@ export default function PasswordLogin() {
|
|||
text1: data.msg,
|
||||
topOffset: 60,
|
||||
});
|
||||
setIsLoading(false);
|
||||
return;
|
||||
}
|
||||
//保存账号信息,用于切换账号
|
||||
|
@ -122,9 +125,11 @@ export default function PasswordLogin() {
|
|||
account: data.data.account,
|
||||
login_time: new Date().getTime(),
|
||||
});
|
||||
setIsLoading(false);
|
||||
//登录
|
||||
signIn(data, mobilePhone, regionCode);
|
||||
} catch (error) {
|
||||
setIsLoading(false);
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
@ -216,6 +221,7 @@ export default function PasswordLogin() {
|
|||
color="#FF669E"
|
||||
radius="999"
|
||||
size="md"
|
||||
loading={isLoading}
|
||||
onPress={handleSubmit}
|
||||
titleStyle={tailwind("text-base font-medium")}
|
||||
containerStyle={tailwind("mt-2")}
|
||||
|
|
|
@ -20,7 +20,7 @@ export default function PhoneNumLogin() {
|
|||
//重新获取验证码的计时器
|
||||
const [isCounting, setIsCounting] = useState(false);
|
||||
const [seconds, setSeconds] = useState(60);
|
||||
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
//保存区号、手机号、验证码
|
||||
const [regionCode, setRegionCode] = useState("86");
|
||||
const [mobilePhone, setMobilePhone] = useState("");
|
||||
|
@ -140,6 +140,7 @@ export default function PhoneNumLogin() {
|
|||
inviter: inviterCode,
|
||||
...base,
|
||||
});
|
||||
setIsLoading(true);
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${apiUrl}/api/login/login_by_veri_code?signature=${signature}`,
|
||||
|
@ -159,6 +160,7 @@ export default function PhoneNumLogin() {
|
|||
);
|
||||
const data = await response.json();
|
||||
if (data.ret === -1) {
|
||||
setIsLoading(false);
|
||||
Toast.show({
|
||||
type: "error",
|
||||
text1: data.msg,
|
||||
|
@ -176,6 +178,7 @@ export default function PhoneNumLogin() {
|
|||
});
|
||||
//若已经设置了密码则直接登录
|
||||
if (data.data.is_enabled) {
|
||||
setIsLoading(false);
|
||||
signIn(data, mobilePhone, regionCode);
|
||||
return;
|
||||
}
|
||||
|
@ -184,6 +187,7 @@ export default function PhoneNumLogin() {
|
|||
await save("account", data.data.account);
|
||||
await save("mobile_phone", mobile_phone);
|
||||
await save("region_code", regionCode);
|
||||
setIsLoading(false);
|
||||
navigation.navigate("SetPassword", {
|
||||
data: data,
|
||||
mobile_phone: mobile_phone,
|
||||
|
@ -191,6 +195,7 @@ export default function PhoneNumLogin() {
|
|||
mobilePhone: mobilePhone,
|
||||
});
|
||||
} catch (error) {
|
||||
setIsLoading(false);
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
@ -287,6 +292,7 @@ export default function PhoneNumLogin() {
|
|||
color="#FF669E"
|
||||
radius="999"
|
||||
size="md"
|
||||
loading={isLoading}
|
||||
onPress={handleSubmit}
|
||||
titleStyle={tailwind("text-base font-medium")}
|
||||
containerStyle={tailwind("mt-2")}
|
||||
|
|
Loading…
Reference in New Issue