| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- // router.js
- 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/login/index','/pages/login/register','/pages/login/forget']
- router.beforeEach(async (to, from, next) => {
- // tools.showLoading()
- console.log(to)
- console.log(from)
- // if(to.path==='/pages/login/index' && from.path!=='/pages/login/index'){
- // uni.setStorageSync('pageFullPath',from.fullPath)
- // }else if(from.path==='/pages/login/index'){
- // let oldFullPath= uni.getStorageSync('pageFullPath')
- // if(oldFullPath){
- // uni.setStorageSync('pageFullPath','')
- // next(oldFullPath);
- // }
- // }
- // let userToken=''
- // if (to.query.token ) {
- // userToken = to.query.token;
- // uni.setStorageSync('token',userToken)
- // }else {
- // userToken = uni.getStorageSync('token')
- // }
- // console.log('userToken:'+userToken)
- // if(whiteList.indexOf(to.path)<0 && !userToken){
- // console.log('----------------------')
- // // await tools.weiXinLogin().then(isLogin=>{
- // // console.log('-----------isLogin-----------')
- // // if(isLogin===-1){
- // // next('/pages/login/register');
- // // }else if(isLogin){
- // // next();
- // // }else {
- // // next('/pages/login/index');
- // // }
- // // }).catch(e=>{
- // // next('/pages/login/index');
- // // })
- // next('/pages/login/index');
- // // next();
- // }else {
- // next();
- // }
- next();
- });
- // 全局路由后置守卫
- router.afterEach((to, from) => {
- // console.log('后置守卫to------', to)
- // tools.hideLoading()
- })
- export {
- router,
- RouterMount
- }
|