Browse Source

授权登录修改

duy 1 day ago
parent
commit
51dd5777df
1 changed files with 38 additions and 2 deletions
  1. 38 2
      src/views/login/index.vue

+ 38 - 2
src/views/login/index.vue

@@ -72,14 +72,15 @@ import HcPicVue from './components/pic.vue'
 import HcHomeBg from './components/home-bg.vue'
 import { getTenantID } from '~api/user'
 import { getTopUrl } from '~uti/tools'
-import { formValidate, getObjVal, setImageColorStyle } from 'js-fast-way'
+import { formValidate, getObjVal, getObjValue, setImageColorStyle } from 'js-fast-way'
 import website from '~src/config'
 import notableform from '~src/assets/view/notableform.svg'
 import { getStoreValue } from '~uti/storage'
-
+import { useRoute, useRouter } from 'vue-router'
 const userStore = useAppStore()
 userStore.clearStoreData() //先清理下缓存
 
+const useRoutes = useRoute()
 //系统信息
 const appLogoIcon = ref('')
 const appLogoName = ref('')
@@ -93,9 +94,44 @@ const accountClick = () => {
 }
 
 onMounted(() => {
+ // 调用函数获取 token
+const gfzxtoken = getGfzxToken()
+if (gfzxtoken) {
+    userStore.setTokenVal(gfzxtoken)
+    //处理授权登录
+    router.push({ path: '/auth-token-gfzx', query: { 'gfzx-token': gfzxtoken } })
+    return
+    
+}
     getTenantIdApi()
     setAppImageColor()
 })
+// 在组件中获取 gfzx-token
+const getGfzxToken = () => {
+  // 获取当前页面的 URL
+  const currentUrl = window.location.href
+  
+  // 解析 URL
+  const url = new URL(currentUrl)
+
+  
+  // 获取 hash 部分(因为你的参数在 # 后面)
+  const search = url.search
+  
+
+  const queryString = search.split('?')[1] || ''
+  console.log(queryString, 'queryString')
+  
+  // 解析查询参数
+  const params = new URLSearchParams(queryString)
+
+  
+  // 获取 gfzx-token 的值
+  const gfzxToken = params.get('gfzx-token')
+  
+  return gfzxToken
+}
+
 
 const setAppImageColor = () => {
     setImageColorStyle('logo-icon', '#1ECC95')