| | |
| | | * 第三方登录 |
| | | * @param source 第三方登录类型 |
| | | * */ |
| | | export function socialLogin(source: string, tenantId: string, loginType: string, code: any, state: any): AxiosPromise<any> { |
| | | export function socialLogin(source: string, tenantId: string, code: any, state: any): AxiosPromise<any> { |
| | | const data = { |
| | | code, |
| | | state, |
| | | socialCode: code, |
| | | socialState: state, |
| | | source, |
| | | tenantId, |
| | | loginType, |
| | | clientId: 'e5cd7e4891bf95d1d19206ce24a7b32e', |
| | | grantType: 'social' |
| | | }; |
| | | return request({ |
| | | url: '/auth/social-login', |
| | | method: 'get', |
| | | params: data |
| | | method: 'post', |
| | | data: data |
| | | }); |
| | | } |
| | | |
| | |
| | | const state = route.query.state; |
| | | const source = route.query.source as string; |
| | | const tenantId = Cookies.get("tenantId") ? Cookies.get("tenantId") as string : '000000'; |
| | | const loginType = getToken() ? 'register' : 'login'; |
| | | |
| | | /** |
| | | * 通过code获取token |
| | |
| | | * @param {string} code |
| | | * @param {string} state |
| | | */ |
| | | await socialLogin(source, tenantId, loginType, code, state) |
| | | await socialLogin(source, tenantId, code, state) |
| | | .then(async (res) => { |
| | | if (res.code !== 200) { |
| | | ElMessage.error(res.msg); |
| | |
| | | return; |
| | | } |
| | | loading.value = false; |
| | | // setToken(res.msg); |
| | | loginType === 'login' ? setToken(res.data) : ElMessage.success(res.msg); |
| | | setToken(res.data.access_token) |
| | | ElMessage.success(res.msg); |
| | | location.href = import.meta.env.VITE_APP_CONTEXT_PATH + 'index'; |
| | | |
| | | }) |
| | | .catch(() => { |
| | | loading.value = false; |