Browse Source

优化找回密码页面验证逻辑

wangyi/feature-20251022162725-启动页登录注册
Ethereal 4 weeks ago
parent
commit
309bb64c6c
  1. 7
      pages/deepMate/deepMate.vue
  2. 95
      pages/start/recoverPassword/recoverPassword.vue

7
pages/deepMate/deepMate.vue

@ -566,13 +566,6 @@ watch(messages, (arr) => {
}
});
// isSending
watch(isSending, (newVal, oldVal) => {
console.log(`isSending changed from ${oldVal} to ${newVal}`);
// isSending
// UI
});
//
const scrollToBottom = () => {
if (!shouldAutoScroll.value) return;

95
pages/start/recoverPassword/recoverPassword.vue

@ -46,7 +46,7 @@
<view v-else class="switch-container-occupy"> </view>
<!-- 输入框 -->
<view v-if="isRecovering" class="input-container">
<view v-if="switchType === 'Email'">
<view >
<!-- 修改邮箱输入框容器将图标包含在内 -->
<view class="input-with-icon">
<image
@ -56,6 +56,7 @@
/>
<input
class="input-field"
:type="newPasswordLookFirst ? 'text' : 'password'"
placeholder="输入新密码"
v-model="newPasswordFirst"
@ -78,6 +79,7 @@
alt=""
/>
<input
class="input-field"
:type="newPasswordLookSecond ? 'text' : 'password'"
placeholder="再次确认"
@ -136,7 +138,7 @@
class="input-field"
type="text"
placeholder="请输入验证码"
v-model="password"
v-model="verifyCode"
/>
</view>
</view>
@ -182,7 +184,7 @@
class="input-field"
type="text"
placeholder="请输入验证码"
v-model="password"
v-model="verifyCode"
/>
</view>
</view>
@ -246,6 +248,7 @@ const { safeAreaInsets } = uni.getSystemInfoSync();
const codeBtnText = ref("获取验证码");
const isCodeBtnDisabled = ref(false); //
const checkboxUrl = ref("../../../static/icons/Check-one-false.png");
const verifyCode = ref("");
const isRecovering = ref(false);
const newPasswordLookFirst = ref(false);
const newPasswordLookSecond = ref(false);
@ -287,18 +290,18 @@ function goToBack() {
function switchEmail() {
//
switchType.value = "Email";
verifyCode.value = "";
}
function switchPhone() {
//
switchType.value = "Phone";
verifyCode.value = "";
}
function register() {
if (isRecovering.value) {
if(!newPasswordFirst.value || !newPasswordSecond.value){
if (!newPasswordFirst.value || !newPasswordSecond.value) {
uni.showToast({
title: "密码不能为空",
icon: "none",
@ -317,6 +320,7 @@ function register() {
//
return;
}
if (switchType.value === "Phone") {
//
if (!phone.value) {
@ -327,21 +331,22 @@ function register() {
return;
}
if (!password.value) {
console.log("123");
const phoneAll = `${country.value}${phone.value}`;
console.log("完整手机号" + phoneAll);
if (!validatePhoneNumber(country.value, phone.value)) {
return;
}
if (!verifyCode.value) {
uni.showToast({
title: "请输入验证码",
icon: "none",
});
return;
}
const phoneAll = `${country.value}${phone.value}`;
console.log("完整手机号" + phoneAll);
if (validatePhoneNumber(country.value, phone.value)) {
console.log("登录成功:", phoneAll);
}
//
// console.log(":", phone.value);
}
if (switchType.value === "Email") {
@ -354,14 +359,6 @@ function register() {
return;
}
if (!password.value) {
uni.showToast({
title: "请输入验证码",
icon: "none",
});
return;
}
const bool = verificationEmail(email.value);
console.log("验证是否成功", bool);
@ -374,12 +371,18 @@ function register() {
return;
}
if (!verifyCode.value) {
uni.showToast({
title: "请输入验证码",
icon: "none",
});
return;
}
//
console.log("登录:", email.value);
}
isRecovering.value = !isRecovering.value;
//
@ -407,36 +410,15 @@ function onPhoneInput(e) {
}
}
// function sendCode() {
// //
// if (isCodeBtnDisabled.value) return;
// //
// isCodeBtnDisabled.value = true;
// codeBtnText.value = "";
// let time = 6;
// const timer = setInterval(() => {
// time--;
// codeBtnText.value = " " + time + "S";
// if (time <= 0) {
// clearInterval(timer);
// codeBtnText.value = "";
// //
// isCodeBtnDisabled.value = false;
// }
// }, 1000);
// return;
// }
function sendCode() {
//
function VerCodeVerfifcation() {
if (switchType.value === "Phone") {
if (!phone.value) {
uni.showToast({
title: "请输入手机号",
icon: "none",
});
return;
return false;
}
const bool = verificationPhone(country.value, phone.value);
@ -448,7 +430,7 @@ function sendCode() {
title: "手机号格式不正确",
icon: "none",
});
return;
return false;
}
}
@ -458,7 +440,7 @@ function sendCode() {
title: "请输入邮箱地址",
icon: "none",
});
return;
return false;
}
const bool = verificationEmail(email.value);
console.log("验证是否成功", bool);
@ -469,10 +451,18 @@ function sendCode() {
title: "邮箱格式不正确",
icon: "none",
});
return;
return false;
}
}
return true;
}
//
function sendCode() {
if (!VerCodeVerfifcation()) {
return;
}
//
if (isCodeBtnDisabled.value) return;
@ -537,6 +527,7 @@ function validatePhoneNumber(countryCode, phoneNumber) {
title: "手机号格式不正确",
icon: "none",
});
return false;
}

Loading…
Cancel
Save