index.js 4.2 KB

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