浏览代码

fix: 修改密码校验手机号问题修复

liangan 2 周之前
父节点
当前提交
771554cde0
共有 1 个文件被更改,包括 10 次插入8 次删除
  1. 10 8
      src/pages/forgotPassword/forgotPassword.vue

+ 10 - 8
src/pages/forgotPassword/forgotPassword.vue

@@ -49,10 +49,11 @@ async function getVerificationCode() {
     return
   }
 
-  // 验证手机号格式
-  const phoneRegex = /^1[3-9]\d{9}$/
-  if (!phoneRegex.test(formData.value.phone)) {
-    toast.error(t('auth.forgotPassword.error.invalidPhone'))
+  // 孟加拉手机号校验:可接受本地格式 01xxxxxxxxx (11 位) 或去掉前导 0 的 1xxxxxxxxx (10 位)
+  const phoneDigits = formData.value.phone.replace(/\D/g, '')
+  const bdPhoneRegex = /^0?1\d{9}$/
+  if (!bdPhoneRegex.test(phoneDigits)) {
+    toast.error(t('auth.register.error.invalidPhone'))
     return
   }
 
@@ -98,10 +99,11 @@ function handleStep1() {
     return
   }
 
-  // 验证手机号格式
-  const phoneRegex = /^1[3-9]\d{9}$/
-  if (!phoneRegex.test(formData.value.phone)) {
-    toast.error(t('auth.forgotPassword.error.invalidPhone'))
+  // 孟加拉手机号校验:可接受本地格式 01xxxxxxxxx (11 位) 或去掉前导 0 的 1xxxxxxxxx (10 位)
+  const phoneDigits = formData.value.phone.replace(/\D/g, '')
+  const bdPhoneRegex = /^0?1\d{9}$/
+  if (!bdPhoneRegex.test(phoneDigits)) {
+    toast.error(t('auth.register.error.invalidPhone'))
     return
   }