zjf
2023-03-03 bafa9dff4d9880c562f4d3a7b83bd4c1129240c5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
import Vue from 'vue'
import VueRouter from 'vue-router'
 
const Login = () =>
    import('@/views/login/index')
const Logining = () =>
    import('@/views/login/logining')
const Home = () =>
    import('@/views/home/Home')
const Welcome = () =>
    import('@/views/welcome/Welcome')
    // 销售模块
const ClientsManage = () =>
    import('@/views/clients/customer/clientsManage')
const ClueIndex = () =>
    import('@/views/clients/clue/ClueIndex')
const ContactsIndex = () =>
    import('@/views/clients/contacts/ContactsIndex')
const BusinessIndex = () =>
    import('@/views/clients/business/BusinessIndex')
const ContractIndex = () =>
    import('@/views/clients/contract/ContractIndex')
const OfferIndex = () =>
    import('@/views/clients/offers/OfferIndex')
const ProductIndex = () =>
    import('@/views/clients/product/ProductIndex')
const EmployeeManage = () =>
    import('@/views/company/employeeManage/EmployeeManage')
const OffcialAuthority = () =>
    import('@/views/company/offcialAuthority')
const StaffLog = () =>
    import('@/views/company/staffLog')
const ApartmentManage = () =>
    import('@/views/company/ApartmentManage')
const SystemSetting = () =>
    import('@/views/company/systemSetting')
const ModuleManage = () =>
    import('@/views/module/ModuleManage')
    // 人事模块
const SealContractIndex = () =>
    import('@/views/clients/sealContract/SealContractIndex')
const SealOfferIndex = () =>
    import('@/views/clients/sealOffers/SealOfferIndex')
    // 商务模块
const BusinessCustomerManage = () =>
    import('@/views/clients/businessCustomer/BusinessCustomerManage')
const BusinessChancesIndex = () =>
    import('@/views/clients/businessChances/BusinessChancesIndex')
const BusinessContractsIndex = () =>
    import('@/views/clients/businessContracts/BusinessContractsIndex')
    // PWS API
const EwsAnalyze = () =>
    import('@/views/PWS/EwsAnalyze')
const Subscriptions = () =>
    import('@/views/PWS/Subscriptions')
 
Vue.use(VueRouter)
 
const routes = [{
  path: '',
  redirect: '/login'
},
{
  path: '/login',
  component: Login
},
{
  path: '/logining',
  component: Logining
},
{
  path: '/home',
  component: Home,
  redirect: '/welcome',
  children: [{
    path: '/welcome',
    component: Welcome
  },
  {
    path: '/ModuleManage',
    component: ModuleManage
  },
  {
    path: '/clientsManage',
    component: ClientsManage
  },
  {
    path: '/ClueIndex',
    component: ClueIndex
  },
  {
    path: '/ContactsIndex',
    component: ContactsIndex
  },
  {
    path: '/BusinessIndex',
    component: BusinessIndex
  },
  {
    path: '/ContractIndex',
    component: ContractIndex
  },
  {
    path: '/OfferIndex',
    component: OfferIndex
  },
  {
    path: '/SealContractIndex',
    component: SealContractIndex
  },
  {
    path: '/SealOfferIndex',
    component: SealOfferIndex
  },
  {
    path: '/BusinessCustomerManage',
    component: BusinessCustomerManage
  },
  {
    path: '/BusinessChancesIndex',
    component: BusinessChancesIndex
  },
  {
    path: '/BusinessContractsIndex',
    component: BusinessContractsIndex
  },
  {
    path: '/ProductIndex',
    component: ProductIndex
  },
  {
    path: '/ApartmentManage',
    component: ApartmentManage
  },
  {
    path: '/offcialAuthority',
    component: OffcialAuthority
  },
  {
    path: '/staffLog',
    component: StaffLog
  },
  {
    path: '/EmployeeManage',
    component: EmployeeManage
  },
  {
    path: '/systemSetting',
    component: SystemSetting
  },
  {
    path: '/ewsAnalyze',
    component: EwsAnalyze
  },
  {
    path: '/Subscriptions',
    component: Subscriptions
  }
  ]
}
]
 
const router = new VueRouter({
  routes,
  mode: 'hash'
})
 
// 路由导航守卫,在跳转前判断
router.beforeEach((to, from, next) => {
  if (window.location.href.indexOf('code') >= 0) { // 如果code存在
    // 如果url中包含code   split?分割成数组,取第二个
    let code = window.location.href.split('?')[1]
    console.log(window.location.href)
    code = code.substring(5, code.indexOf('&')) // 截取字符串第6位开始截取直到&出现截取成功
    console.log(code)
    sessionStorage.setItem('code', code)
    next()
  } else {
    if (to.path === '/login') { // 如果是登录页
      localStorage.removeItem('token')
    }
    if (!localStorage.getItem('token') && to.path !== '/login') { // 如果token不存在 并且 不是mylogin页面
      next({ path: '/login' })
    } else {
      next()
    }
  }
})
 
export default router