添加邮件验证码登录

This commit is contained in:
lijun 2025-09-27 13:38:14 +08:00
parent 9aa1191a44
commit 91321b44c5
1 changed files with 7 additions and 3 deletions

View File

@ -329,9 +329,13 @@ const thirdLogin = async (type) => {
};
const check_email = (email) => {
const emailReg = /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/;
return emailReg.test(email);
}
const sendCode = async () => {
if (code_login_form.value.email === ""){
ElMessage.error("请输入邮箱地址!");
if (code_login_form.value.email === "" || check_email(code_login_form.value.email) === false) {
ElMessage.error("请输入正确邮箱地址!");
return;
}
let result = await sendLoginCode(code_login_form.value);
@ -352,7 +356,7 @@ const sendCode = async () => {
}
const HandleLoginByCode =async () => {
if(code_login_form.value.email === "" || code_login_form.value.code === ""){
if(code_login_form.value.email === "" || code_login_form.value.code === "" || check_email(code_login_form.value.email) === false){
ElMessage.error("请输入邮箱和验证码!");
return;
}