router.js
6.86 KB
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
const whiteList = [
'/login', // 登录页面
'/register', // 注册页面
// ...其他不需要登录的路由
];
const router = new Router({
mode: 'history', // 使用history模式
routes: [
{
path: '/home',
name: 'home',
component: () => import('@/pages/home/home.vue'),
meta: {
navigationStyle: 'custom'
}
},
{
path: '/login',
name: 'login',
component: () => import('@/pages/login/login.vue'),
meta: {
navigationBarTitleText: '登录',
navigationBarBackgroundColor: '#FFFFFF'
}
},
{
path: '/my',
name: 'my',
component: () => import('@/pages/my/my.vue'),
meta: {
navigationStyle: 'custom'
}
},
{
path: '/apply',
name: 'apply',
component: () => import('@/pages/apply/apply.vue'),
meta: {
navigationBarTitleText: '申请记录',
navigationBarBackgroundColor: '#FFFFFF'
}
},
{
path: '/shops',
name: 'shops',
component: () => import('@/pages/shops/shops.vue'),
meta: {
navigationBarTitleText: '租商铺',
navigationBarBackgroundColor: '#FFFFFF'
}
},
{
path: '/applyDetail',
name: 'applyDetail',
component: () => import('@/pages/applyDetail/applyDetail.vue'),
meta: {
navigationBarTitleText: '详情',
navigationBarBackgroundColor: '#FFFFFF'
}
},
{
path: '/message',
name: 'message',
component: () => import('@/pages/message/message.vue'),
meta: {
navigationStyle: 'custom'
}
},
{
path: '/field',
name: 'field',
component: () => import('@/pages/field/field.vue'),
meta: {
navigationBarTitleText: '租场地',
navigationBarBackgroundColor: '#FFFFFF'
}
},
{
path: '/advertisement',
name: 'advertisement',
component: () => import('@/pages/advertisement/advertisement.vue'),
meta: {
navigationBarTitleText: '租广告',
navigationBarBackgroundColor: '#FFFFFF'
}
},
{
path: '/details',
name: 'details',
component: () => import('@/pages/details/details.vue'),
meta: {
navigationBarTitleText: '详情',
navigationBarBackgroundColor: '#FFFFFF'
}
},
{
path: '/leaseAdd',
name: 'leaseAdd',
component: () => import('@/pages/leaseAdd/leaseAdd.vue'),
meta: {
navigationBarTitleText: '申请租赁',
navigationBarBackgroundColor: '#FFFFFF'
}
},
{
path: '/recordService',
name: 'recordService',
component: () => import('@/pages/recordService/recordService.vue'),
meta: {
navigationBarTitleText: '服务记录',
navigationBarBackgroundColor: '#FFFFFF'
}
},
{
path: '/activityAdd',
name: 'activityAdd',
component: () => import('@/pages/activityAdd/activityAdd.vue'),
meta: {
navigationBarTitleText: '活动申请',
navigationBarBackgroundColor: '#FFFFFF'
}
},
{
path: '/complaint',
name: 'complaint',
component: () => import('@/pages/complaint/complaint.vue'),
meta: {
navigationBarTitleText: '投诉建议',
navigationBarBackgroundColor: '#FFFFFF'
}
},
{
path: '/repair',
name: 'repair',
component: () => import('@/pages/repair/repair.vue'),
meta: {
navigationBarTitleText: '故障报修',
navigationBarBackgroundColor: '#FFFFFF'
}
},
{
path: '/advertisementTime',
name: 'advertisementTime',
component: () => import('@/pages/advertisementTime/advertisementTime.vue'),
meta: {
navigationBarTitleText: '租赁时段选择',
navigationBarBackgroundColor: '#FFFFFF'
}
},
{
path: '/advertisementAdd',
name: 'advertisementAdd',
component: () => import('@/pages/advertisementAdd/advertisementAdd.vue'),
meta: {
navigationBarTitleText: '申请',
navigationBarBackgroundColor: '#FFFFFF'
}
},
{
path: '/participation',
name: 'participation',
component: () => import('@/pages/participation/participation.vue'),
meta: {
navigationBarTitleText: '活动参与',
navigationBarBackgroundColor: '#FFFFFF'
}
},
{
path: '/questionnaire',
name: 'questionnaire',
component: () => import('@/pages/questionnaire/questionnaire.vue'),
meta: {
navigationBarTitleText: '问卷调查',
navigationBarBackgroundColor: '#FFFFFF'
}
},
{
path: '/createQuestionnaire',
name: 'createQuestionnaire',
component: () => import('@/pages/createQuestionnaire/createQuestionnaire.vue'),
meta: {
navigationBarTitleText: '创建问卷',
navigationBarBackgroundColor: '#FFFFFF'
}
},
{
path: '/mycreated',
name: 'mycreated',
component: () => import('@/pages/mycreated/mycreated.vue'),
meta: {
navigationBarTitleText: '我创建的活动',
navigationBarBackgroundColor: '#FFFFFF'
}
},
{
path: '/record',
name: 'record',
component: () => import('@/pages/record/record.vue'),
meta: {
navigationBarTitleText: '申请记录',
navigationBarBackgroundColor: '#FFFFFF'
}
},
{
path: '/accepting',
name: 'accepting',
component: () => import('@/pages/accepting/accepting.vue'),
meta: {
navigationBarTitleText: '详情',
navigationBarBackgroundColor: '#FFFFFF'
}
},
{
path: '/servicerecords',
name: 'servicerecords',
component: () => import('@/pages/servicerecords/servicerecords.vue'),
meta: {
navigationBarTitleText: '服务记录',
navigationBarBackgroundColor: '#FFFFFF'
}
},
{
path: '/servicedetails',
name: 'servicedetails',
component: () => import('@/pages/servicedetails/servicedetails.vue'),
meta: {
navigationBarTitleText: '详情',
navigationBarBackgroundColor: '#FFFFFF'
}
},
{
path: '/application',
name: 'application',
component: () => import('@/pages/application/application.vue'),
meta: {
navigationBarTitleText: '推广方案申请',
navigationBarBackgroundColor: '#FFFFFF'
}
},
{
path: '/projectManagement',
name: 'projectManagement',
component: () => import('@/pages/projectManagement/projectManagement.vue'),
meta: {
navigationBarTitleText: '推广方案管理',
navigationBarBackgroundColor: '#FFFFFF'
}
},
// ...其他路由配置
{
path: '/mycreated',
name: 'mycreated',
component: () => import('@/pages/mycreated/mycreated.vue'),
meta: {
navigationBarTitleText: '我创建的活动',
navigationBarBackgroundColor: '#FFFFFF'
}
},
// ...其他路由配置
]
})
router.beforeEach((to, from, next) => {
// 检查目标页面是否在白名单中
let token = uni.getStorageSync('token');
if (whiteList.includes(to.path)) {
// 如果在白名单中,直接放行
next();
} else {
// 如果不在白名单中,检查用户是否登录
if (token) {
// 如果已登录,继续跳转到目标页面
next();
} else {
// 如果未登录,跳转到登录页面
next({ path: '/login' });
}
}
});
export default router