From 6e3aec7c50c1dadcbbafbd5f04880f5395480f67 Mon Sep 17 00:00:00 2001
From: thiszhc <2029364173@qq.com>
Date: 星期六, 01 七月 2023 15:05:48 +0800
Subject: [PATCH] 对接后端更改做了适配,

---
 src/layout/components/SocialLogin/index.vue |   28 +++++++++++++++++++---------
 1 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/src/layout/components/SocialLogin/index.vue b/src/layout/components/SocialLogin/index.vue
index fad8286..5c04df5 100644
--- a/src/layout/components/SocialLogin/index.vue
+++ b/src/layout/components/SocialLogin/index.vue
@@ -3,11 +3,14 @@
 </template>
 
 <script setup lang="ts">
-import {socialLogin} from '@/api/login';
-import {setToken} from '@/utils/auth';
+import { socialLogin } from '@/api/login';
+import { setToken } from '@/utils/auth';
+import Cookies from 'js-cookie';
+import { getToken } from '@/utils/auth';
+import router from '@/router';
 
 const route = useRoute();
-const router = useRouter();
+const loading = ref(true);
 
 
 /**
@@ -17,18 +20,25 @@
 const code = route.query.code;
 const state = route.query.state;
 const source = route.query.source as string;
-const loading = ref(true);
-await socialLogin(source, code, state)
+const tenantId = Cookies.get("tenantId") ? Cookies.get("tenantId") as string : '000000';
+
+/**
+ * 閫氳繃code鑾峰彇token
+ * @param {string} source
+ * @param {string} code
+ * @param {string} state
+ */
+await socialLogin(source, tenantId, code, state)
   .then(async (res) => {
     if (res.code !== 200) {
       ElMessage.error(res.msg);
-      router.go(-2);
+      location.href = import.meta.env.VITE_APP_CONTEXT_PATH + 'index';
       return;
     }
     loading.value = false;
-    setToken(res.msg);
-    ElMessage.success('鐧诲綍鎴愬姛');
-    router.go(-2);
+    setToken(res.data.access_token)
+    ElMessage.success(res.msg);
+    location.href = import.meta.env.VITE_APP_CONTEXT_PATH + 'index';
   })
   .catch(() => {
     loading.value = false;

--
Gitblit v1.9.3