zs преди 6 месеца
родител
ревизия
9112d594d6
променени са 2 файла, в които са добавени 22 реда и са изтрити 4 реда
  1. 11 2
      src/views/center/password.vue
  2. 11 2
      src/views/login/parts/register.vue

+ 11 - 2
src/views/center/password.vue

@@ -5,7 +5,7 @@
         <el-col :span="24" class="one">
           <el-form label-position="top" ref="ruleFormRef" :model="form" :rules="rules" label-width="80px" class="form">
             <el-form-item label="新密码" prop="password">
-              <el-input size="large" v-model="form.password" type="password" show-password placeholder="请输入新密码">
+              <el-input size="large" v-model="form.password" type="password" show-password placeholder="请输入包含英文字母大小写、数字和特殊符号的 8-16 位组合">
                 <template #prefix>
                   <el-icon>
                     <Unlock />
@@ -56,8 +56,17 @@ const validatePassword = (rule, value, callback) => {
     callback()
   }
 }
+const passwordValValidate = (rule, value, callback) => {
+  if (!value) {
+    return callback(new Error('请输入密码'))
+  } else if (/^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[._~!@#$^&*])[A-Za-z0-9._~!@#$^&*]{8,16}$/g.test(value)) {
+    return callback()
+  } else {
+    return callback(new Error('请输入包含英文字母大小写、数字和特殊符号的 8-16 位组合'))
+  }
+}
 const rules = reactive({
-  password: [{ required: true, message: '请输入新密码', trigger: 'blur' }],
+  password: [{ required: true, validator: passwordValValidate, trigger: 'blur' }],
   refpassword: [{ required: true, validator: validatePassword, trigger: 'blur' }]
 })
 // 修改密码

+ 11 - 2
src/views/login/parts/register.vue

@@ -50,7 +50,7 @@
           </el-input>
         </el-form-item>
         <el-form-item label="密码" prop="password">
-          <el-input size="large" v-model="form.password" type="password" show-password placeholder="请输入登录密码">
+          <el-input size="large" v-model="form.password" type="password" show-password placeholder="请输入包含英文字母大小写、数字和特殊符号的 8-16 位组合">
             <template #prefix>
               <el-icon>
                 <Unlock />
@@ -124,11 +124,20 @@ const validatePhoneNumber = (rule, value, callback) => {
   }
   callback()
 }
+const passwordValValidate = (rule, value, callback) => {
+  if (!value) {
+    return callback(new Error('请输入密码'))
+  } else if (/^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[._~!@#$^&*])[A-Za-z0-9._~!@#$^&*]{8,16}$/g.test(value)) {
+    return callback()
+  } else {
+    return callback(new Error('请输入包含英文字母大小写、数字和特殊符号的 8-16 位组合'))
+  }
+}
 const rules = reactive({
   nick_name: [{ required: true, message: '请输入昵称', trigger: 'blur' }],
   phone: [{ required: true, validator: validatePhoneNumber, trigger: 'blur' }],
   account: [{ required: true, message: '请输入账号', trigger: 'blur' }],
-  password: [{ required: true, message: '请输入密码', trigger: 'blur' }],
+  password: [{ required: true, validator: passwordValValidate, trigger: 'blur' }],
   email: [{ required: true, message: '请输入电子邮箱', trigger: 'blur' }],
   type: [{ required: true, message: '请选择注册类型', trigger: 'blur' }],
   role: [{ required: true, message: '请选择角色', trigger: 'blur' }],