This commit is contained in:
parent
8e9db7850c
commit
237fa4902c
|
|
@ -88,9 +88,9 @@ export function MixSignUp(props: {
|
|||
setTransferLoading(false);
|
||||
}, []);
|
||||
|
||||
const signUpWithCode = async (username: string, password: string) => {
|
||||
const signUpWithOutCode = async (username: string, password: string) => {
|
||||
|
||||
console.log("-------------username---------", username, "-------------password---------", password);
|
||||
console.log("--username:", username, "--password:", password);
|
||||
|
||||
if (
|
||||
isLoading ||
|
||||
|
|
@ -98,51 +98,37 @@ export function MixSignUp(props: {
|
|||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
setIsLoading(true)
|
||||
|
||||
try {
|
||||
await service.post('/api/v1/common/auth-code', {
|
||||
user_name: username,
|
||||
email: username,
|
||||
}).then(function (result: any) {
|
||||
setIsLoading(false);
|
||||
console.log("==================> result:", result);
|
||||
|
||||
// 如果返回的header中的code不为0,表示失败
|
||||
if (result && result.header.code !== 0) {
|
||||
toast.error(result.header.message); // 提示错误信息
|
||||
return;
|
||||
}
|
||||
|
||||
props.password(password); // 设置密码
|
||||
toast.success(result.header.message); // 提示成功信息
|
||||
props.setVerification(true); // 更新状态
|
||||
|
||||
}).catch((err: any) => {
|
||||
setIsLoading(false);
|
||||
|
||||
// 更详细的错误信息
|
||||
if (err.response) {
|
||||
// 如果是网络请求返回的错误(如 4xx 或 5xx 错误)
|
||||
console.error("Response Error:", err.response);
|
||||
toast.error(`API 错误: ${err.response.status} - ${err.response.data.message || '未知错误'}`);
|
||||
} else if (err.request) {
|
||||
// 如果请求没有响应
|
||||
console.error("Request Error:", err.request);
|
||||
toast.error("请求超时或无法连接到服务器");
|
||||
} else {
|
||||
// 其他错误(如代码错误)
|
||||
console.error("General Error:", err.message);
|
||||
toast.error(`发生了一个错误: ${err.message}`);
|
||||
}
|
||||
});
|
||||
} catch (err) {
|
||||
await service.post('/api/v1/customer/uregister', {
|
||||
user_name: emailValue,
|
||||
email: emailValue,
|
||||
password: md5(passwordValue),
|
||||
}).then(function (result: any) {
|
||||
setIsLoading(false);
|
||||
console.error("Unexpected Error:", err);
|
||||
toast.error("发生了一个意外错误");
|
||||
}
|
||||
|
||||
console.log("result:", result)
|
||||
|
||||
if (result && result.header.code != 0) {
|
||||
|
||||
toast.error(result.header.message)
|
||||
return
|
||||
}
|
||||
|
||||
toast.success(result.header.message)
|
||||
|
||||
router.push("/auth/sign-in");
|
||||
// 自身方法
|
||||
// localStorage.setItem("data", JSON.stringify(result.data));
|
||||
// []方法
|
||||
{ {/* localStorage["name"]="bonly"; */ } }
|
||||
|
||||
}).catch((err: any) => {
|
||||
setIsLoading(false);
|
||||
console.log(err);
|
||||
|
||||
});
|
||||
|
||||
|
||||
};
|
||||
|
||||
return (
|
||||
|
|
@ -158,7 +144,7 @@ export function MixSignUp(props: {
|
|||
return null;
|
||||
}
|
||||
|
||||
console.log("------1", regname)
|
||||
console.log("--regname:", regname)
|
||||
props.email(regname)
|
||||
|
||||
setGoPassword(true)
|
||||
|
|
@ -215,11 +201,11 @@ export function MixSignUp(props: {
|
|||
console.log("------1", props.emailValue, password, confirmPassword)
|
||||
|
||||
if (typeof password !== "string" || password != confirmPassword) {
|
||||
toast.error("two passwords do not match")
|
||||
toast.error("The two passwords you entered do not match.")
|
||||
return
|
||||
}
|
||||
|
||||
await signUpWithCode(props.emailValue, password)
|
||||
await signUpWithOutCode(props.emailValue, password)
|
||||
|
||||
setGoPassword(false)
|
||||
}} >
|
||||
|
|
|
|||
Loading…
Reference in New Issue