From 8022f7036945b75f82f2dfc43055623f81ed98f6 Mon Sep 17 00:00:00 2001
From: yxh <172933527@qq.com>
Date: 星期五, 23 五月 2025 22:42:56 +0800
Subject: [PATCH] yxh

---
 src/views/login.vue |   78 +++++++++++++++++++++++++++++++++------
 1 files changed, 66 insertions(+), 12 deletions(-)

diff --git a/src/views/login.vue b/src/views/login.vue
index 02932ef..aac1184 100644
--- a/src/views/login.vue
+++ b/src/views/login.vue
@@ -96,7 +96,8 @@
   data() {
     return {
       codeUrl: "",
-      cookiePassword: "", 
+      authCode: "",
+      cookiePassword: "",
       loginForm: {
         username: "",
         password: "",
@@ -137,6 +138,8 @@
   created() {
     this.getCode();
     this.getCookie();
+    this.getAuthCode();
+    // this.avoidLogin();
   },
   methods: {
     tip() {
@@ -151,6 +154,47 @@
           this.loginForm.uuid = res.uuid;
         }
       });
+    },
+    getAuthCode() {
+      this.$dingtalk.runtime.permission.requestAuthCode({
+        corpId: "dingd31f00f4fbc0ff5bf5bf40eda33b7ba0",
+        onSuccess: result => {
+          // 鍦ㄨ繖閲屽鐞嗘巿鏉冩垚鍔熷悗鐨勯�昏緫锛宺esult涓寘鍚巿鏉冪爜绛変俊鎭�
+          // this.authCode = result.codde;
+          this.$message.success("鎴愬姛鑾峰彇鎺堟潈鐮侊細" + result.code);
+          this.avoidLogin(result.code);
+        },
+        onFail: err => {
+          // 鍦ㄨ繖閲屽鐞嗘巿鏉冨け璐ュ悗鐨勯�昏緫
+          this.$message({
+            type: "error",
+            message: err
+          });
+        }
+      });
+    },
+    avoidLogin(authCode) {
+      this.loading = true;
+      // this.$message.error(authCode, "1鍙蜂綅");
+      this.loginForm.authCode = authCode;
+      this.$store
+        .dispatch("Login", this.loginForm)
+        .then(res => {
+          if (this.$store.state.user.code == 200) {
+            this.$router.push({ path: this.redirect || "/" }).catch(() => {});
+          } else {
+            this.loading = false;
+            // this.$message.error(this.$store.state.user.msg);
+          }
+        })
+        .catch(err => {
+          console.log(err);
+          this.loading = false;
+          this.$message.error("鍏嶇櫥闄嗗け璐ヨ鎵嬪姩鎿嶄綔銆�");
+          if (this.captchaOnOff) {
+            this.getCode();
+          }
+        });
     },
     getCookie() {
       const username = Cookies.get("username");
@@ -182,10 +226,20 @@
           }
           this.$store
             .dispatch("Login", this.loginForm)
-            .then(() => {
-              this.$router.push({ path: this.redirect || "/" }).catch(() => {});
+            .then(res => {
+              console.log(this.$store.state.user.code, "44");
+              console.log(this.$store.state.user.msg, "22");
+              if (this.$store.state.user.code == 200) {
+                this.$router
+                  .push({ path: this.redirect || "/" })
+                  .catch(() => {});
+              } else {
+                this.loading = false;
+                this.$message.error(this.$store.state.user.msg);
+              }
             })
-            .catch(() => {
+            .catch(err => {
+              console.log(err);
               this.loading = false;
               // this.$message.error("鐧婚檰澶辫触璇烽噸璇曘��");
               if (this.captchaOnOff) {
@@ -206,14 +260,14 @@
   align-items: center;
   height: 100%;
   background-position: center center;
-/* 鑳屾櫙鍥句笉骞抽摵 */
-background-repeat: no-repeat;
-/* 褰撳唴瀹归珮搴﹀ぇ浜庡浘鐗囬珮搴︽椂锛岃儗鏅浘鍍忕殑浣嶇疆鐩稿浜巚iewport鍥哄畾 */
-background-attachment: fixed;
-/* 璁╄儗鏅浘鍩轰簬瀹瑰櫒澶у皬浼哥缉 */
-background-size: cover;
-/* 璁剧疆鑳屾櫙棰滆壊锛岃儗鏅浘鍔犺浇杩囩▼涓細鏄剧ず鑳屾櫙鑹� */
-background-color: #464646;
+  /* 鑳屾櫙鍥句笉骞抽摵 */
+  background-repeat: no-repeat;
+  /* 褰撳唴瀹归珮搴﹀ぇ浜庡浘鐗囬珮搴︽椂锛岃儗鏅浘鍍忕殑浣嶇疆鐩稿浜巚iewport鍥哄畾 */
+  background-attachment: fixed;
+  /* 璁╄儗鏅浘鍩轰簬瀹瑰櫒澶у皬浼哥缉 */
+  background-size: cover;
+  /* 璁剧疆鑳屾櫙棰滆壊锛岃儗鏅浘鍔犺浇杩囩▼涓細鏄剧ず鑳屾櫙鑹� */
+  background-color: #464646;
   background-image: url("../assets/images/login-bgc.jpg");
   background-size: cover;
 }

--
Gitblit v1.9.3