Browse Source

等保增加短信

谢杰标 2 năm trước cách đây
mục cha
commit
5219e775a1
2 tập tin đã thay đổi với 68 bổ sung18 xóa
  1. 9 0
      common/httpList/login.js
  2. 59 18
      pages4/login/login.vue

+ 9 - 0
common/httpList/login.js

@@ -157,6 +157,15 @@ export default {
 			noToken: true
 		})
 	},
+	// 三级等保是否需要验证码
+	getDualAuth(data) {
+		return myRequest({
+			url: '/app/common/dual_auth',
+			method: 'get',
+			data: data,
+			noToken: true
+		})
+	},
 	//绑定身份证号信息
 	bindId(data) {
 		return myRequest({

+ 59 - 18
pages4/login/login.vue

@@ -27,13 +27,21 @@
       </view>
       <view class="login_box">
         <u-form :model="form" ref="uForm1" v-show="current == 0">
-          <u-form-item prop="account"
+          <u-form-item prop="account" v-if="!isDualAuth"
             ><u-input
               type="idcard"
               v-model="form.account"
               placeholder-style="color:#999999"
               placeholder="手机号/学员身份证"
           /></u-form-item>
+          <u-form-item prop="account" ref="account" v-else
+            ><u-input
+              type="number"
+              maxlength="11"
+              placeholder-style="color:#999999"
+              v-model="form.account"
+              placeholder="手机号"
+          /></u-form-item>
           <u-form-item prop="pwd"
             ><u-input
               class="password"
@@ -42,6 +50,17 @@
               type="password"
               placeholder="登录密码"
           /></u-form-item>
+          <u-form-item prop="code" v-if="isDualAuth">
+            <u-input
+              v-model="form.code"
+              type="number"
+              placeholder-style="color:#999999"
+              placeholder="验证码"
+            />
+            <u-button slot="right" size="mini" @click="getCode('account')">{{
+              codeTips
+            }}</u-button>
+          </u-form-item>
         </u-form>
         <u-form :model="form" ref="uForm2" v-show="current == 1">
           <u-form-item prop="tel" ref="tel"
@@ -59,7 +78,7 @@
               placeholder-style="color:#999999"
               placeholder="验证码"
             />
-            <u-button slot="right" size="mini" @click="getCode">{{
+            <u-button slot="right" size="mini" @click="getCode('tel')">{{
               codeTips
             }}</u-button>
           </u-form-item>
@@ -182,7 +201,6 @@ export default {
           {
             required: true,
             message: "请输入手机号/学员身份证",
-            // 可以单个或者同时写两个触发验证方式
             trigger: ["change"],
           },
         ],
@@ -210,29 +228,20 @@ export default {
       newUser_sc: "", // 用户扫码进来详情页获取的sc
       shareActivityCode: "", // 用户扫码进来详情页获取的
       isBack: false,
+      isDualAuth: false,
     };
   },
   onLoad(option) {
     if (option.isBack) {
       this.isBack = option.isBack;
     }
-    console.log("登录后的this.isBack:", option.isBack, typeof this.isBack);
-    // else if (option.scanCode) {
-    // 	this.scanCode = option.scanCode
-    // }
-    // this.from = option.from;
     if (uni.getStorageSync("newUser_sc")) {
       this.newUser_sc = uni.getStorageSync("newUser_sc");
     }
     if (uni.getStorageSync("shareActivityCode")) {
       this.shareActivityCode = uni.getStorageSync("shareActivityCode");
     }
-    console.log(
-      "---this.newUser_sc:",
-      this.newUser_sc,
-      "this.shareActivityCode:",
-      this.shareActivityCode
-    );
+    this.getDualAuth();
   },
   onShow() {
     // 获取code
@@ -265,6 +274,29 @@ export default {
         });
       }
     },
+    getDualAuth() {
+      this.$api.getDualAuth().then((res) => {
+        if (res.data.code == 200) {
+          this.isDualAuth = res.data.data * 1;
+          if (this.isDualAuth === 1) {
+            this.rules.account = [
+              {
+                required: true,
+                message: "请输入手机号",
+                trigger: ["change"],
+              },
+              {
+                validator: (rule, value, callback) => {
+                  return this.$u.test.mobile(value);
+                },
+                message: "手机号码格式不正确",
+                trigger: ["change"],
+              },
+            ];
+          }
+        }
+      });
+    },
     wxLogin(e) {
       this.$api
         .wxLogin({
@@ -359,6 +391,15 @@ export default {
         this.$u.toast("请输入密码");
         return;
       }
+
+      if (this.isDualAuth) {
+        if (!this.form.code) {
+          this.$u.toast("请输入验证码");
+          return;
+        }
+        this.form.tel = this.form.account;
+      }
+
       //虚拟登录
       /* that.fakeLogin()
 			return */
@@ -385,11 +426,11 @@ export default {
       this.codeTips = text;
     },
     // 获取验证码
-    getCode() {
+    getCode(key) {
       let that = this;
       if (that.$refs.uCode.canGetCode) {
-        if (that.$refs.tel.validateState == "success") {
-          let datas = { tel: this.form.tel };
+        if (that.$refs[key].validateState == "success") {
+          let datas = { tel: this.form[key] };
           that.$api.loginSms(datas).then(
             (res) => {
               if (res.data.code == 200) {
@@ -405,7 +446,7 @@ export default {
             }
           );
         } else {
-          this.$refs.tel.onFieldChange();
+          this.$refs[key].onFieldChange();
         }
       }
     },