index.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. /**
  18. * 生命周期函数--监听页面加载
  19. */
  20. onLoad: function (options) {
  21. // 计算
  22. const systemInfo = wx.getSystemInfoSync();
  23. const statusBarHeight = systemInfo.statusBarHeight || 0;
  24. const screenHeight = systemInfo.screenHeight || 0;
  25. const custom = wx.getMenuButtonBoundingClientRect();
  26. const customHeight = custom.height + 10 + 2 || 0;
  27. const bottomNavHeight = systemInfo.screenHeight - systemInfo.safeArea.bottom || 0;
  28. const contentpadding = (statusBarHeight + customHeight) * 750 / systemInfo.windowWidth;
  29. const contentHeight = (screenHeight -50- bottomNavHeight - statusBarHeight - customHeight) * 750 / systemInfo.windowWidth;
  30. this.setData({
  31. statusBarHeight,
  32. screenHeight,
  33. customHeight,
  34. bottomNavHeight,
  35. contentpadding,
  36. contentHeight
  37. });
  38. },
  39. /**
  40. * 生命周期函数--监听页面初次渲染完成
  41. */
  42. onReady: function () {
  43. },
  44. /**
  45. * 生命周期函数--监听页面显示
  46. */
  47. onShow: function () {
  48. },
  49. /**
  50. * 生命周期函数--监听页面隐藏
  51. */
  52. onHide: function () {
  53. },
  54. /**
  55. * 生命周期函数--监听页面卸载
  56. */
  57. onUnload: function () {
  58. },
  59. /**
  60. * 页面相关事件处理函数--监听用户下拉动作
  61. */
  62. onPullDownRefresh: function () {
  63. },
  64. /**
  65. * 页面上拉触底事件的处理函数
  66. */
  67. onReachBottom: function () {
  68. },
  69. /**
  70. * 用户点击右上角分享
  71. */
  72. onShareAppMessage: function () {
  73. },
  74. onChange(event) {
  75. this.setData({ active: event.detail });
  76. },
  77. })