路泰科技体检小程序UI设计新版本
qx
2025-08-06 fcc0076c3507bc4e544c3cb3915204937fa46f60
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { getToken } from '@/utils/auth'
 
// 登录页面
const loginPage = "/pages/login"
  
// 页面白名单
const whiteList = [
  '/pages/login', '/pages/common/webview/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) {
      // 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)
    }
  })
})