index.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. gourl(e) {
  42. const url = e.currentTarget.dataset.url;
  43. wx.navigateTo({
  44. url: `${url}`,
  45. });
  46. },
  47. }
  48. })