mixin.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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/login/submit-success',
  35. 'pages/test/test',
  36. 'pages/chooseLable/chooseLable',
  37. 'pages/withdraw/withdraw',
  38. 'pages/withdraw/select-bank',
  39. 'pages/pay/pay',
  40. ]
  41. if (!WHiTE_LIST.includes(currentPage)) {
  42. if (!this.$cache.get('phone')) {
  43. uni.reLaunch({
  44. url: "/pages/login/account-login"
  45. })
  46. return
  47. }
  48. }
  49. //判断商场id是否为空
  50. WHiTE_LIST.push('pages/index/index')
  51. if (!WHiTE_LIST.includes(currentPage)) {
  52. if (!this.vuex_shopId) {
  53. uni.reLaunch({
  54. url:"/pages/index/index"
  55. })
  56. return
  57. }
  58. }
  59. }
  60. }
  61. export default page