| | |
| | | data() { |
| | | return { |
| | | codeUrl: "", |
| | | authCode: "", |
| | | cookiePassword: "", |
| | | loginForm: { |
| | | username: "", |
| | |
| | | created() { |
| | | this.getCode(); |
| | | this.getCookie(); |
| | | this.getAuthCode(); |
| | | // this.avoidLogin(); |
| | | }, |
| | | methods: { |
| | | tip() { |
| | |
| | | this.loginForm.uuid = res.uuid; |
| | | } |
| | | }); |
| | | }, |
| | | getAuthCode() { |
| | | this.$dingtalk.runtime.permission.requestAuthCode({ |
| | | corpId: "dingd31f00f4fbc0ff5bf5bf40eda33b7ba0", |
| | | onSuccess: result => { |
| | | // 在这里处理授权成功后的逻辑,result中包含授权码等信息 |
| | | // 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"); |
| | |
| | | .push({ path: this.redirect || "/" }) |
| | | .catch(() => {}); |
| | | } else { |
| | | this.loading = false; |
| | | this.loading = false; |
| | | this.$message.error(this.$store.state.user.msg); |
| | | } |
| | | }) |