完整完成钉钉的三方接入

This commit is contained in:
YunaiV
2021-10-02 23:55:41 +08:00
parent e05d90590e
commit 9be00d6035
23 changed files with 401 additions and 94 deletions

View File

@ -45,7 +45,7 @@
</template>
<script>
import { getCodeImg,thirdLoginRedirect } from "@/api/login";
import { getCodeImg,socialLoginRedirect } from "@/api/login";
import Cookies from "js-cookie";
import { encrypt, decrypt } from '@/utils/jsencrypt'
@ -143,11 +143,11 @@ export default {
// 设置登陆中
this.loading = true;
// 计算 redirectUri
// const redirectUri = location.origin + '/third-login';
const redirectUri = location.origin + '/social-login';
// const redirectUri = 'http://127.0.0.1:48080/api/gitee/callback';
const redirectUri = 'http://127.0.0.1:48080/api/dingtalk/callback';
// const redirectUri = 'http://127.0.0.1:48080/api/dingtalk/callback';
// 进行跳转
thirdLoginRedirect(provider.type, redirectUri).then((res) => {
socialLoginRedirect(provider.type, redirectUri).then((res) => {
// console.log(res.url);
window.location.href = res.data;
});

View File

@ -28,7 +28,7 @@
</template>
<script>
import { thirdLogin } from "@/api/login";
import { socialLogin } from "@/api/login";
import Cookies from "js-cookie";
import { encrypt, decrypt } from '@/utils/jsencrypt'
@ -39,7 +39,7 @@ export default {
loginForm: {
username: "admin",
password: "admin123",
rememberMe: false,
rememberMe: false, // TODO
},
loginRules: {
username: [
@ -68,11 +68,17 @@ export default {
created() {
this.getCookie();
//
this.type = 10;
this.type = 20;
this.code = this.$route.query.code;
this.state = this.$route.query.state;
thirdLogin(this.type, this.code, this.state).then(res => {
debugger
this.$store.dispatch("SocialLogin", {
code: this.code,
state: this.state,
type: this.type
}).then(() => {
this.$router.push({ path: this.redirect || "/" }).catch(()=>{});
}).catch(() => {
this.loading = false;
});
},
methods: {
@ -97,7 +103,13 @@ export default {
Cookies.remove("username");
Cookies.remove("password");
}
this.$store.dispatch("Login", this.loginForm).then(() => {
this.$store.dispatch("SocialLogin2", {
code: this.code,
state: this.state,
type: this.type,
username: this.loginForm.username,
password: this.loginForm.password
}).then(() => {
this.$router.push({ path: this.redirect || "/" }).catch(()=>{});
}).catch(() => {
this.loading = false;