You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
1.2 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

// 路由
import {
RouterMount,
createRouter
} from './uni-simple-router.js'
import store from '@/shopro/store'
const router = createRouter({
platform: process.env.VUE_APP_PLATFORM,
applet: {
animationDuration: 0 //默认 300ms
},
routerErrorEach: ({
type,
msg
}) => {
switch (type) {
case 3: // APP退出应用
// #ifdef APP-PLUS
router.$lockStatus = false;
uni.showModal({
title: '提示',
content: '您确定要退出应用吗?',
success: function(res) {
if (res.confirm) {
plus.runtime.quit();
}
}
});
// #endif
break;
case 2:
case 0:
router.$lockStatus = false;
break;
default:
break;
}
},
// 通配符非定义页面跳转404
routes: [...ROUTES,
{
path: '*',
redirect: (to) => {
return {
name: '404'
}
}
},
]
});
//全局路由前置守卫
router.beforeEach((to, from, next) => {
// 权限控制登录
if (to.meta && to.meta.auth && !store.getters.isLogin) {
store.dispatch('showAuthModal');
next(false);
} else if (store.getters.initRecharge.enable !== '1' && to.path === '/pages/user/wallet/top-up') {
// 充值入口控制
next(false);
} else {
next()
}
});
export {
router,
RouterMount
}