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