yanghao 2 дней назад
Родитель
Сommit
efdfcb6126
3 измененных файлов с 31 добавлено и 13 удалено
  1. 1 1
      .env.local
  2. 13 3
      src/api/login/index.ts
  3. 17 9
      src/permission.ts

+ 1 - 1
.env.local

@@ -4,7 +4,7 @@ NODE_ENV=development
 VITE_DEV=true
 
 # 请求路径  http://192.168.188.149:48080  https://iot.deepoil.cc
-VITE_BASE_URL='http://192.168.188.198:48080'
+VITE_BASE_URL='https://iot.deepoil.cc'
 
 # 文件上传类型:server - 后端上传, client - 前端直连上传,仅支持 S3 服务
 VITE_UPLOAD_TYPE=server

+ 13 - 3
src/api/login/index.ts

@@ -1,5 +1,6 @@
 import request from '@/config/axios'
 import type { RegisterVO, UserLoginVO } from './types'
+import { head } from 'lodash-es'
 
 export interface SmsCodeVO {
   mobile: string
@@ -16,12 +17,12 @@ export const login = (data: UserLoginVO) => {
   return request.post({ url: '/system/auth/login', data })
 }
 
-export const dingTalkLogin = (data:{code:string,type:number,state:number}) => {
-  return request.post({ url: '/system/auth/h5SocialLogin', data,headers:{'tenant-id':1} })
+export const dingTalkLogin = (data: { code: string; type: number; state: number }) => {
+  return request.post({ url: '/system/auth/h5SocialLogin', data, headers: { 'tenant-id': 1 } })
 }
 
 export const simpleLogin = (id: any) => {
-  return request.post({ url: '/system/auth/simple/login/'+id })
+  return request.post({ url: '/system/auth/simple/login/' + id })
 }
 // 注册
 export const register = (data: RegisterVO) => {
@@ -90,3 +91,12 @@ export const reqCheck = (data: any) => {
 export const smsResetPassword = (data: any) => {
   return request.post({ url: '/system/auth/reset-password', data })
 }
+
+// 门户用户登录
+export const portalLogin = (data: any) => {
+  return request.post({
+    url: 'system/auth/portal/login',
+    headers: { 'portal-secret': 'cc99d802-ce5c-5f62-b037-9a00726e7109' },
+    data
+  })
+}

+ 17 - 9
src/permission.ts

@@ -1,16 +1,16 @@
 import router from './router'
 import type { RouteRecordRaw } from 'vue-router'
 import { isRelogin } from '@/config/axios/service'
-import {getAccessToken} from '@/utils/auth'
+import { getAccessToken } from '@/utils/auth'
 import { useTitle } from '@/hooks/web/useTitle'
 import { useNProgress } from '@/hooks/web/useNProgress'
 import { usePageLoading } from '@/hooks/web/usePageLoading'
 import { useDictStoreWithOut } from '@/store/modules/dict'
 import { useUserStoreWithOut } from '@/store/modules/user'
 import { usePermissionStoreWithOut } from '@/store/modules/permission'
-import * as LoginApi from "@/api/login";
-import * as authUtil from "@/utils/auth";
-
+import * as LoginApi from '@/api/login'
+import * as authUtil from '@/utils/auth'
+import { he } from 'element-plus/es/locale'
 
 const { start, done } = useNProgress()
 
@@ -116,16 +116,24 @@ router.beforeEach(async (to, from, next) => {
       }
     }
   } else {
-    if (whiteList.indexOf(to.path) !== -1) {
-      const code = to.query.code;
+    if (to.fullPath.includes('sso') && to.fullPath.includes('username')) {
+      const res = await LoginApi.portalLogin({
+        username: to.query.username
+      })
+
+      authUtil.setToken(res)
+      await getTenantId()
+      next({ path: 'index' })
+    } else if (whiteList.indexOf(to.path) !== -1) {
+      const code = to.query.code
       if (code) {
         debugger
         await getTenantId()
-        const res = await LoginApi.socialLogin('20', typeof code === "string" ? code :"", '22')
+        const res = await LoginApi.socialLogin('20', typeof code === 'string' ? code : '', '22')
         authUtil.setToken(res)
-        next({ path: 'index' });
+        next({ path: 'index' })
       } else {
-        next(); // 正常导航
+        next() // 正常导航
       }
       // next()
     } else {