index.js 2.4 KB

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