zhangjie 2 years ago
parent
commit
23baec7206
2 changed files with 34 additions and 28 deletions
  1. 8 2
      src/modules/login/views/Login.vue
  2. 26 26
      src/plugins/formRules.js

+ 8 - 2
src/modules/login/views/Login.vue

@@ -137,7 +137,7 @@
 </template>
 
 <script>
-import { strictPassword, phone, smscode } from "@/plugins/formRules";
+import { phone, smscode } from "@/plugins/formRules";
 import { login, getSmsCode, getSchoolInfo, getAccountSmsCode } from "../api";
 import { Base64 } from "@/plugins/crypto";
 import ResetPwd from "@/modules/base/components/ResetPwd";
@@ -161,7 +161,13 @@ export default {
       },
       loginRules: {
         code: smscode,
-        password: strictPassword,
+        password: [
+          {
+            required: true,
+            message: "请输入密码",
+            trigger: "change",
+          },
+        ],
         loginName: [
           {
             required: true,

+ 26 - 26
src/plugins/formRules.js

@@ -45,37 +45,37 @@ const strictPassword = [
       if (!value) {
         return callback(new Error(`请输入密码`));
       }
-      // 禁止使用相同的数字或字符作为密码
-      const reg2 = /^[a-zA-Z0-9].+$/;
-      const vals = new Set(value.split(""));
-      if (reg2.test(value) && vals.size === 1) {
-        return callback(new Error(`禁止使用相同的数字或字符作为密码`));
-      }
-      // 禁止使用连续升序或降序的数字或字母作为密码
-      const valCharCodes = value.split("").map((item) => item.charCodeAt());
-      let intervals = [];
-      for (let i = 0; i < valCharCodes.length; i++) {
-        const element = valCharCodes[i];
-        if (i === 0) continue;
-        intervals.push(element - valCharCodes[i - 1]);
-      }
-      const interVals = Array.from(new Set(intervals));
-      if (
-        reg2.test(value) &&
-        interVals.length === 1 &&
-        Math.abs(interVals[0]) === 1
-      ) {
-        return callback(
-          new Error(`禁止使用连续升序或降序的数字或字母作为密码`)
-        );
-      }
+      // // 禁止使用相同的数字或字符作为密码
+      // const reg2 = /^[a-zA-Z0-9].+$/;
+      // const vals = new Set(value.split(""));
+      // if (reg2.test(value) && vals.size === 1) {
+      //   return callback(new Error(`禁止使用相同的数字或字符作为密码`));
+      // }
+      // // 禁止使用连续升序或降序的数字或字母作为密码
+      // const valCharCodes = value.split("").map((item) => item.charCodeAt());
+      // let intervals = [];
+      // for (let i = 0; i < valCharCodes.length; i++) {
+      //   const element = valCharCodes[i];
+      //   if (i === 0) continue;
+      //   intervals.push(element - valCharCodes[i - 1]);
+      // }
+      // const interVals = Array.from(new Set(intervals));
+      // if (
+      //   reg2.test(value) &&
+      //   interVals.length === 1 &&
+      //   Math.abs(interVals[0]) === 1
+      // ) {
+      //   return callback(
+      //     new Error(`禁止使用连续升序或降序的数字或字母作为密码`)
+      //   );
+      // }
       // 密码应至少包含数字、大小写字母及特殊宇符中的两种;
       const reg1 =
-        /^(?![\d]+$)(?![a-z]+$)(?![A-Z]+$)(?![!#$%^&*]+$)[\da-zA-Z!#$%^&*]{8,20}$/g;
+        /^(?![\d]+$)(?![a-z]+$)(?![A-Z]+$)(?![!@#$%^&*]+$)[\da-zA-Z!@#$%^&*]{8,20}$/g;
       if (!reg1.test(value)) {
         return callback(
           new Error(
-            `密码应至少包含数字、大小写字母及特殊宇符中的两种,长度8-20位;`
+            `密码应至少包含数字、大小写字母及特殊宇符(!@#$%^&*)中的两种,长度8-20位;`
           )
         );
       }