|
|
@ -240,7 +240,7 @@ import countryList from "./list.js"; |
|
|
import footerBar from "../../../components/footerBar-cn"; |
|
|
import footerBar from "../../../components/footerBar-cn"; |
|
|
import uniPopupDialogVue from "../../../uni_modules/uni-popup/components/uni-popup-dialog/uni-popup-dialog.vue"; |
|
|
import uniPopupDialogVue from "../../../uni_modules/uni-popup/components/uni-popup-dialog/uni-popup-dialog.vue"; |
|
|
import uniPopup from "../../../uni_modules/uni-popup/components/uni-popup/uni-popup.vue"; |
|
|
import uniPopup from "../../../uni_modules/uni-popup/components/uni-popup/uni-popup.vue"; |
|
|
import {verification} from "../login/verification" |
|
|
|
|
|
|
|
|
import { verificationPhone, verificationEmail } from "../login/verification"; |
|
|
|
|
|
|
|
|
const deepChartID = ref(""); |
|
|
const deepChartID = ref(""); |
|
|
const type = ref("member"); |
|
|
const type = ref("member"); |
|
|
@ -268,7 +268,8 @@ const countries = ref( |
|
|
|
|
|
|
|
|
// 默认选中的国家(中国) |
|
|
// 默认选中的国家(中国) |
|
|
const selectedCountry = ref( |
|
|
const selectedCountry = ref( |
|
|
countries.value.find((country) => country.short === "CN") || countries.value[0] |
|
|
|
|
|
|
|
|
countries.value.find((country) => country.short === "CN") || |
|
|
|
|
|
countries.value[0] |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
// 显示国家选择器 |
|
|
// 显示国家选择器 |
|
|
@ -279,7 +280,7 @@ function showCountryPicker() { |
|
|
), |
|
|
), |
|
|
success: function (res) { |
|
|
success: function (res) { |
|
|
selectedCountry.value = countries.value[res.tapIndex]; |
|
|
selectedCountry.value = countries.value[res.tapIndex]; |
|
|
country.value = selectedCountry.value.code |
|
|
|
|
|
|
|
|
country.value = selectedCountry.value.code; |
|
|
}, |
|
|
}, |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
@ -301,14 +302,12 @@ function switchEmail() { |
|
|
// 切换到邮箱注册 |
|
|
// 切换到邮箱注册 |
|
|
switchType.value = "Email"; |
|
|
switchType.value = "Email"; |
|
|
password.value = ""; |
|
|
password.value = ""; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function switchPhone() { |
|
|
function switchPhone() { |
|
|
// 切换到手机注册 |
|
|
// 切换到手机注册 |
|
|
switchType.value = "Phone"; |
|
|
switchType.value = "Phone"; |
|
|
password.value = ""; |
|
|
password.value = ""; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function register() { |
|
|
function register() { |
|
|
@ -330,7 +329,6 @@ function register() { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (switchType.value === "Phone") { |
|
|
if (switchType.value === "Phone") { |
|
|
// 登录逻辑 |
|
|
// 登录逻辑 |
|
|
if (!phone.value) { |
|
|
if (!phone.value) { |
|
|
@ -348,22 +346,16 @@ function register() { |
|
|
}); |
|
|
}); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
const phoneAll = `${country.value}${phone.value}` |
|
|
|
|
|
console.log("完整手机号"+phoneAll); |
|
|
|
|
|
if(validatePhoneNumber(country.value,phone.value)){ |
|
|
|
|
|
|
|
|
const phoneAll = `${country.value}${phone.value}`; |
|
|
|
|
|
console.log("完整手机号" + phoneAll); |
|
|
|
|
|
if (validatePhoneNumber(country.value, phone.value)) { |
|
|
console.log("登录成功:", phoneAll); |
|
|
console.log("登录成功:", phoneAll); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 发送登录请求 |
|
|
// 发送登录请求 |
|
|
// console.log("登录:", phone.value); |
|
|
// console.log("登录:", phone.value); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (switchType.value === "Email") { |
|
|
if (switchType.value === "Email") { |
|
|
// 登录逻辑 |
|
|
// 登录逻辑 |
|
|
if (!email.value) { |
|
|
if (!email.value) { |
|
|
@ -382,6 +374,18 @@ function register() { |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const bool = verificationEmail(email.value); |
|
|
|
|
|
console.log("验证是否成功", bool); |
|
|
|
|
|
|
|
|
|
|
|
// 检查格式是否正确 |
|
|
|
|
|
if (!bool) { |
|
|
|
|
|
uni.showToast({ |
|
|
|
|
|
title: "邮箱格式不正确", |
|
|
|
|
|
icon: "none", |
|
|
|
|
|
}); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 发送登录请求 |
|
|
// 发送登录请求 |
|
|
console.log("登录:", email.value); |
|
|
console.log("登录:", email.value); |
|
|
} |
|
|
} |
|
|
@ -475,27 +479,48 @@ function onPhoneInput(e) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function sendCode() { |
|
|
function sendCode() { |
|
|
if(switchType.value === "Phone"){ |
|
|
|
|
|
if(!phone.value){ |
|
|
|
|
|
|
|
|
if (switchType.value === "Phone") { |
|
|
|
|
|
if (!phone.value) { |
|
|
uni.showToast({ |
|
|
uni.showToast({ |
|
|
title: "请输入手机号", |
|
|
title: "请输入手机号", |
|
|
icon: "none", |
|
|
icon: "none", |
|
|
}); |
|
|
}); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(switchType.value === "Email"){ |
|
|
|
|
|
if(!email.value){ |
|
|
|
|
|
|
|
|
const bool = verificationPhone(country.value, phone.value); |
|
|
|
|
|
console.log("验证是否成功", bool); |
|
|
|
|
|
|
|
|
|
|
|
// 检查格式是否正确 |
|
|
|
|
|
if (!bool) { |
|
|
uni.showToast({ |
|
|
uni.showToast({ |
|
|
title: "请输入邮箱地址", |
|
|
|
|
|
|
|
|
title: "手机号格式不正确", |
|
|
icon: "none", |
|
|
icon: "none", |
|
|
}); |
|
|
}); |
|
|
return; |
|
|
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; |
|
|
if (isCodeBtnDisabled.value) return; |
|
|
@ -549,7 +574,7 @@ function changeCheckbox() { |
|
|
// 验证手机号是否正确 |
|
|
// 验证手机号是否正确 |
|
|
function validatePhoneNumber(countryCode, phoneNumber) { |
|
|
function validatePhoneNumber(countryCode, phoneNumber) { |
|
|
// 检查是否为空 |
|
|
// 检查是否为空 |
|
|
if (!phoneNumber || phoneNumber.trim() === '') { |
|
|
|
|
|
|
|
|
if (!phoneNumber || phoneNumber.trim() === "") { |
|
|
uni.showToast({ |
|
|
uni.showToast({ |
|
|
title: "手机号不能为空", |
|
|
title: "手机号不能为空", |
|
|
icon: "none", |
|
|
icon: "none", |
|
|
@ -557,8 +582,7 @@ function validatePhoneNumber(countryCode, phoneNumber) { |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const bool = verification(countryCode,phoneNumber) |
|
|
|
|
|
|
|
|
const bool = verificationPhone(countryCode, phoneNumber); |
|
|
console.log("验证是否成功", bool); |
|
|
console.log("验证是否成功", bool); |
|
|
|
|
|
|
|
|
// 检查格式是否正确 |
|
|
// 检查格式是否正确 |
|
|
@ -571,7 +595,7 @@ function validatePhoneNumber(countryCode, phoneNumber) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 去掉+号后检查长度(手机号通常在7到15位之间) |
|
|
// 去掉+号后检查长度(手机号通常在7到15位之间) |
|
|
const cleanNumber = phoneNumber.replace(/^\+/, ''); |
|
|
|
|
|
|
|
|
const cleanNumber = phoneNumber.replace(/^\+/, ""); |
|
|
if (cleanNumber.length < 7 || cleanNumber.length > 15) { |
|
|
if (cleanNumber.length < 7 || cleanNumber.length > 15) { |
|
|
uni.showToast({ |
|
|
uni.showToast({ |
|
|
title: "手机号长度不正确", |
|
|
title: "手机号长度不正确", |
|
|
@ -582,13 +606,6 @@ function validatePhoneNumber(countryCode, phoneNumber) { |
|
|
|
|
|
|
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 部分国家优化手机号验证 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</script> |
|
|
</script> |
|
|
|
|
|
|
|
|
<style scoped> |
|
|
<style scoped> |
|
|
|