index.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // nova-werun/components/home/index.js
  2. Component({
  3. /**
  4. * 组件的属性列表
  5. */
  6. properties: {
  7. },
  8. /**
  9. * 组件的初始数据
  10. */
  11. data: {
  12. //屏幕高度
  13. statusBarHeight: 0, // 状态栏高度
  14. screenHeight: 0, // 屏幕高度
  15. customHeight: 0, // 自定义导航栏高度(如小程序右上角胶囊按钮)
  16. bottomNavHeight: 0, // 底部导航栏高度
  17. contentHeight: 0, // 可用内容高度
  18. contentpadding:0,//顶部padding高度
  19. //选择
  20. rows:[
  21. {image:'https://file-cloud.fmode.cn/qpFbRRSZrO/20241102/3l5p1v041343137.png?imageView2/1/w/200/h/200',text:'签到打卡'},
  22. {image:'https://file-cloud.fmode.cn/qpFbRRSZrO/20241102/v6p4fm041343296.png?imageView2/1/w/200/h/200',text:'排行榜'},
  23. {image:'https://file-cloud.fmode.cn/qpFbRRSZrO/20241102/mcu488041343362.png?imageView2/1/w/200/h/200',text:'转发分享'},
  24. {image:'https://file-cloud.fmode.cn/qpFbRRSZrO/20241102/pqln61041343428.png?imageView2/1/w/200/h/200',text:'我的勋章'},
  25. {image:'https://file-cloud.fmode.cn/qpFbRRSZrO/20241102/9crt85041343498.png?imageView2/1/w/200/h/200',text:'步行'},
  26. {image:'https://file-cloud.fmode.cn/qpFbRRSZrO/20241102/71svpg041343669.png?imageView2/1/w/200/h/200',text:'跑步'},
  27. {image:'https://file-cloud.fmode.cn/qpFbRRSZrO/20241102/uk13u1041343733.png?imageView2/1/w/200/h/200',text:'我的统计'},
  28. {image:'https://file-cloud.fmode.cn/qpFbRRSZrO/20241104/k1q4no034958681.png?imageView2/1/w/200/h/200',text:'积分'},
  29. ]
  30. },
  31. lifetimes: {
  32. detached: function () {
  33. // 在组件实例被从页面节点树移除时执行
  34. },
  35. attached: async function () {
  36. // 在组件实例进入页面节点树时执行
  37. // 计算
  38. const systemInfo = wx.getSystemInfoSync();
  39. const statusBarHeight = systemInfo.statusBarHeight || 0;
  40. const screenHeight = systemInfo.screenHeight || 0;
  41. const custom = wx.getMenuButtonBoundingClientRect();
  42. const customHeight = custom.height + 10 + 2 || 0;
  43. const bottomNavHeight = systemInfo.screenHeight - systemInfo.safeArea.bottom || 0;
  44. const contentpadding = (statusBarHeight + customHeight) * 750 / systemInfo.windowWidth;
  45. const contentHeight = (screenHeight - bottomNavHeight-50 - statusBarHeight - customHeight) * 750 / systemInfo.windowWidth;
  46. this.setData({
  47. statusBarHeight,
  48. screenHeight,
  49. customHeight,
  50. bottomNavHeight,
  51. contentHeight,
  52. contentpadding
  53. });
  54. console.log('123',contentpadding);
  55. },
  56. },
  57. /**
  58. * 组件的方法列表
  59. */
  60. methods: {
  61. }
  62. })