index.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. // nova-werun/pages/home/statistics/index.js
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. //屏幕高度
  8. statusBarHeight: 0, // 状态栏高度
  9. screenHeight: 0, // 屏幕高度
  10. customHeight: 0, // 自定义导航栏高度(如小程序右上角胶囊按钮)
  11. bottomNavHeight: 0, // 底部导航栏高度
  12. contentHeight: 0, // 可用内容高度
  13. contentHeight2: 0,
  14. contentpadding: 0, //顶部padding高度
  15. active: 0,
  16. //
  17. day:'7'
  18. },
  19. /**
  20. * 生命周期函数--监听页面加载
  21. */
  22. onLoad: function (options) {
  23. // 计算
  24. const systemInfo = wx.getSystemInfoSync();
  25. const statusBarHeight = systemInfo.statusBarHeight || 0;
  26. const screenHeight = systemInfo.screenHeight || 0;
  27. const custom = wx.getMenuButtonBoundingClientRect();
  28. const customHeight = custom.height + 10 + 2 || 0;
  29. const bottomNavHeight = systemInfo.screenHeight - systemInfo.safeArea.bottom || 0;
  30. const contentpadding = (statusBarHeight + customHeight) * 750 / systemInfo.windowWidth;
  31. const contentHeight = (screenHeight -50- bottomNavHeight - statusBarHeight - customHeight) * 750 / systemInfo.windowWidth;
  32. this.setData({
  33. statusBarHeight,
  34. screenHeight,
  35. customHeight,
  36. bottomNavHeight,
  37. contentpadding,
  38. contentHeight
  39. });
  40. },
  41. /**
  42. * 生命周期函数--监听页面初次渲染完成
  43. */
  44. onReady: function () {
  45. },
  46. /**
  47. * 生命周期函数--监听页面显示
  48. */
  49. onShow: function () {
  50. },
  51. /**
  52. * 生命周期函数--监听页面隐藏
  53. */
  54. onHide: function () {
  55. },
  56. /**
  57. * 生命周期函数--监听页面卸载
  58. */
  59. onUnload: function () {
  60. },
  61. /**
  62. * 页面相关事件处理函数--监听用户下拉动作
  63. */
  64. onPullDownRefresh: function () {
  65. },
  66. /**
  67. * 页面上拉触底事件的处理函数
  68. */
  69. onReachBottom: function () {
  70. },
  71. /**
  72. * 用户点击右上角分享
  73. */
  74. onShareAppMessage: function () {
  75. },
  76. onChange(event) {
  77. this.setData({ active: event.detail });
  78. },
  79. changeday(){
  80. if(this.data.day=='7'){
  81. this.setData({
  82. day:'30'
  83. })
  84. }else{
  85. this.setData({
  86. day:'7'
  87. })
  88. }
  89. }
  90. })