mobile-main.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // commpents/mobile-frame/mobile-main.js
  2. const app = getApp()
  3. Component({
  4. /**
  5. * 组件的属性列表
  6. */
  7. options: { multipleSlots: true },
  8. properties: {
  9. frameStyle: { type: Object }
  10. },
  11. /**
  12. * 组件的初始数据
  13. */
  14. data: {
  15. infoHeight: ''
  16. },
  17. // 生命周期函数,可以为函数,或一个在methods段中定义的方法名
  18. attached: function () { }, // 此处attached的声明会被lifetimes字段中的声明覆盖
  19. ready: function () { },
  20. pageLifetimes: {
  21. // 组件所在页面的生命周期函数
  22. show: function () { this.searchHeight() },
  23. hide: function () { },
  24. resize: function () { },
  25. },
  26. /**
  27. * 组件的方法列表
  28. */
  29. methods: {
  30. // 返回上一级
  31. back() {
  32. this.triggerEvent('back', '1')
  33. },
  34. tabPath(e) {
  35. this.triggerEvent('tabPath', e)
  36. },
  37. searchHeight() {
  38. let frameStyle = this.data.frameStyle;
  39. let client = app.globalData.client;
  40. let infoHeight = client.windowHeight;
  41. // 减去状态栏
  42. if (frameStyle.useTop) infoHeight = infoHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  43. // 减去菜单栏
  44. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  45. this.setData({ infoHeight: infoHeight })
  46. }
  47. }
  48. })