mixin.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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/register',
  31. 'pages/login/account-login',
  32. 'pages/shop-info/shop-info',
  33. 'pages/webView/webView',
  34. 'pages/test/test',
  35. ]
  36. if (!WHiTE_LIST.includes(currentPage)) {
  37. if (!this.$cache.get('phone')) {
  38. uni.reLaunch({
  39. url: "/pages/login/login"
  40. })
  41. return
  42. }
  43. }
  44. //判断商场id是否为空
  45. WHiTE_LIST.push('pages/index/index')
  46. if (!WHiTE_LIST.includes(currentPage)) {
  47. if (!this.vuex_shopId) {
  48. uni.reLaunch({
  49. url:"/pages/index/index"
  50. })
  51. return
  52. }
  53. }
  54. }
  55. }
  56. export default page