From e654306e8d4a837c4dbe64b5a69bf4083c6b04b2 Mon Sep 17 00:00:00 2001 From: ovo Date: Thu, 5 Dec 2024 22:40:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B3=A8=E5=86=8C=E7=95=8C?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/RegisterView.vue | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/views/RegisterView.vue b/src/views/RegisterView.vue index 35e9d64..0682bf7 100644 --- a/src/views/RegisterView.vue +++ b/src/views/RegisterView.vue @@ -91,7 +91,7 @@ {{ phoneCooldown > 0 ? `${phoneCooldown}s` : '获取验证码' }} @@ -297,7 +297,17 @@ const startEmailCooldown = () => { // 发送手机验证码 const sendPhoneCode = () => { - if (phoneCooldown.value > 0) return + if (phoneCooldown.value > 0 || !registerForm.phone) { + ElMessage.warning('请先输入手机号') + return + } + + // 验证手机号格式 + if (!/^1[3-9]\d{9}$/.test(registerForm.phone)) { + ElMessage.warning('请输入正确的手机号') + return + } + // 这里添加发送验证码的逻辑 ElMessage.success('手机验证码已发送') startPhoneCooldown()