router.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // router.js
  2. import { RouterMount, createRouter } from 'uni-simple-router';
  3. import tools from '@/common/js/tools'
  4. import store from '@/store/index'
  5. import { getPlatform } from '@/common/js/utils'
  6. import tokenpocketBnb from "@/common/wallet/tokenpocket-wallet/tokenpocket-bnb";
  7. const router = createRouter({
  8. platform: process.env.VUE_APP_PLATFORM,
  9. routes: [...ROUTES]
  10. });
  11. //全局路由前置守卫
  12. const whiteList = ['/pages/login/register','/pages/login/index','/pages/login/invite']
  13. router.beforeEach((to, from, next) => {
  14. // if(to.path!=='/pages/index/error'){
  15. // let token = to.query.token;
  16. // let inviteCode = to.query.inviteCode;
  17. // if (token) {
  18. // uni.setStorageSync('token',token);
  19. // }
  20. // if (inviteCode) {
  21. // uni.setStorageSync('inviteCode',inviteCode);
  22. // }
  23. // const userToken = uni.getStorageSync('token')
  24. // if(!userToken){
  25. // if(whiteList.indexOf(to.path)<0){
  26. // next('/pages/login/index');
  27. // }
  28. // }
  29. // next();
  30. // }else {
  31. // next();
  32. // }
  33. next();
  34. });
  35. // 全局路由后置守卫
  36. router.afterEach((to, from) => {
  37. console.log('后置守卫to------', to)
  38. if(to.path!=='/pages/index/error'){
  39. }
  40. })
  41. export {
  42. router,
  43. RouterMount
  44. }