对接后端更改做了适配,

This commit is contained in:
thiszhc 2023-07-01 15:05:48 +08:00
parent 2b7ffdf19c
commit 6e3aec7c50
2 changed files with 8 additions and 11 deletions

View File

@ -66,20 +66,19 @@ export function getCodeImg(): AxiosPromise<VerifyCodeResult> {
* *
* @param source * @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 = { const data = {
code, socialCode: code,
state, socialState: state,
source, source,
tenantId, tenantId,
loginType,
clientId: 'e5cd7e4891bf95d1d19206ce24a7b32e', clientId: 'e5cd7e4891bf95d1d19206ce24a7b32e',
grantType: 'social' grantType: 'social'
}; };
return request({ return request({
url: '/auth/social-login', url: '/auth/social-login',
method: 'get', method: 'post',
params: data data: data
}); });
} }

View File

@ -21,7 +21,6 @@ const code = route.query.code;
const state = route.query.state; const state = route.query.state;
const source = route.query.source as string; const source = route.query.source as string;
const tenantId = Cookies.get("tenantId") ? Cookies.get("tenantId") as string : '000000'; const tenantId = Cookies.get("tenantId") ? Cookies.get("tenantId") as string : '000000';
const loginType = getToken() ? 'register' : 'login';
/** /**
* 通过code获取token * 通过code获取token
@ -29,7 +28,7 @@ const loginType = getToken() ? 'register' : 'login';
* @param {string} code * @param {string} code
* @param {string} state * @param {string} state
*/ */
await socialLogin(source, tenantId, loginType, code, state) await socialLogin(source, tenantId, code, state)
.then(async (res) => { .then(async (res) => {
if (res.code !== 200) { if (res.code !== 200) {
ElMessage.error(res.msg); ElMessage.error(res.msg);
@ -37,10 +36,9 @@ await socialLogin(source, tenantId, loginType, code, state)
return; return;
} }
loading.value = false; loading.value = false;
// setToken(res.msg); setToken(res.data.access_token)
loginType === 'login' ? setToken(res.data) : ElMessage.success(res.msg); ElMessage.success(res.msg);
location.href = import.meta.env.VITE_APP_CONTEXT_PATH + 'index'; location.href = import.meta.env.VITE_APP_CONTEXT_PATH + 'index';
}) })
.catch(() => { .catch(() => {
loading.value = false; loading.value = false;