index.js
2.71 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
import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)
const routes = [
// 首页
{
path: '/home',
component: () => import("../views/home/home")
},
// 支付页
{
path: '/pay',
name: "Pay",
component: () => import("../views/pay")
},
// 第二个外推页
{
path: '/homeSecond',
name: "HomeSecond",
component: () => import("../views/homeSecond/homeSecond")
},
// 第三个外推页
{
path: '/homeThird',
name: "HomeThird",
component: () => import("../views/homeThird/homeThird")
},
// 确认订单页
{
path: '/confirmOrder',
name: "ConfirmOrder",
component: () => import("../views/confirmOrder/confirmOrder")
},
// 抽奖页
{
path: '/lottery',
name: "Lottery",
component: () => import("../views/Lottery/Lottery")
},
// 下载app页
{
path: '/downloadApp',
name: "DownloadApp",
component: () => import("../views/downloadApp/downloadApp")
},
// 支付额外页面
{
path: '/additional',
name: "Additional",
component: () => import("../views/additional/additional")
},
// 登录页
{
path: '/login',
name: "Login",
component: () => import("../views/login/login")
},
// 单抽页面
{
path: '/openOneBox',
name: "OpenOneBox",
component: () => import("../views/openOneBox/openOneBox")
},
// 订单页面
{
path: '/order',
name: "Order",
component: () => import("../views/order/order")
},
// 确认支付页面
{
path: '/payConfirm',
name: "PayConfirm",
component: () => import("../views/payConfirm/payConfirm")
},
// 媒介跳转页面
{
path: '/medium',
name: "Medium",
component: () => import("../views/medium/medium")
},
{
path: '*',
// redirect: { path: "/additional", query: { boxId: 40 } }
// redirect: { path: "/additional", query: { boxId: 7} }
// redirect: { path: "/home"}
redirect: { path: "/medium"}
},
]
const router = new VueRouter({
mode: 'hash',
base: process.env.BASE_URL,
routes
})
// //重写VueRouter.prototype身上的push方法
// //先把VueRouter.prototype身上的push方法进行保存一份
const originPush = VueRouter.prototype.push;
// // const originReplace = VueRouter.prototype.replace;
VueRouter.prototype.push = function push(location) {
return originPush.call(this, location).catch(err => err)
}
// //全局守卫:前置守卫(在路由跳转之间进行判断)
router.beforeEach(async (to, from, next) => {
next()
// console.log(to);
// if(to.path=="/home"){
// redirect: { path: "/additional", query: { boxId: 40 } }
// }
// console.log(to);
// console.log(from);
// if(to.fullPath=="/additional"){
// }
});
export default router