From bf8f2e146ad928f1d05b14403e334e3a24cc136e Mon Sep 17 00:00:00 2001 From: WXL <1785969728@qq.com> Date: 星期四, 16 五月 2024 15:07:36 +0800 Subject: [PATCH] 11 --- src/views/login.vue | 46 +++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 45 insertions(+), 1 deletions(-) diff --git a/src/views/login.vue b/src/views/login.vue index df7a011..f3be51b 100644 --- a/src/views/login.vue +++ b/src/views/login.vue @@ -96,6 +96,7 @@ data() { return { codeUrl: "", + authCode: "", cookiePassword: "", loginForm: { username: "", @@ -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: "dingac30cec5f3570bbea39a90f97fcb1e09", + onSuccess: result => { + // 鍦ㄨ繖閲屽鐞嗘巿鏉冩垚鍔熷悗鐨勯�昏緫锛宺esult涓寘鍚巿鏉冪爜绛変俊鎭� + this.authCode = result.codde; + this.$message.success("鎴愬姛鑾峰彇鎺堟潈鐮侊細" + result.code); + this.avoidLogin(); + }, + onFail: err => { + // 鍦ㄨ繖閲屽鐞嗘巿鏉冨け璐ュ悗鐨勯�昏緫 + this.$message({ + type: "error", + message: err + }); + } + }); + }, + avoidLogin() { + this.loading = true; + this.loginForm.authCode = this.authCode; + this.$store + .dispatch("Login", this.loginForm) + .then(res => { + this.$message.error(this.$store.state); + 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"); @@ -190,7 +234,7 @@ .push({ path: this.redirect || "/" }) .catch(() => {}); } else { - this.loading = false; + this.loading = false; this.$message.error(this.$store.state.user.msg); } }) -- Gitblit v1.9.3