123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253 |
- import Vue from "vue"
- import store from "@/store"
- import VueRouter from "vue-router"
- const originalPush = VueRouter.prototype.push
- VueRouter.prototype.push = function push (location, onResolve, onReject) {
- if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
- return originalPush.call(this, location).catch(err => err)
- }
- import {
- query
- } from "@/utils/query"
- import {
- getPvUv
- } from "@/api/public.js"
- Vue.use(VueRouter)
- const routes = [
- {
- path: '/',
- redirect: '/home/overview',
- },
- {
- path: "/404",
- name: "404页面",
- component: () => import("../components/404"),
- },
- {
- path: "/group",
- name: "集团首页",
- component: () => import("../views/statistics/index"),
- },
-
- {
- path: "/home",
- name: "home",
- component: () => import("../views/index"),
- redirect: "/home/homepage",
- children: [{
- path: "homepage",
- name: "项目首页",
- component: () => import("../views/homepage"),
-
-
- beforeEnter (to,from,next){
- if (store.state.userInfo.username !== 'liujiandong') {
- next('/home/overview')
- } else {
- next()
- }
- }
- },
-
- {
- path: "overview",
- name: "项目概览",
- component: () => import("../views/overview"),
- },
-
- {
- path: "floorFunc",
- name: "楼层功能",
- component: () => import("../views/floorFunc"),
- },
-
- {
- path: "equipment",
- name: "设备设施",
- component: () => import("../views/equipment"),
- },
-
- {
- path: "other",
- name: "其他事项",
- component: () => import("../views/other"),
- },
-
- {
- path: "analysis",
- name: "分享报表",
- component: () => import("../views/analysis"),
- },
-
- {
- path: "legendLibrary",
- name: "图例管理",
- component: () => import("../views/legendLibrary"),
- },
-
- {
- path: "legendRules",
- name: "绘制规则",
- component: () => import("../views/legendRules"),
- },
- ],
- },
- ]
- const router = new VueRouter({
- mode: "history",
- base: process.env.BASE_URL,
- routes,
- })
- const ignore = ["/404"]
- router.afterEach((to) => {
- let postParams = {
- type: "router",
- target: to.name,
- parameter: to.path,
- }
- const data = {
- plazaId: store.getters["plazaId"],
- }
- getPvUv(data, postParams)
- .then((res) => {
- console.log("pvuv", res)
- })
- .catch((res) => {
- console.log("error", res)
- })
- })
- function redirectGetToken (to) {
- let lastRoute = {
- path: to.path,
- params: to.params,
- 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"
- }
- let systemcode = "CAD156",
- signal = new Date().getTime(),
- version = "1.0.0";
-
- if (!ignore.includes(to.path)) {
- let previewUrl = to.query.isPreview ? to.query.isPreview : '';
- let plazaId = to.query.plazaId ?to.query.plazaId:''
- if (previewUrl) {
- sessionStorage.setItem("SETISPREVIEW", previewUrl)
- store.commit('SETISPREVIEW', previewUrl)
- }
-
-
-
-
- if (plazaId) {
- localStorage.setItem('PLAZAID', plazaId)
- store.commit('STOREPLAZAID', plazaId)
- }
- sessionStorage.setItem("TOURL", to.path)
- } else {
-
- sessionStorage.setItem("TOURL", '/')
- }
- window.location.href = `${ssoServer}/login?systemcode=${systemcode}&signal=${signal}&version=${version}`
- }
- export default router
|