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