|
|
|
@ -327,14 +327,52 @@ function switchPhone() { |
|
|
|
verifyCode.value = ""; |
|
|
|
} |
|
|
|
|
|
|
|
// 登录 |
|
|
|
async function register() { |
|
|
|
if (!basicVerification()) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
const account = changeAccount(); |
|
|
|
|
|
|
|
const res = await LoginApi({ |
|
|
|
loginType: switchType.value, |
|
|
|
account: account, |
|
|
|
verifyCode: verifyCode.value, |
|
|
|
password: password.value, |
|
|
|
useCode: verifyCode.value ? true : false, |
|
|
|
idToken: "", |
|
|
|
}); |
|
|
|
|
|
|
|
const message = res.message; |
|
|
|
if (res.code === 200) { |
|
|
|
// 登录成功 |
|
|
|
uni.showToast({ |
|
|
|
title: "登录成功", |
|
|
|
icon: "success", |
|
|
|
}); |
|
|
|
// 跳转到首页 |
|
|
|
uni.switchTab({ |
|
|
|
url: "/pages/start/index/index", |
|
|
|
}); |
|
|
|
} else { |
|
|
|
// 登录失败 |
|
|
|
uni.showToast({ |
|
|
|
title: message, |
|
|
|
icon: "none", |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 基础验证 |
|
|
|
function basicVerification() { |
|
|
|
if (switchType.value === "User") { |
|
|
|
if (!deepChartID.value) { |
|
|
|
uni.showToast({ |
|
|
|
title: "请输入用户名", |
|
|
|
icon: "none", |
|
|
|
}); |
|
|
|
return; |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
if (!password.value) { |
|
|
|
@ -342,7 +380,7 @@ async function register() { |
|
|
|
title: "请输入密码", |
|
|
|
icon: "none", |
|
|
|
}); |
|
|
|
return; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -353,7 +391,13 @@ async function register() { |
|
|
|
title: "请输入手机号码", |
|
|
|
icon: "none", |
|
|
|
}); |
|
|
|
return; |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
const phoneAll = `${country.value}${phone.value}`; |
|
|
|
console.log("完整手机号" + phoneAll); |
|
|
|
if (!validatePhoneNumber(country.value, phone.value)) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
if (!verifyCode.value) { |
|
|
|
@ -361,16 +405,8 @@ async function register() { |
|
|
|
title: "请输入验证码", |
|
|
|
icon: "none", |
|
|
|
}); |
|
|
|
return; |
|
|
|
} |
|
|
|
const phoneAll = `${country.value}${phone.value}`; |
|
|
|
console.log("完整手机号" + phoneAll); |
|
|
|
if (!validatePhoneNumber(country.value, phone.value)) { |
|
|
|
return; |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
// 发送登录请求 |
|
|
|
// console.log("登录:", phone.value); |
|
|
|
} |
|
|
|
|
|
|
|
if (switchType.value === "Email") { |
|
|
|
@ -380,30 +416,27 @@ async function register() { |
|
|
|
title: "请输入邮箱地址", |
|
|
|
icon: "none", |
|
|
|
}); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if (!verifyCode.value) { |
|
|
|
uni.showToast({ |
|
|
|
title: "请输入验证码", |
|
|
|
icon: "none", |
|
|
|
}); |
|
|
|
return; |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
const bool = verificationEmail(email.value); |
|
|
|
console.log("验证是否成功", bool); |
|
|
|
|
|
|
|
// 检查格式是否正确 |
|
|
|
if (!bool) { |
|
|
|
uni.showToast({ |
|
|
|
title: "邮箱格式不正确", |
|
|
|
icon: "none", |
|
|
|
}); |
|
|
|
return; |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
if (!verifyCode.value) { |
|
|
|
uni.showToast({ |
|
|
|
title: "请输入验证码", |
|
|
|
icon: "none", |
|
|
|
}); |
|
|
|
return false; |
|
|
|
} |
|
|
|
// 发送登录请求 |
|
|
|
// console.log("登录:", email.value); |
|
|
|
} |
|
|
|
|
|
|
|
if (!agreed.value) { |
|
|
|
@ -412,43 +445,57 @@ async function register() { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// 如果已经同意,则继续登录流程 |
|
|
|
// uni.showToast({ |
|
|
|
// title: "登录成功", |
|
|
|
// icon: "success", |
|
|
|
// }); |
|
|
|
|
|
|
|
const account = changeAccount(); |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
const res = await LoginApi({ |
|
|
|
loginType: switchType.value, |
|
|
|
account: account, |
|
|
|
verifyCode: verifyCode.value, |
|
|
|
password: password.value, |
|
|
|
useCode: verifyCode.value ? true : false, |
|
|
|
idToken: "", |
|
|
|
// 注册码码验证 |
|
|
|
function VerCodeVerfifcation() { |
|
|
|
if (switchType.value === "Phone") { |
|
|
|
if (!phone.value) { |
|
|
|
uni.showToast({ |
|
|
|
title: "请输入手机号", |
|
|
|
icon: "none", |
|
|
|
}); |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
const message = res.message; |
|
|
|
if (res.code === 200) { |
|
|
|
// 登录成功 |
|
|
|
const bool = verificationPhone(country.value, phone.value); |
|
|
|
console.log("验证是否成功", bool); |
|
|
|
|
|
|
|
// 检查格式是否正确 |
|
|
|
if (!bool) { |
|
|
|
uni.showToast({ |
|
|
|
title: "登录成功", |
|
|
|
icon: "success", |
|
|
|
title: "手机号格式不正确", |
|
|
|
icon: "none", |
|
|
|
}); |
|
|
|
// 跳转到首页 |
|
|
|
uni.switchTab({ |
|
|
|
url: "/pages/start/index/index", |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (switchType.value === "Email") { |
|
|
|
if (!email.value) { |
|
|
|
uni.showToast({ |
|
|
|
title: "请输入邮箱地址", |
|
|
|
icon: "none", |
|
|
|
}); |
|
|
|
} else { |
|
|
|
// 登录失败 |
|
|
|
return false; |
|
|
|
} |
|
|
|
const bool = verificationEmail(email.value); |
|
|
|
console.log("验证是否成功", bool); |
|
|
|
|
|
|
|
// 检查格式是否正确 |
|
|
|
if (!bool) { |
|
|
|
uni.showToast({ |
|
|
|
title: message, |
|
|
|
title: "邮箱格式不正确", |
|
|
|
icon: "none", |
|
|
|
}); |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
function changeAccount() { |
|
|
|
if (switchType.value === "User") { |
|
|
|
account.value = deepChartID.value; |
|
|
|
@ -545,49 +592,10 @@ function onPhoneInput(e) { |
|
|
|
} |
|
|
|
|
|
|
|
async function sendCode() { |
|
|
|
if (switchType.value === "Phone") { |
|
|
|
if (!phone.value) { |
|
|
|
uni.showToast({ |
|
|
|
title: "请输入手机号", |
|
|
|
icon: "none", |
|
|
|
}); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
const bool = verificationPhone(country.value, phone.value); |
|
|
|
console.log("验证是否成功", bool); |
|
|
|
|
|
|
|
// 检查格式是否正确 |
|
|
|
if (!bool) { |
|
|
|
uni.showToast({ |
|
|
|
title: "手机号格式不正确", |
|
|
|
icon: "none", |
|
|
|
}); |
|
|
|
if (!VerCodeVerfifcation()) { |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (switchType.value === "Email") { |
|
|
|
if (!email.value) { |
|
|
|
uni.showToast({ |
|
|
|
title: "请输入邮箱地址", |
|
|
|
icon: "none", |
|
|
|
}); |
|
|
|
return; |
|
|
|
} |
|
|
|
const bool = verificationEmail(email.value); |
|
|
|
console.log("验证是否成功", bool); |
|
|
|
|
|
|
|
// 检查格式是否正确 |
|
|
|
if (!bool) { |
|
|
|
uni.showToast({ |
|
|
|
title: "邮箱格式不正确", |
|
|
|
icon: "none", |
|
|
|
}); |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 如果按钮已禁用,则不执行后续逻辑 |
|
|
|
if (isCodeBtnDisabled.value) return; |
|
|
|
|
|
|
|
@ -1045,8 +1053,6 @@ function validatePhoneNumber(countryCode, phoneNumber) { |
|
|
|
width: 550rpx; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.popup-message { |
|
|
|
font-size: 28rpx; |
|
|
|
color: #000000; |
|
|
|
|