mobile-main.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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',)
  33. },
  34. tabPath(e) {
  35. this.triggerEvent('tabPath', e)
  36. },
  37. searchHeight() {
  38. let frameStyle = this.properties.frameStyle;
  39. let client = app.globalData.client;
  40. // 减去状态栏
  41. let infoHeight = client.windowHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  42. // 是否减去底部菜单
  43. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  44. if (infoHeight) this.setData({ infoHeight: infoHeight })
  45. }
  46. }
  47. })