From 6e3aec7c50c1dadcbbafbd5f04880f5395480f67 Mon Sep 17 00:00:00 2001 From: thiszhc <2029364173@qq.com> Date: Sat, 1 Jul 2023 15:05:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E6=8E=A5=E5=90=8E=E7=AB=AF=E6=9B=B4?= =?UTF-8?q?=E6=94=B9=E5=81=9A=E4=BA=86=E9=80=82=E9=85=8D=EF=BC=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/login.ts | 11 +++++------ src/layout/components/SocialLogin/index.vue | 8 +++----- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/api/login.ts b/src/api/login.ts index f60406c..655d6c9 100644 --- a/src/api/login.ts +++ b/src/api/login.ts @@ -66,20 +66,19 @@ export function getCodeImg(): AxiosPromise { * 第三方登录 * @param source 第三方登录类型 * */ -export function socialLogin(source: string, tenantId: string, loginType: string, code: any, state: any): AxiosPromise { +export function socialLogin(source: string, tenantId: string, code: any, state: any): AxiosPromise { 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 }); } diff --git a/src/layout/components/SocialLogin/index.vue b/src/layout/components/SocialLogin/index.vue index 82fb253..5c04df5 100644 --- a/src/layout/components/SocialLogin/index.vue +++ b/src/layout/components/SocialLogin/index.vue @@ -21,7 +21,6 @@ const code = route.query.code; 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 @@ -29,7 +28,7 @@ const loginType = getToken() ? 'register' : 'login'; * @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); @@ -37,10 +36,9 @@ await socialLogin(source, tenantId, loginType, code, state) 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;