index.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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',
  22. text: '签到打卡',
  23. url: '../../pages/home/signin/index'
  24. },
  25. {
  26. image: 'https://file-cloud.fmode.cn/qpFbRRSZrO/20241102/v6p4fm041343296.png?imageView2/1/w/200/h/200',
  27. text: '排行榜',
  28. url: ''
  29. },
  30. {
  31. image: 'https://file-cloud.fmode.cn/qpFbRRSZrO/20241102/mcu488041343362.png?imageView2/1/w/200/h/200',
  32. text: '转发分享',
  33. url: ''
  34. },
  35. {
  36. image: 'https://file-cloud.fmode.cn/qpFbRRSZrO/20241102/pqln61041343428.png?imageView2/1/w/200/h/200',
  37. text: '我的勋章',
  38. url: ''
  39. },
  40. {
  41. image: 'https://file-cloud.fmode.cn/qpFbRRSZrO/20241102/9crt85041343498.png?imageView2/1/w/200/h/200',
  42. text: '步行',
  43. url: ''
  44. },
  45. {
  46. image: 'https://file-cloud.fmode.cn/qpFbRRSZrO/20241102/71svpg041343669.png?imageView2/1/w/200/h/200',
  47. text: '跑步',
  48. url: ''
  49. },
  50. {
  51. image: 'https://file-cloud.fmode.cn/qpFbRRSZrO/20241102/uk13u1041343733.png?imageView2/1/w/200/h/200',
  52. text: '我的统计',
  53. url: ''
  54. },
  55. {
  56. image: 'https://file-cloud.fmode.cn/qpFbRRSZrO/20241104/k1q4no034958681.png?imageView2/1/w/200/h/200',
  57. text: '积分',
  58. url: ''
  59. },
  60. ]
  61. },
  62. lifetimes: {
  63. detached: function () {
  64. // 在组件实例被从页面节点树移除时执行
  65. },
  66. attached: async function () {
  67. // 在组件实例进入页面节点树时执行
  68. // 计算
  69. const systemInfo = wx.getSystemInfoSync();
  70. const statusBarHeight = systemInfo.statusBarHeight || 0;
  71. const screenHeight = systemInfo.screenHeight || 0;
  72. const custom = wx.getMenuButtonBoundingClientRect();
  73. const customHeight = custom.height + 10 + 2 || 0;
  74. const bottomNavHeight = systemInfo.screenHeight - systemInfo.safeArea.bottom || 0;
  75. const contentpadding = (statusBarHeight + customHeight) * 750 / systemInfo.windowWidth;
  76. const contentHeight = (screenHeight - bottomNavHeight - 50 - statusBarHeight - customHeight) * 750 / systemInfo.windowWidth;
  77. this.setData({
  78. statusBarHeight,
  79. screenHeight,
  80. customHeight,
  81. bottomNavHeight,
  82. contentHeight,
  83. contentpadding
  84. });
  85. console.log('123', contentpadding);
  86. },
  87. },
  88. /**
  89. * 组件的方法列表
  90. */
  91. methods: {
  92. //跳转
  93. gourl(e) {
  94. const url = e.currentTarget.dataset.url
  95. wx.navigateTo({
  96. url: `${url}` // 目标页面的路径
  97. });
  98. },
  99. }
  100. })