运维小程序
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

index.js 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. // pages/privacy/index.js
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. // 状态栏高度
  8. statusBarHeight:'',
  9. // 导航栏高度
  10. navBarHeight:'',
  11. // 导航栏和状态栏高度
  12. navStatusBarHeight: '',
  13. // 胶囊
  14. menu:'',
  15. },
  16. /**
  17. * 生命周期函数--监听页面加载
  18. */
  19. onLoad(options) {
  20. this.setData({
  21. statusBarHeight:wx.getStorageSync('statusBarHeight'),
  22. navBarHeight: wx.getStorageSync('navBarHeight'),
  23. navStatusBarHeight:wx.getStorageSync('navStatusBarHeight'),
  24. menu:wx.getStorageSync('menu')
  25. })
  26. },
  27. getShowScreenHeight(){
  28. //系统信息
  29. const systemInfo = wx.getWindowInfo()
  30. //胶囊位置
  31. const capsuleInfo = wx.getMenuButtonBoundingClientRect()
  32. //计算导航栏高度
  33. let navHeight = systemInfo.statusBarHeight + capsuleInfo.height + (capsuleInfo.top - systemInfo.statusBarHeight) * 2
  34. //计算tabbar高度
  35. let tabHeight = systemInfo.safeArea.bottom - systemInfo.safeArea.height
  36. //计算可现实内容高度(中间区域)
  37. // let screenHeight = systemInfo.screenHeight-navHeight-tabHeight-30
  38. const menu = wx.getMenuButtonBoundingClientRect()
  39. wx.setStorageSync('menu', menu)
  40. // 手机系统状态栏高度
  41. wx.setStorageSync('statusBarHeight', tabHeight)
  42. // 导航栏高度
  43. wx.setStorageSync('navBarHeight', menu.height+(menu.top-systemInfo.statusBarHeight) *2 )
  44. // 状态栏加导航栏
  45. wx.setStorageSync('navStatusBarHeight',navHeight)
  46. },
  47. /**
  48. * 生命周期函数--监听页面初次渲染完成
  49. */
  50. onReady() {
  51. },
  52. /**
  53. * 生命周期函数--监听页面显示
  54. */
  55. onShow() {
  56. },
  57. /**
  58. * 生命周期函数--监听页面隐藏
  59. */
  60. onHide() {
  61. },
  62. /**
  63. * 生命周期函数--监听页面卸载
  64. */
  65. onUnload() {
  66. },
  67. /**
  68. * 页面相关事件处理函数--监听用户下拉动作
  69. */
  70. onPullDownRefresh() {
  71. },
  72. /**
  73. * 页面上拉触底事件的处理函数
  74. */
  75. onReachBottom() {
  76. },
  77. /**
  78. * 用户点击右上角分享
  79. */
  80. onShareAppMessage() {
  81. }
  82. })