mixin.js 992 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * 全局注入器
  3. */
  4. let page = {
  5. data() {
  6. return {
  7. }
  8. },
  9. computed: {
  10. //ios底部安全区域
  11. safeAreaBottom() {
  12. let info = uni.getSystemInfoSync()
  13. let safe = 20
  14. if (
  15. info && ['devtools', 'ios'].includes(info.platform) &&
  16. info.statusBarHeight > safe
  17. ) {
  18. return info.statusBarHeight - safe + 'px'
  19. }
  20. return 0
  21. }
  22. },
  23. methods: {
  24. },
  25. onLoad(options) {
  26. let currentPage = this.$util.getCurrentRoute()
  27. //全局登录拦截
  28. let WHiTE_LIST = ['pages/login/login',
  29. 'pages/login/forget',
  30. 'pages/login/account-login',
  31. 'pages/test/test',
  32. ]
  33. if (!WHiTE_LIST.includes(currentPage)) {
  34. if (!this.$cache.get('phone')) {
  35. uni.reLaunch({
  36. url: "/pages/login/login"
  37. })
  38. return
  39. }
  40. }
  41. //判断商场id是否为空
  42. WHiTE_LIST.push('pages/index/index')
  43. if (!WHiTE_LIST.includes(currentPage)) {
  44. if (!this.vuex_mallId) {
  45. uni.reLaunch({
  46. url:"/pages/index/index"
  47. })
  48. return
  49. }
  50. }
  51. }
  52. }
  53. export default page