|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
-
- import {
- RouterMount,
- createRouter,
- runtimeQuit
- } from 'uni-simple-router'
- import {
- getToken,
- removeToken
- } from '@/utils/auth'
- import store from '@/store'
-
- const router = createRouter({
- platform: process.env.VUE_APP_PLATFORM,
- routerErrorEach: ({
- type,
- level,
- ...args
- }) => {
-
-
- if (type === 3) {
- router.$lockStatus = false;
- uni.showModal({
- title: '提示',
- content: '您确定要退出应用吗?',
- success: function(res) {
- if (res.confirm) {
- let main = plus.android.runtimeMainActivity();
- plus.runtime.quit = function() {
- main.moveTaskToBack(false);
- };
- plus.runtime.quit();
- }
- }
- });
- }
-
-
- },
- applet: {
- animationDuration: 300
- },
- routes: [...ROUTES]
- });
-
-
- const whiteList = ['/pages/login/index', '/pages/details/index', '/pages/skin-assessment/croppedImage', '/pages/user/mine', '/pages/user/info', '/pages/skin-assessment/photograph']
-
-
- router.beforeEach((to, from, next) => {
- if (getToken()) {
-
- if (to.path === '/pages/login/index') {
- next({
- path: '/pages/index/index',
- NAVTYPE: 'replace'
- })
- } else {
- if (!store.getters.userId) {
-
- store.dispatch('UserInfo').then((res) => {
- next();
- }).catch(() => {
- next();
- })
- } else {
- next();
- }
- }
- } else {
-
- if (whiteList.indexOf(to.path) !== -1) {
-
- next();
- } else {
- next();
-
-
-
-
-
- }
- }
- });
-
- router.afterEach((to, from) => {})
-
- export {
- router,
- RouterMount
- }
|