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 = () => { const scrollToBottom = () => {
if (!shouldAutoScroll.value) return; if (!shouldAutoScroll.value) return;

95
pages/start/recoverPassword/recoverPassword.vue

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

Loading…
Cancel
Save