uni-events-helper-wx
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.

73 lines
1.4 KiB

3 years ago
  1. // 路由
  2. import {
  3. RouterMount,
  4. createRouter
  5. } from './uni-simple-router.js'
  6. import store from '@/nxTemp/store'
  7. const router = createRouter({
  8. platform: process.env.VUE_APP_PLATFORM,
  9. applet: {
  10. animationDuration: 0 //默认 300ms
  11. },
  12. routerErrorEach: ({
  13. type,
  14. msg
  15. }) => {
  16. console.log(55555,type,msg)
  17. switch (type) {
  18. case 3: // APP退出应用
  19. // #ifdef APP-PLUS
  20. router.$lockStatus = false;
  21. uni.showModal({
  22. title: '提示',
  23. content: '您确定要退出应用吗?',
  24. success: function(res) {
  25. if (res.confirm) {
  26. plus.runtime.quit();
  27. }
  28. }
  29. });
  30. // #endif
  31. break;
  32. case 2:
  33. case 0:
  34. console.log(66666,type)
  35. router.$lockStatus = false;
  36. break;
  37. default:
  38. console.log(77777,type)
  39. break;
  40. }
  41. },
  42. // 通配符,非定义页面,跳转404
  43. routes: [...ROUTES,
  44. {
  45. path: '*',
  46. redirect: (to) => {
  47. return {
  48. name: '404'
  49. }
  50. }
  51. },
  52. ]
  53. });
  54. //全局路由前置守卫
  55. router.beforeEach((to, from, next) => {
  56. // 权限控制登录
  57. next()
  58. // // 有两个个判断条件,一个是token,还有一个路由元信息
  59. // let userInfo = Boolean(uni.getStorageSync('userInfo'));
  60. // // 权限控制
  61. // if (to.meta && to.meta.auth && !userInfo) {//没有登录信息执行登录操作
  62. // } else {
  63. // next()
  64. // }
  65. });
  66. export {
  67. router,
  68. RouterMount
  69. }