Эх сурвалжийг харах

修改跳转4s项目的方式

Alfyn 2 долоо хоног өмнө
parent
commit
5c3b487a57

+ 7 - 0
src/api/user.js

@@ -131,4 +131,11 @@ export function operationLogList(params) {
     method: 'get',
     params
   })
+}
+
+export function get4SLoginToken() {
+  return request({
+    url: `/user/get4sAccessToken`,
+    method: 'get',
+  })
 }

+ 12 - 20
src/permission.js

@@ -6,9 +6,9 @@ import NProgress from 'nprogress' // progress bar
 import '@/components/NProgress/nprogress.less' // progress bar custom style
 import notification from 'ant-design-vue/es/notification'
 import { setDocumentTitle, domTitle } from '@/utils/domUtil'
-import { userInfo } from '@/api/headerInfo/index.js'
-import {  fileBimView } from '@/api/document/index.js'
-import { ACCESS_TOKEN,TENANT_ID } from '@/store/mutation-types'
+import { get4SLoginToken } from '@/api/user.js'
+import { fileBimView } from '@/api/document/index.js'
+import { ACCESS_TOKEN, TENANT_ID } from '@/store/mutation-types'
 import { i18nRender } from '@/locales'
 
 NProgress.configure({ showSpinner: false }) // NProgress Configuration
@@ -99,25 +99,17 @@ router.beforeEach(async (to, from, next) => {
           })
       } else {
         if (to.path === '/4S') {
-          const {
-            data: { name, fs_password },
-          } = await userInfo()
-          axios
-            .post(`http://newlinker.net:18001/login/pc?username=${name}&password=${fs_password}`)
-            .then(({ data }) => {
-              if (data.code === 200) {
-                window.open('https://www.newlinker.net:8090?token=' + data.data.token)
-              } else {
-                return
-              }
-            })
+          const res = await get4SLoginToken()
+          if (res.target_url) {
+            window.location.href = res.target_url
+          }
         }
-        if(to.path === '/IOT') {
+        if (to.path === '/IOT') {
           let {
             data: { bim_view },
           } = await fileBimView('1207')
           localStorage.setItem(bim_view.lightweightName, JSON.stringify([bim_view]))
-          window.open(`/modelViewIOT?id=${bim_view.lightweightName}`, '_blank') 
+          next({ path: `/modelViewIOT?id=${bim_view.lightweightName}` })
         }
         next()
       }
@@ -127,10 +119,10 @@ router.beforeEach(async (to, from, next) => {
       // 在免登录名单,直接进入
       next()
     } else {
-      if(window.location.href.startsWith("http://localhost")){
+      if (window.location.href.startsWith('http://localhost')) {
         next({ path: '/user/login' })
-      }else{
-        window.location.href = `https://dev.autocde.com/login?redirect=${to.fullPath}`;
+      } else {
+        window.location.href = `https://dev.autocde.com/login?redirect=${to.fullPath}`
       }
       NProgress.done() // if current page is login will not trigger afterEach hook, so manually handle it
     }

+ 1 - 1
src/utils/request.js

@@ -49,7 +49,7 @@ const errorHandler = (error) => {
         message: 'Bad request',
         description: data.message,
       })
-      return
+      return data
     }
   }
   return Promise.reject(error)