Browse Source

update login

zhulizhen1111 5 years ago
parent
commit
2e7f1d6f4a
3 changed files with 67 additions and 63 deletions
  1. 2 2
      src/components/menuList.vue
  2. 40 37
      src/router/index.js
  3. 25 24
      src/store/index.js

+ 2 - 2
src/components/menuList.vue

@@ -123,7 +123,7 @@ export default {
         toDrafts() {
             const { conf } = window.__systemConf,
                 { editerUrl } = conf
-            let data = `projectId=${this.plazaId}&fmapID=${this.fmapID}`
+            let data = `projectId=${this.plazaId}&fmapID=${this.fmapID}&token=${this.$store.state.ssoToken}`
             let url = editerUrl + 'drafts?' + encodeURIComponent(data)
             window.open(url, true)
         },
@@ -174,7 +174,7 @@ export default {
         dumpLegend() {
             const { conf } = window.__systemConf,
                 { wandaBmGuideUrl } = conf
-            window.open(`${wandaBmGuideUrl}home/legendLibrary`, true)
+            window.open(`${wandaBmGuideUrl}home/legendLibrary&token=${this.$store.state.ssoToken}`, true)
         }
     }
 }

+ 40 - 37
src/router/index.js

@@ -1,81 +1,83 @@
-import Vue from 'vue'
-import store from '@/store'
-import VueRouter from 'vue-router'
-import { query } from '@/utils/query'
+import Vue from "vue"
+import store from "@/store"
+import VueRouter from "vue-router"
+import { query } from "@/utils/query"
 Vue.use(VueRouter)
 
 const routes = [
     // 登陆页面
     {
-        path: '/',
-        redirect: '/home/overview',
+        path: "/",
+        redirect: "/home/overview",
     },
     // home
     {
-        path: '/home',
-        name: 'home',
-        component: () => import('../views/index'),
-        redirect: '/home/first',
+        path: "/home",
+        name: "home",
+        component: () => import("../views/index"),
+        redirect: "/home/first",
         children: [
             {
-                path: 'first',
-                component: () => import('../views/first'),
+                path: "first",
+                component: () => import("../views/first"),
             },
             //概览
             {
-                path: 'overview',
-                component: () => import('../views/overview'),
+                path: "overview",
+                component: () => import("../views/overview"),
             },
             // 楼层功能
             {
-                path: 'floorFunc',
-                component: () => import('../views/floorFunc'),
+                path: "floorFunc",
+                component: () => import("../views/floorFunc"),
             },
             // 设备设施
             {
-                path: 'equipment',
-                component: () => import('../views/equipment'),
+                path: "equipment",
+                component: () => import("../views/equipment"),
             },
             // 其他功能
             {
-                path: 'other',
-                component: () => import('../views/other'),
+                path: "other",
+                component: () => import("../views/other"),
             },
             // 分析
             {
-                path: 'analysis',
-                component: () => import('../views/analysis'),
+                path: "analysis",
+                component: () => import("../views/analysis"),
             },
             //图例库管理
             {
-                path: 'legendLibrary',
-                component: () => import('../views/legendLibrary'),
+                path: "legendLibrary",
+                component: () => import("../views/legendLibrary"),
             },
             //图例绘制规则
             {
-                path: 'legendRules',
-                component: () => import('../views/legendRules'),
+                path: "legendRules",
+                component: () => import("../views/legendRules"),
             },
         ],
     },
 ]
 const router = new VueRouter({
-    mode: 'history',
+    mode: "history",
     base: process.env.BASE_URL,
     routes,
 })
 router.beforeEach(async (to, from, next) => {
     const token = query().token
-    const ssoToken = store.getters['ssoToken']
+    console.log(token)
+    const ssoToken = store.getters["ssoToken"]
     if (ssoToken) {
-         store.commit("SETSSOTOKEN", token)
-         await store.dispatch("getUserInfo")
-        await store.dispatch('getFloors')
-        await store.dispatch('getBrand')
+        store.commit("SETSSOTOKEN", ssoToken)
+        await store.dispatch("getUserInfo")
+        await store.dispatch("getFloors")
+        await store.dispatch("getBrand")
         next()
     } else if (token) {
-        store.commit('SETSSOTOKEN', token)
-        await store.dispatch('getUserInfo')
+        store.commit("SETSSOTOKEN", token)
+        console.log(store.state.ssoToken)
+        await store.dispatch("getUserInfo")
         next()
     } else {
         let lastRoute = {
@@ -83,13 +85,14 @@ router.beforeEach(async (to, from, next) => {
             params: to.params,
             query: to.query,
         }
-        store.commit('SETLASTROUTER', lastRoute)
-        let ssoServer = 'http://oauth.wanda-dev.cn'
+        store.commit("SETLASTROUTER", lastRoute)
+        let ssoServer = "http://oauth.wanda-dev.cn"
         let systemcode = "CAD156",
             signal = new Date().getTime(),
             version = "1.0.0",
             // returnurl = 'http://glsms.wanda-dev.cn/'
-            returnurl = window.location.protocol + "//" + window.location.host + "/wandaBmGuide"
+            // returnurl = window.location.protocol + "//" + window.location.host + "/wandaBmGuide"
+            returnurl = "http://localhost:8090/wandaBmGuide/home/equipment"
         window.location.href = `${ssoServer}/login?token=${token}&systemcode=${systemcode}&signal=${signal}&version=${version}&returnurl=${returnurl}`
     }
 })

+ 25 - 24
src/store/index.js

@@ -1,32 +1,33 @@
-import Vue from 'vue'
-import Vuex from 'vuex'
-import { login, queryFloor, queryfmapID } from '@/api/login.js'
-import { queryBrand } from '@/api/public.js'
-import axios from 'axios'
+import Vue from "vue"
+import Vuex from "vuex"
+import { login, queryFloor, queryfmapID } from "@/api/login.js"
+import { queryBrand } from "@/api/public.js"
+import axios from "axios"
 
 Vue.use(Vuex)
 export default new Vuex.Store({
     state: {
-        ssoToken: 'admin:lengqiang',
-        lastRoute: '',
+        ssoToken: "admin:lengqiang",
+        // ssoToken: null,
+        lastRoute: "",
         isrequestAuth: true, // 是否请求登录校验接口
         permissions: [], //权限信息 "GLSMS_VIEW":"说明书查看"、"GLSMS_SYMBOL_MANAGE": "图例库管理"、 "GLSMS_PLANARGRAPH_MANAGE":"平面图维护"
         plazas: [], //项目列表
         userInfo: {
-            employeename: '', //用户名称:艾宇;
-            orgCode: '',
-            username: 'lengqiang', //账户名称
+            employeename: "", //用户名称:艾宇;
+            orgCode: "",
+            username: "lengqiang", //账户名称
         },
-        plazaId: '1000423', //项目Id
-        projectName: '', //全局项目名称
+        plazaId: "1000423", //项目Id
+        projectName: "", //全局项目名称
         floorsArr: [], //楼层数组
         floorSelect: [], //楼层下拉框
-        fmapID: '',
+        fmapID: "",
         haveFengMap: false, //是否有蜂鸟地图的数据
         isMessage: true, //是否有发布的图
         scpzTable: [], //土建系统图例展示
         legendTable: [], //除土建系统图例展示
-        remarksText: '', //备注
+        remarksText: "", //备注
         bunkObj: {}, // 铺位名称
         currentFloor: {}, //当前选中的楼层信息
     },
@@ -47,7 +48,7 @@ export default new Vuex.Store({
     },
     mutations: {
         SETSSOTOKEN(state, data) {
-            state.ssoToke = data
+            state.ssoToken = data
         },
         // 设置是否登陆校验
         SETISREQUESTtAUTH(state, palyload) {
@@ -106,19 +107,19 @@ export default new Vuex.Store({
         // 获取项目列表、userId
         async getUserInfo({ commit }, palyload) {
             await login({ username: palyload }).then((res) => {
-                if (res.result == 'success') {
-                    commit('SETISREQUESTtAUTH', true)
-                    commit('SETAUTHMSG', res)
+                if (res.result == "success") {
+                    commit("SETISREQUESTtAUTH", true)
+                    commit("SETAUTHMSG", res)
                 } else {
-                    console.log('接口报错!!')
-                    commit('SETISREQUESTtAUTH', false)
+                    console.log("接口报错!!")
+                    commit("SETISREQUESTtAUTH", false)
                 }
             })
         },
         getFloors(context) {
             queryFloor({ plazaId: context.state.plazaId }).then((res) => {
-                if (res.result == 'success') {
-                    context.commit('SETFLOORS', res.data)
+                if (res.result == "success") {
+                    context.commit("SETFLOORS", res.data)
                 }
             })
         },
@@ -126,7 +127,7 @@ export default new Vuex.Store({
             await queryfmapID({
                 mapId: context.state.plazaId,
             }).then((res) => {
-                context.commit('SETMAPID', `${context.state.plazaId}_${res.mapVersion}`)
+                context.commit("SETMAPID", `${context.state.plazaId}_${res.mapVersion}`)
             })
         },
         async getBrand(context) {
@@ -141,7 +142,7 @@ export default new Vuex.Store({
                         obj[i.bunkdesc] = i
                     })
                 }
-                context.commit('SETBUNKOBJ', obj)
+                context.commit("SETBUNKOBJ", obj)
             })
         },
     },