index.js 2.3 KB

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