|
|
@ -149,9 +149,10 @@ |
|
|
<button class="register-btn" @click="register">注册</button> |
|
|
<button class="register-btn" @click="register">注册</button> |
|
|
|
|
|
|
|
|
<!-- 或者 --> |
|
|
<!-- 或者 --> |
|
|
<text class="or-text" @click="goToLogin">已有账号? |
|
|
|
|
|
|
|
|
<text class="or-text" @click="goToLogin" |
|
|
|
|
|
>已有账号? |
|
|
<text class="link">登录</text> |
|
|
<text class="link">登录</text> |
|
|
</text> |
|
|
|
|
|
|
|
|
</text> |
|
|
|
|
|
|
|
|
<!-- 同意弹窗 --> |
|
|
<!-- 同意弹窗 --> |
|
|
<uniPopup ref="agreementPopup" type="dialog"> |
|
|
<uniPopup ref="agreementPopup" type="dialog"> |
|
|
@ -184,6 +185,11 @@ import countryList from "../login/list"; |
|
|
import footerBar from "../../../components/footerBar-cn.vue"; |
|
|
import footerBar from "../../../components/footerBar-cn.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 { verificationPhone, verificationEmail } from "../login/verification"; |
|
|
import { verificationPhone, verificationEmail } from "../login/verification"; |
|
|
|
|
|
import { |
|
|
|
|
|
registerApi, |
|
|
|
|
|
SendEmailCodeApi, |
|
|
|
|
|
SendPhoneCodeApi, |
|
|
|
|
|
} from "../../../api/start/login"; |
|
|
|
|
|
|
|
|
const type = ref("member"); |
|
|
const type = ref("member"); |
|
|
const email = ref(""); |
|
|
const email = ref(""); |
|
|
@ -247,39 +253,76 @@ function switchPhone() { |
|
|
verifyCode.value = ""; |
|
|
verifyCode.value = ""; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// function register() { |
|
|
|
|
|
// if (switchType.value === "Email") { |
|
|
|
|
|
// // 登录逻辑 |
|
|
|
|
|
// if (!email.value) { |
|
|
|
|
|
// uni.showToast({ |
|
|
|
|
|
// title: "请输入邮箱地址", |
|
|
|
|
|
// icon: "none", |
|
|
|
|
|
// }); |
|
|
|
|
|
// return; |
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
// // 发送登录请求 |
|
|
|
|
|
// console.log("登录:", email.value); |
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
// if (switchType.value === "Phone") { |
|
|
|
|
|
// // 登录逻辑 |
|
|
|
|
|
// if (!phone.value) { |
|
|
|
|
|
// uni.showToast({ |
|
|
|
|
|
// title: "请输入手机号码", |
|
|
|
|
|
// icon: "none", |
|
|
|
|
|
// }); |
|
|
|
|
|
// return; |
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
// // 发送登录请求 |
|
|
|
|
|
// console.log("登录:", phone.value); |
|
|
|
|
|
// } |
|
|
|
|
|
// } |
|
|
|
|
|
function register() { |
|
|
|
|
|
|
|
|
// 注册 |
|
|
|
|
|
async function register() { |
|
|
if (!basicVerification()) { |
|
|
if (!basicVerification()) { |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const account = changeAccount(); |
|
|
|
|
|
const registerType = changeLoginType(); |
|
|
|
|
|
|
|
|
|
|
|
const res = await registerApi({ |
|
|
|
|
|
registerType: registerType, |
|
|
|
|
|
account: account, |
|
|
|
|
|
verifyCode: verifyCode.value, |
|
|
|
|
|
agree: agreed.value, |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const message = res.message; |
|
|
|
|
|
if (res.code === 200) { |
|
|
|
|
|
// 登录成功 |
|
|
|
|
|
uni.showToast({ |
|
|
|
|
|
title: "注册成功", |
|
|
|
|
|
icon: "success", |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const userStore = useUserStore(); |
|
|
|
|
|
userStore.setUserInfo(res.data); |
|
|
|
|
|
|
|
|
|
|
|
console.log("userInfo为", userStore.userInfo); |
|
|
|
|
|
|
|
|
|
|
|
// 跳转到首页 |
|
|
|
|
|
uni.navigateTo({ |
|
|
|
|
|
url: "/pages/home/home", |
|
|
|
|
|
}); |
|
|
|
|
|
} else { |
|
|
|
|
|
// 登录失败 |
|
|
|
|
|
uni.showToast({ |
|
|
|
|
|
title: message, |
|
|
|
|
|
icon: "none", |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 请求账户 |
|
|
|
|
|
function changeAccount() { |
|
|
|
|
|
if (switchType.value === "User") { |
|
|
|
|
|
account.value = deepChartID.value; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (switchType.value === "Phone") { |
|
|
|
|
|
account.value = `${country.value}${phone.value}`; |
|
|
|
|
|
} |
|
|
|
|
|
if (switchType.value === "Email") { |
|
|
|
|
|
account.value = email.value; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return account.value; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 改变请求时的type |
|
|
|
|
|
function changeLoginType() { |
|
|
|
|
|
if (switchType.value === "User") { |
|
|
|
|
|
return "DCCODE"; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (switchType.value === "Phone") { |
|
|
|
|
|
return "PHONE"; |
|
|
|
|
|
} |
|
|
|
|
|
if (switchType.value === "Email") { |
|
|
|
|
|
return "EMAIL"; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 基础验证 |
|
|
// 基础验证 |
|
|
@ -367,8 +410,8 @@ function basicVerification() { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 验证码验证 |
|
|
// 验证码验证 |
|
|
function VerCodeVerfifcation() { |
|
|
|
|
|
if (switchType.value === "Phone") { |
|
|
|
|
|
|
|
|
function VerCodeVerfifcation() { |
|
|
|
|
|
if (switchType.value === "Phone") { |
|
|
if (!phone.value) { |
|
|
if (!phone.value) { |
|
|
uni.showToast({ |
|
|
uni.showToast({ |
|
|
title: "请输入手机号", |
|
|
title: "请输入手机号", |
|
|
@ -432,16 +475,47 @@ function onPhoneInput(e) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function sendCode() { |
|
|
|
|
|
|
|
|
|
|
|
if (!VerCodeVerfifcation()) { |
|
|
|
|
|
return ; |
|
|
|
|
|
|
|
|
async function sendCode() { |
|
|
|
|
|
if (!VerCodeVerfifcation()) { |
|
|
|
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 如果按钮已禁用,则不执行后续逻辑 |
|
|
// 如果按钮已禁用,则不执行后续逻辑 |
|
|
if (isCodeBtnDisabled.value) return; |
|
|
if (isCodeBtnDisabled.value) return; |
|
|
|
|
|
|
|
|
|
|
|
console.log("发送验证码"); |
|
|
|
|
|
if (switchType.value === "Phone") { |
|
|
|
|
|
// 发送验证码 |
|
|
|
|
|
|
|
|
|
|
|
const phoneAll = `${country.value}${phone.value}`; |
|
|
|
|
|
const res = await SendPhoneCodeApi({ |
|
|
|
|
|
phone: phoneAll, |
|
|
|
|
|
}); |
|
|
|
|
|
console.log("手机验证码:", res.message); |
|
|
|
|
|
|
|
|
|
|
|
if (!res) { |
|
|
|
|
|
uni.showToast({ |
|
|
|
|
|
title: "请求失败", |
|
|
|
|
|
icon: "none", |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (switchType.value === "Email") { |
|
|
|
|
|
// 发送验证码 |
|
|
|
|
|
const res = await SendEmailCodeApi({ |
|
|
|
|
|
email: email.value, |
|
|
|
|
|
}); |
|
|
|
|
|
console.log("邮箱验证码:", res.message); |
|
|
|
|
|
|
|
|
|
|
|
if (!res) { |
|
|
|
|
|
uni.showToast({ |
|
|
|
|
|
title: "请求失败", |
|
|
|
|
|
icon: "none", |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 设置按钮为禁用状态 |
|
|
// 设置按钮为禁用状态 |
|
|
isCodeBtnDisabled.value = true; |
|
|
isCodeBtnDisabled.value = true; |
|
|
codeBtnText.value = "重新发送"; |
|
|
codeBtnText.value = "重新发送"; |
|
|
|