From 1e5c40ca6d5c6bbbd062f5cbdfc31d6045b4b77b Mon Sep 17 00:00:00 2001
From: liuyg <376836862@qq.com>
Date: Tue, 26 Oct 2021 09:01:24 +0800
Subject: [PATCH] 提醒密码为身份证后六位

---
 src/views/securityGuard/securityGuard.vue |   54 ++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 44 insertions(+), 10 deletions(-)

diff --git a/src/views/securityGuard/securityGuard.vue b/src/views/securityGuard/securityGuard.vue
index 43a6590..5732615 100644
--- a/src/views/securityGuard/securityGuard.vue
+++ b/src/views/securityGuard/securityGuard.vue
@@ -337,21 +337,49 @@
     // };
     var date = new Date();
     let year = date.getFullYear(),
-      oldyear;
+      mouth = date.getMonth() + 1,
+      day = date.getDate(),
+      oldy,
+      oldm,
+      oldd,
+      ok = false;
 
     const validatePassCardid = (rule, value, callback) => {
+      // console.log(oldy, oldm, oldd, year - oldy, mouth, day);
       var test =
         /^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/;
       if (!test.test(value)) {
         callback(new Error("请输入正确身份证号码"));
       } else {
         //加入校验18岁到60岁的
-        oldyear = +value.slice(6, 10);
-        if (year - oldyear < 18 || year - oldyear > 60) {
+        oldy = +value.slice(6, 10);
+        oldm = +value.slice(10, 12);
+        oldd = +value.slice(12, 14);
+        ok =
+          year - oldy < 18 || year - oldy > 60
+            ? false
+            : year - oldy == 18
+            ? mouth < oldm
+              ? false
+              : mouth > oldm
+              ? true
+              : day < oldd
+              ? false
+              : true
+            : year - oldy == 60
+            ? mouth < oldm
+              ? true
+              : mouth > oldm
+              ? false
+              : day <= oldd
+              ? false
+              : true
+            : true;
+        if (ok) {
+          callback();
+        } else {
           // callback(new Error("根据国家要求,需在18岁至60岁"));
           callback(new Error("年龄不符"));
-        } else {
-          callback();
         }
       }
     };
@@ -1106,15 +1134,21 @@
           sex: row.sex,
         },
       };
+
       securitySave(userMap).then(
         () => {
           this.initFlag = false;
-          this.onLoad(this.page);
-          this.$message({
-            type: "success",
-            message: "操作成功!",
+          this.$alert("账号为身份证号码,密码为身份证后六位", "温馨提示", {
+            confirmButtonText: "确定",
+            callback: (action) => {
+              this.$message({
+                type: "success",
+                message: `操作成功`,
+              });
+              this.onLoad(this.page);
+              done();
+            },
           });
-          done();
         },
         (error) => {
           window.console.log(error);

--
Gitblit v1.9.3