|
@@ -1,8 +1,8 @@
|
|
-import Vue from 'vue'
|
|
|
|
-import store from '@/store'
|
|
|
|
-import VueRouter from 'vue-router'
|
|
|
|
-import { query } from '@/utils/query'
|
|
|
|
-import { getPvUv } from '@/api/public.js'
|
|
|
|
|
|
+import Vue from "vue"
|
|
|
|
+import store from "@/store"
|
|
|
|
+import VueRouter from "vue-router"
|
|
|
|
+import { query } from "@/utils/query"
|
|
|
|
+import { getPvUv } from "@/api/public.js"
|
|
Vue.use(VueRouter)
|
|
Vue.use(VueRouter)
|
|
const routes = [
|
|
const routes = [
|
|
// {
|
|
// {
|
|
@@ -10,130 +10,130 @@ const routes = [
|
|
// redirect: '/home/overview', // 只有区域,及区域以上用户才能进入总部首页这一套
|
|
// redirect: '/home/overview', // 只有区域,及区域以上用户才能进入总部首页这一套
|
|
// },
|
|
// },
|
|
{
|
|
{
|
|
- path: '/404',
|
|
|
|
- name: '404页面',
|
|
|
|
- component: () => import('../components/404'),
|
|
|
|
|
|
+ path: "/404",
|
|
|
|
+ name: "404页面",
|
|
|
|
+ component: () => import("../components/404"),
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- path: '/group',
|
|
|
|
- name: '集团首页',
|
|
|
|
- component: () => import('../views/statistics/index'),
|
|
|
|
|
|
+ path: "/group",
|
|
|
|
+ name: "集团首页",
|
|
|
|
+ component: () => import("../views/statistics/index"),
|
|
},
|
|
},
|
|
// home
|
|
// home
|
|
{
|
|
{
|
|
- path: '/home',
|
|
|
|
- name: 'home',
|
|
|
|
- component: () => import('../views/index'),
|
|
|
|
- redirect: '/home/homepage',
|
|
|
|
|
|
+ path: "/home",
|
|
|
|
+ name: "home",
|
|
|
|
+ component: () => import("../views/index"),
|
|
|
|
+ redirect: "/home/homepage",
|
|
children: [
|
|
children: [
|
|
{
|
|
{
|
|
- path: 'homepage',
|
|
|
|
- name: '项目首页',
|
|
|
|
- component: () => import('../views/homepage'),
|
|
|
|
- redirect: '/home/overview',
|
|
|
|
|
|
+ path: "homepage",
|
|
|
|
+ name: "项目首页",
|
|
|
|
+ component: () => import("../views/homepage"),
|
|
|
|
+ redirect: "/home/overview",
|
|
},
|
|
},
|
|
//概览
|
|
//概览
|
|
{
|
|
{
|
|
- path: 'overview',
|
|
|
|
- name: '项目概览',
|
|
|
|
- component: () => import('../views/overview'),
|
|
|
|
|
|
+ path: "overview",
|
|
|
|
+ name: "项目概览",
|
|
|
|
+ component: () => import("../views/overview"),
|
|
},
|
|
},
|
|
// 楼层功能
|
|
// 楼层功能
|
|
{
|
|
{
|
|
- path: 'floorFunc',
|
|
|
|
- name: '楼层功能',
|
|
|
|
- component: () => import('../views/floorFunc'),
|
|
|
|
|
|
+ path: "floorFunc",
|
|
|
|
+ name: "楼层功能",
|
|
|
|
+ component: () => import("../views/floorFunc"),
|
|
},
|
|
},
|
|
// 设备设施
|
|
// 设备设施
|
|
{
|
|
{
|
|
- path: 'equipment',
|
|
|
|
- name: '设备设施',
|
|
|
|
- component: () => import('../views/equipment'),
|
|
|
|
|
|
+ path: "equipment",
|
|
|
|
+ name: "设备设施",
|
|
|
|
+ component: () => import("../views/equipment"),
|
|
},
|
|
},
|
|
// 其他功能
|
|
// 其他功能
|
|
{
|
|
{
|
|
- path: 'other',
|
|
|
|
- name: '其他事项',
|
|
|
|
- component: () => import('../views/other'),
|
|
|
|
|
|
+ path: "other",
|
|
|
|
+ name: "其他事项",
|
|
|
|
+ component: () => import("../views/other"),
|
|
},
|
|
},
|
|
// 分析
|
|
// 分析
|
|
{
|
|
{
|
|
- path: 'analysis',
|
|
|
|
- name: '分享报表',
|
|
|
|
- component: () => import('../views/analysis'),
|
|
|
|
|
|
+ path: "analysis",
|
|
|
|
+ name: "分享报表",
|
|
|
|
+ component: () => import("../views/analysis"),
|
|
},
|
|
},
|
|
//图例库管理
|
|
//图例库管理
|
|
{
|
|
{
|
|
- path: 'legendLibrary',
|
|
|
|
- name: '图例管理',
|
|
|
|
- component: () => import('../views/legendLibrary'),
|
|
|
|
|
|
+ path: "legendLibrary",
|
|
|
|
+ name: "图例管理",
|
|
|
|
+ component: () => import("../views/legendLibrary"),
|
|
},
|
|
},
|
|
//图例绘制规则
|
|
//图例绘制规则
|
|
{
|
|
{
|
|
- path: 'legendRules',
|
|
|
|
- name: '绘制规则',
|
|
|
|
- component: () => import('../views/legendRules'),
|
|
|
|
|
|
+ path: "legendRules",
|
|
|
|
+ name: "绘制规则",
|
|
|
|
+ component: () => import("../views/legendRules"),
|
|
},
|
|
},
|
|
],
|
|
],
|
|
},
|
|
},
|
|
]
|
|
]
|
|
const router = new VueRouter({
|
|
const router = new VueRouter({
|
|
- mode: 'history',
|
|
|
|
|
|
+ mode: "history",
|
|
base: process.env.BASE_URL,
|
|
base: process.env.BASE_URL,
|
|
routes,
|
|
routes,
|
|
})
|
|
})
|
|
-const ignore = ['/404']
|
|
|
|
|
|
+const ignore = ["/404"]
|
|
|
|
|
|
router.beforeEach(async (to, from, next) => {
|
|
router.beforeEach(async (to, from, next) => {
|
|
// 取出刷新时的 ssoToken, 路由拦截时app.vue 生命周期还没有执行,store中还没有数据,
|
|
// 取出刷新时的 ssoToken, 路由拦截时app.vue 生命周期还没有执行,store中还没有数据,
|
|
- let beforeunload = localStorage.getItem('beforeunload'),
|
|
|
|
|
|
+ let beforeunload = localStorage.getItem("beforeunload"),
|
|
__token = null
|
|
__token = null
|
|
beforeunload && (__token = JSON.parse(beforeunload).ssoToken)
|
|
beforeunload && (__token = JSON.parse(beforeunload).ssoToken)
|
|
if (!ignore.includes(to.path)) {
|
|
if (!ignore.includes(to.path)) {
|
|
//都是需要token检验的页面 首先优先获取路由上带的token
|
|
//都是需要token检验的页面 首先优先获取路由上带的token
|
|
let token = null
|
|
let token = null
|
|
if (to.query.token) {
|
|
if (to.query.token) {
|
|
- store.commit('SETSSOTOKEN', to.query.token) //存vuex
|
|
|
|
- sessionStorage.setItem('SSOTOKEN', to.query.token)
|
|
|
|
|
|
+ store.commit("SETSSOTOKEN", to.query.token) //存vuex
|
|
|
|
+ sessionStorage.setItem("SSOTOKEN", to.query.token)
|
|
token = to.query.token
|
|
token = to.query.token
|
|
} else {
|
|
} else {
|
|
// to.query.token ? to.query.token : store.getters['ssoToken'] ? store.getters['ssoToken'] : __token
|
|
// to.query.token ? to.query.token : store.getters['ssoToken'] ? store.getters['ssoToken'] : __token
|
|
- if (store.getters['ssoToken']) {
|
|
|
|
- token = store.getters['ssoToken']
|
|
|
|
- } else if (sessionStorage.getItem('SSOTOKEN')) {
|
|
|
|
- token = sessionStorage.getItem('SSOTOKEN')
|
|
|
|
- store.commit('SETSSOTOKEN', sessionStorage.getItem('SSOTOKEN')) //存vuex
|
|
|
|
|
|
+ if (store.getters["ssoToken"]) {
|
|
|
|
+ token = store.getters["ssoToken"]
|
|
|
|
+ } else if (sessionStorage.getItem("SSOTOKEN")) {
|
|
|
|
+ token = sessionStorage.getItem("SSOTOKEN")
|
|
|
|
+ store.commit("SETSSOTOKEN", sessionStorage.getItem("SSOTOKEN")) //存vuex
|
|
} else {
|
|
} else {
|
|
let lastRoute = {
|
|
let lastRoute = {
|
|
path: to.path,
|
|
path: to.path,
|
|
params: to.params,
|
|
params: to.params,
|
|
query: to.query,
|
|
query: to.query,
|
|
}
|
|
}
|
|
- store.commit('SETLASTROUTER', lastRoute)
|
|
|
|
- let ssoServer = 'http://oauth.wanda-dev.cn'
|
|
|
|
- if (process.env.NODE_ENV == 'wanda_build') {
|
|
|
|
- ssoServer = 'http://oauth.wanda.cn'
|
|
|
|
|
|
+ store.commit("SETLASTROUTER", lastRoute)
|
|
|
|
+ let ssoServer = "http://oauth.wanda-dev.cn"
|
|
|
|
+ if (process.env.NODE_ENV == "wanda_build") {
|
|
|
|
+ ssoServer = "http://oauth.wanda.cn"
|
|
}
|
|
}
|
|
- let systemcode = 'CAD156',
|
|
|
|
|
|
+ let systemcode = "CAD156",
|
|
signal = new Date().getTime(),
|
|
signal = new Date().getTime(),
|
|
- version = '1.0.0'
|
|
|
|
|
|
+ version = "1.0.0"
|
|
window.location.href = `${ssoServer}/login?systemcode=${systemcode}&signal=${signal}&version=${version}`
|
|
window.location.href = `${ssoServer}/login?systemcode=${systemcode}&signal=${signal}&version=${version}`
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (token) {
|
|
if (token) {
|
|
- if (to.path == '/') {
|
|
|
|
- next('/group')
|
|
|
|
|
|
+ if (to.path == "/") {
|
|
|
|
+ next("/group")
|
|
}
|
|
}
|
|
- if (to.path == '/group' || to.path == '/home/homepage') {
|
|
|
|
|
|
+ if (to.path == "/group" || to.path == "/home/homepage") {
|
|
if (store.state.accessLevel == -1) {
|
|
if (store.state.accessLevel == -1) {
|
|
- await store.dispatch('getUserInfo', router)
|
|
|
|
- await store.dispatch('getBrand')
|
|
|
|
|
|
+ await store.dispatch("getUserInfo", router)
|
|
|
|
+ await store.dispatch("getBrand")
|
|
// await store.dispatch('getFact')
|
|
// await store.dispatch('getFact')
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- console.log('token', token)
|
|
|
|
- await store.dispatch('getFloors')
|
|
|
|
- await store.dispatch('getBrand')
|
|
|
|
|
|
+ console.log("token", token)
|
|
|
|
+ await store.dispatch("getFloors")
|
|
|
|
+ await store.dispatch("getBrand")
|
|
// await store.dispatch('getFact')
|
|
// await store.dispatch('getFact')
|
|
next()
|
|
next()
|
|
} else {
|
|
} else {
|
|
@@ -142,14 +142,14 @@ router.beforeEach(async (to, from, next) => {
|
|
params: to.params,
|
|
params: to.params,
|
|
query: to.query,
|
|
query: to.query,
|
|
}
|
|
}
|
|
- store.commit('SETLASTROUTER', lastRoute)
|
|
|
|
- let ssoServer = 'http://oauth.wanda-dev.cn'
|
|
|
|
- if (process.env.NODE_ENV == 'wanda_build') {
|
|
|
|
- ssoServer = 'http://oauth.wanda.cn'
|
|
|
|
|
|
+ store.commit("SETLASTROUTER", lastRoute)
|
|
|
|
+ let ssoServer = "http://oauth.wanda-dev.cn"
|
|
|
|
+ if (process.env.NODE_ENV == "wanda_build") {
|
|
|
|
+ ssoServer = "http://oauth.wanda.cn"
|
|
}
|
|
}
|
|
- let systemcode = 'CAD156',
|
|
|
|
|
|
+ let systemcode = "CAD156",
|
|
signal = new Date().getTime(),
|
|
signal = new Date().getTime(),
|
|
- version = '1.0.0'
|
|
|
|
|
|
+ version = "1.0.0"
|
|
window.location.href = `${ssoServer}/login?systemcode=${systemcode}&signal=${signal}&version=${version}`
|
|
window.location.href = `${ssoServer}/login?systemcode=${systemcode}&signal=${signal}&version=${version}`
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
@@ -159,17 +159,20 @@ router.beforeEach(async (to, from, next) => {
|
|
})
|
|
})
|
|
// 跳入路由后要对发送pvuv
|
|
// 跳入路由后要对发送pvuv
|
|
router.afterEach((to) => {
|
|
router.afterEach((to) => {
|
|
- let data = {
|
|
|
|
- type: 'router',
|
|
|
|
|
|
+ let postParams = {
|
|
|
|
+ type: "router",
|
|
target: to.name,
|
|
target: to.name,
|
|
parameter: to.path,
|
|
parameter: to.path,
|
|
}
|
|
}
|
|
- getPvUv(data)
|
|
|
|
|
|
+ const data = {
|
|
|
|
+ plazaId: store.getters["plazaId"],
|
|
|
|
+ }
|
|
|
|
+ getPvUv(data, postParams)
|
|
.then((res) => {
|
|
.then((res) => {
|
|
- console.log('pvuv', res)
|
|
|
|
|
|
+ console.log("pvuv", res)
|
|
})
|
|
})
|
|
.catch((res) => {
|
|
.catch((res) => {
|
|
- console.log('error', res)
|
|
|
|
|
|
+ console.log("error", res)
|
|
})
|
|
})
|
|
})
|
|
})
|
|
export default router
|
|
export default router
|