景徳镇旅游微信小程序
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.

28 lines
670 B

6 months ago
  1. let needLogin = [
  2. // "/pages/user/user",
  3. ]
  4. let list = ["navigateTo"];
  5. list.forEach(item => { //用遍历的方式分别为,uni.navigateTo,uni.redirectTo,uni.reLaunch,uni.switchTab这4个路由方法添加拦截器
  6. console.log(item, 'router list item')
  7. uni.addInterceptor(item, {
  8. invoke(e) { // 调用前拦截
  9. let length = getCurrentPages().length
  10. if (length >= 10) {
  11. uni.showToast({
  12. title: '页面栈已满,即将回到首页',
  13. icon: 'none'
  14. })
  15. setTimeout(uni.reLaunch, 1000, {
  16. url: '/pages/index/index'
  17. })
  18. return false
  19. }
  20. return true
  21. },
  22. fail(err) { // 失败回调拦截
  23. console.log(err);
  24. },
  25. })
  26. })