| 1234567891011121314151617181920212223242526272829303132333435363738394041 | import { getToken } from '@/utils/auth'// 登录页面const loginPage = "/pages/login"  // 页面白名单const whiteList = [  '/pages/login', '/pages/common/webview/index',  '/pages/business/mhxf/unitInfoCollection/index', '/pages/business/mhxf/unitInfoCollection/index',]// 检查地址白名单function checkWhite(url) {  const path = url.split('?')[0]  return whiteList.indexOf(path) !== -1}// 页面跳转验证拦截器let list = ["navigateTo", "redirectTo", "reLaunch", "switchTab"]list.forEach(item => {  uni.addInterceptor(item, {    invoke(to) {      console.log(to)      if (getToken()) {        if (to.url === loginPage) {          uni.reLaunch({ url: "/" })        }        return true      } else {        if (checkWhite(to.url)) {          return true        }        uni.reLaunch({ url: loginPage })        return false      }    },    fail(err) {      console.log(err)    }  })})
 |