index.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. const getHeight = require("../../utils/getRheRemainingHeight");
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. scrollHeight: 0, //滚动区域高度
  8. searchContent: "", //搜索内容
  9. mainActiveIndex: 0, //分类选择器打开分类的下标
  10. activeId: null, //分类选择器选择id
  11. items: [{
  12. text: '所有城市',
  13. children: [{
  14. text: '温州',
  15. id: '温州',
  16. },
  17. {
  18. text: '杭州',
  19. id: '杭州',
  20. },
  21. ],
  22. }, {
  23. text: '可选城市',
  24. children: [{
  25. text: '嘉兴',
  26. id: '嘉兴',
  27. },
  28. {
  29. text: '台州',
  30. id: '台州',
  31. },
  32. ],
  33. }, ]
  34. },
  35. /**
  36. * 生命周期函数--监听页面加载
  37. */
  38. onLoad(options) {},
  39. onClickNav({
  40. detail = {}
  41. }) {
  42. this.setData({
  43. mainActiveIndex: detail.index || 0,
  44. });
  45. },
  46. onClickItem({
  47. detail = {}
  48. }) {
  49. const activeId = this.data.activeId === detail.id ? null : detail.id;
  50. console.log(activeId)
  51. this.setData({
  52. activeId
  53. });
  54. },
  55. /**
  56. * 生命周期函数--监听页面初次渲染完成
  57. */
  58. onReady() {
  59. //滚动区域高度
  60. getHeight.getHeight('.menu', this).then(res => {
  61. this.setData({
  62. scrollHeight: res
  63. })
  64. })
  65. },
  66. /**
  67. * 生命周期函数--监听页面显示
  68. */
  69. onShow() {
  70. },
  71. /**
  72. * 生命周期函数--监听页面隐藏
  73. */
  74. onHide() {
  75. },
  76. /**
  77. * 生命周期函数--监听页面卸载
  78. */
  79. onUnload() {
  80. },
  81. /**
  82. * 页面相关事件处理函数--监听用户下拉动作
  83. */
  84. onPullDownRefresh() {
  85. },
  86. /**
  87. * 页面上拉触底事件的处理函数
  88. */
  89. onReachBottom() {
  90. },
  91. /**
  92. * 用户点击右上角分享
  93. */
  94. onShareAppMessage() {
  95. },
  96. /**
  97. * 用户分享到朋友圈
  98. */
  99. onShareTimeline() {
  100. }
  101. })