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()