Browse Source

账号登录只能是邮箱或者是手机号

lifanagju_citu 8 months ago
parent
commit
861e383434
1 changed files with 20 additions and 13 deletions
  1. 20 13
      src/views/login/components/passwordPage.vue

+ 20 - 13
src/views/login/components/passwordPage.vue

@@ -46,25 +46,32 @@ const props = defineProps({ phoneDisabled: Boolean, placeholder: String, validEm
 const passwordType = ref(false)
 const emits = defineEmits(['handleEnter'])
 
-const phoneRules = ref([
-  value => {
-    if (value) return true
-    return props.placeholder ? props.placeholder : '请输入手机号码'
-  },
-  value => {
-    if (value?.length <= 11 && /^1[3456789]\d{9}$/.test(value)) return true
-    return t('login.correctPhoneNumber')
-  }
-])
+const phoneRules = ref([])
 
-// 邮箱效验
 if (props.validEmail) {
-  phoneRules.value.push(
+  // 邮箱效验
+  phoneRules.value = [
+    value => {
+      if (value) return true
+      return props.placeholder ? props.placeholder : '请输入企业邮箱'
+    },
     value => {
       if (checkEmail(value)) return true
       return '请输入正确的企业邮箱'
     }
-  )
+  ]
+} else {
+  // 手机号码效验
+  phoneRules.value = [
+    value => {
+      if (value) return true
+      return props.placeholder ? props.placeholder : '请输入手机号码'
+    },
+    value => {
+      if (value?.length <= 11 && /^1[3456789]\d{9}$/.test(value)) return true
+      return t('login.correctPhoneNumber')
+    }
+  ]
 }
 
 // 手机号区域