|
|
@@ -1,38 +1,51 @@
|
|
|
// router.js
|
|
|
-import { RouterMount, createRouter } from 'uni-simple-router';
|
|
|
+import { RouterMount, createRouter, runtimeQuit } from '@/js_sdk/hhyang-uni-simple-router/uni-simple-router';
|
|
|
+import tools from "@/service/tools";
|
|
|
const router = createRouter({
|
|
|
platform: process.env.VUE_APP_PLATFORM,
|
|
|
+ routerErrorEach:({type,level,...args})=>{
|
|
|
+ // console.log({type,level,...args})
|
|
|
+ // #ifdef APP-PLUS
|
|
|
+ if(type===3){
|
|
|
+ router.$lockStatus=false;
|
|
|
+ tools.onBackPress()
|
|
|
+ }
|
|
|
+ // #endif
|
|
|
+ },
|
|
|
routes: [...ROUTES]
|
|
|
});
|
|
|
//全局路由前置守卫
|
|
|
-const whiteList = ['/','/pages/index/index','/pages/text/index']
|
|
|
+const whiteList = ['/pages/text/index','/pages/login/forget','/pages/login/register','/pages-user/pages/explain','/pages/index/down']
|
|
|
|
|
|
router.beforeEach((to, from, next) => {
|
|
|
- let token = to.query.token;
|
|
|
- let m_id = to.query.m_id;
|
|
|
- if (token && m_id) {
|
|
|
- // store.commit("setCookie", { 'token': token, 'm_id': m_id });
|
|
|
- uni.setStorageSync('token',token);
|
|
|
- uni.setStorageSync('m_id',m_id);
|
|
|
- next('/pages/index/index');
|
|
|
- }
|
|
|
const userToken = uni.getStorageSync('token')
|
|
|
- const userMid = uni.getStorageSync('m_id')
|
|
|
- console.log('登陆信息-------'+userToken+'--------------'+userMid)
|
|
|
- if((!userToken || !userMid) && whiteList.indexOf(to.fullPath)<0){
|
|
|
- console.log('暂无登陆信息')
|
|
|
- console.log(to.fullPath )
|
|
|
+ // const userMid = uni.getStorageSync('m_id')
|
|
|
+ console.log('userToken:'+userToken)
|
|
|
+ // console.log('m_id:'+userMid)
|
|
|
+ console.log('path:'+to.fullPath)
|
|
|
+ // #ifdef APP-PLUS
|
|
|
+ if(!userToken && whiteList.indexOf(to.path)<0){
|
|
|
if(to.fullPath!=='/pages/login/index'){
|
|
|
next('/pages/login/index');
|
|
|
}
|
|
|
+ }else if(userToken && to.fullPath==='/pages/login/index'){
|
|
|
+ next('/pages/index/index');
|
|
|
}
|
|
|
- console.log('前置守卫to----------', to)
|
|
|
+ // #endif
|
|
|
+ // #ifdef H5
|
|
|
+ if(process.uniEnv.version==='prod'){
|
|
|
+ let wapUrl=['/pages/login/register','/pages-user/pages/explain','/pages/index/down']
|
|
|
+ if(wapUrl.indexOf(to.path)<0){
|
|
|
+ next('/pages/index/down');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // #endif
|
|
|
next();
|
|
|
|
|
|
});
|
|
|
// 全局路由后置守卫
|
|
|
router.afterEach((to, from) => {
|
|
|
- console.log('后置守卫to------', to)
|
|
|
+ // console.log('后置守卫to------', to)
|
|
|
})
|
|
|
|
|
|
export {
|