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
import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/home.vue'
import { getXToken, configWx } from '@/utils/aCommon'
Vue.use(VueRouter)
const routes = [
{
path: '/',
name: 'home',
component: Home
},
{
path: '/discount',
name: 'Discount',
component: () => import('@/views/sideNav/discount/index')
},
{
path: '/invite',
name: 'register',
component: () => import('@/views/sideNav/register/index')
},
{
path: '/manInfo',
name: 'ManInfo',
component: () => import('@/views/sideNav/manInfo/index')
},
{
path: '/goodPost',
name: 'GoodPost',
component: () => import('@/views/sideNav/goodPost/index')
}
// {
// path: '/about',
// name: 'about',
// // route level code-splitting
// // this generates a separate chunk (about.[hash].js) for this route
// // which is lazy-loaded when the route is visited.
// component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
// }
]
const router = new VueRouter({
mode: 'history',
base: process.env.BASE_URL,
routes
})
const whiteList = ['/discount', 'discount']
router.beforeEach((to, from ,next) => {
// alert(`--->route: beforeEach: to =${JSON.stringify(to)}. from =${from}. next =${JSON.stringify(next)}`)
if(whiteList.indexOf(to.path) != -1) {
// alert(`--->route: beforeEach: If: UnIn whiteList.`)
if(sessionStorage.getItem('zConfigWx') === 'Pass'){
next()
} else {
configWx(to)
}
} else {
// alert(`--->route: beforeEach: If: In whiteList.`)
next()
}
// if (whiteList.indexOf(to.path) !== -1) {
// next()
// } else {
// if(sessionStorage.getItem('unionid')) {
// next()
// } else {
// getUnionId(to)
// // next()
// }
// }
})
// async function getUnionId (to) {
// await getXToken()
// configWx(to)
// }
export default router