index.js 2.1 KB

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