mirror of
https://github.com/PlayEdu/h5.git
synced 2025-07-25 11:51:01 +08:00
登录验证码去除
This commit is contained in:
parent
aaa4a1f1fb
commit
64187eb2f6
@ -1,16 +1,9 @@
|
|||||||
import client from "./internal/httpClient";
|
import client from "./internal/httpClient";
|
||||||
|
|
||||||
export function login(
|
export function login(email: string, password: string) {
|
||||||
email: string,
|
|
||||||
password: string,
|
|
||||||
captchaKey: string,
|
|
||||||
captchaVal: string
|
|
||||||
) {
|
|
||||||
return client.post("/api/v1/auth/login/password", {
|
return client.post("/api/v1/auth/login/password", {
|
||||||
email: email,
|
email: email,
|
||||||
password: password,
|
password: password,
|
||||||
captcha_key: captchaKey,
|
|
||||||
captcha_val: captchaVal,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,11 +22,6 @@
|
|||||||
height: auto;
|
height: auto;
|
||||||
position: relative;
|
position: relative;
|
||||||
.alert-message {
|
.alert-message {
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
bottom: 0;
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 211px;
|
height: 211px;
|
||||||
background: rgba(0, 0, 0);
|
background: rgba(0, 0, 0);
|
||||||
|
@ -19,27 +19,14 @@ const LoginPage = () => {
|
|||||||
const [image, setImage] = useState<string>("");
|
const [image, setImage] = useState<string>("");
|
||||||
const [email, setEmail] = useState<string>("");
|
const [email, setEmail] = useState<string>("");
|
||||||
const [password, setPassword] = useState<string>("");
|
const [password, setPassword] = useState<string>("");
|
||||||
const [captchaVal, setCaptchaVal] = useState<string>("");
|
|
||||||
const [captchaKey, setCaptchaKey] = useState<string>("");
|
|
||||||
const [captchaLoading, setCaptchaLoading] = useState(true);
|
|
||||||
const [bodyHeight, setBodyHeight] = useState<number>(0);
|
const [bodyHeight, setBodyHeight] = useState<number>(0);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchImageCaptcha();
|
|
||||||
document.title = "登录";
|
document.title = "登录";
|
||||||
let value = document.documentElement.clientHeight;
|
let value = document.documentElement.clientHeight;
|
||||||
setBodyHeight(value);
|
setBodyHeight(value);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const fetchImageCaptcha = () => {
|
|
||||||
setCaptchaLoading(true);
|
|
||||||
system.imageCaptcha().then((res: any) => {
|
|
||||||
setImage(res.data.image);
|
|
||||||
setCaptchaKey(res.data.key);
|
|
||||||
setCaptchaLoading(false);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const loginSubmit = async (e: any) => {
|
const loginSubmit = async (e: any) => {
|
||||||
if (!email) {
|
if (!email) {
|
||||||
Toast.show({
|
Toast.show({
|
||||||
@ -53,18 +40,6 @@ const LoginPage = () => {
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!captchaVal) {
|
|
||||||
Toast.show({
|
|
||||||
content: "请输入图形验证码",
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (captchaVal.length < 4) {
|
|
||||||
Toast.show({
|
|
||||||
content: "图形验证码错误",
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
await handleSubmit();
|
await handleSubmit();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -74,7 +49,7 @@ const LoginPage = () => {
|
|||||||
}
|
}
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
let res: any = await login.login(email, password, captchaKey, captchaVal);
|
let res: any = await login.login(email, password);
|
||||||
setToken(res.data.token); //将token写入本地
|
setToken(res.data.token); //将token写入本地
|
||||||
await getSystemConfig(); //获取系统配置并写入store
|
await getSystemConfig(); //获取系统配置并写入store
|
||||||
await getUser(); //获取登录用户的信息并写入store
|
await getUser(); //获取登录用户的信息并写入store
|
||||||
@ -83,8 +58,6 @@ const LoginPage = () => {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("错误信息", e);
|
console.error("错误信息", e);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
setCaptchaVal("");
|
|
||||||
fetchImageCaptcha(); //刷新图形验证码
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -155,34 +128,10 @@ const LoginPage = () => {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className={styles["captcha-box"]}>
|
|
||||||
<Input
|
|
||||||
value={captchaVal}
|
|
||||||
className={styles["input-item"]}
|
|
||||||
placeholder="请输入图形验证码"
|
|
||||||
onChange={(val) => {
|
|
||||||
setCaptchaVal(val);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<div className={styles["captcha-button"]}>
|
|
||||||
{captchaLoading && (
|
|
||||||
<div className={styles["catpcha-loading-box"]}>
|
|
||||||
<SpinLoading color="primary" />
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{!captchaLoading && (
|
|
||||||
<Image
|
|
||||||
className={styles["captcha"]}
|
|
||||||
onClick={fetchImageCaptcha}
|
|
||||||
src={image}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className={styles["button-box"]}>
|
<div className={styles["button-box"]}>
|
||||||
<Button
|
<Button
|
||||||
className={styles["primary-button"]}
|
className={styles["primary-button"]}
|
||||||
disabled={captchaVal === "" || email === "" || password === ""}
|
disabled={email === "" || password === ""}
|
||||||
color="primary"
|
color="primary"
|
||||||
loading={loading}
|
loading={loading}
|
||||||
onClick={loginSubmit}
|
onClick={loginSubmit}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user