index.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. // nova-tourism/pages/my/my-card/index.js
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. statusBarHeight: 0,
  8. screenHeight: 0,
  9. customHeight: 0,
  10. bottomNavHeight: 0,
  11. contentHeight: 0,
  12. currentTab: 0,
  13. },
  14. /**
  15. * 生命周期函数--监听页面加载
  16. */
  17. onLoad: function (options) {
  18. const systemInfo = wx.getSystemInfoSync();
  19. const statusBarHeight = systemInfo.statusBarHeight || 0;
  20. const screenHeight = systemInfo.screenHeight || 0;
  21. const custom = wx.getMenuButtonBoundingClientRect();
  22. const customHeight = custom.height + 10 + 2 || 0;
  23. const bottomNavHeight = systemInfo.screenHeight - systemInfo.safeArea.bottom || 0;
  24. const contentHeight = (screenHeight - bottomNavHeight - statusBarHeight - customHeight) * 750 / systemInfo.windowWidth;
  25. this.setData({
  26. statusBarHeight,
  27. screenHeight,
  28. customHeight,
  29. bottomNavHeight,
  30. contentHeight
  31. });
  32. },
  33. switchTab (e) {
  34. const index = e.currentTarget.dataset.index;
  35. this.setData({
  36. currentTab: index
  37. });
  38. console.log(this.data.currentTab);
  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. onChange(event) {
  76. },
  77. })