index.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // nova-tourism/components/my/index.js
  2. Component({
  3. /**
  4. * 组件的属性列表
  5. */
  6. properties: {
  7. },
  8. /**
  9. * 组件的初始数据
  10. */
  11. data: {
  12. statusBarHeight: 0,
  13. screenHeight: 0,
  14. customHeight: 0,
  15. bottomNavHeight: 0,
  16. contentHeight: 0,
  17. },
  18. lifetimes: {
  19. detached: function () {},
  20. attached: async function () {
  21. const systemInfo = wx.getSystemInfoSync();
  22. const statusBarHeight = systemInfo.statusBarHeight || 0;
  23. const screenHeight = systemInfo.screenHeight || 0;
  24. const custom = wx.getMenuButtonBoundingClientRect();
  25. const customHeight = custom.height + 10 + 2 || 0;
  26. const bottomNavHeight = systemInfo.screenHeight - systemInfo.safeArea.bottom || 0;
  27. const contentHeight = (screenHeight - bottomNavHeight - 50 - statusBarHeight - customHeight) * 750 / systemInfo.windowWidth;
  28. this.setData({
  29. statusBarHeight,
  30. screenHeight,
  31. customHeight,
  32. bottomNavHeight,
  33. contentHeight
  34. });
  35. },
  36. },
  37. /**
  38. * 组件的方法列表
  39. */
  40. methods: {
  41. }
  42. })