index.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. },
  40. onClickNav({
  41. detail = {}
  42. }) {
  43. this.setData({
  44. mainActiveIndex: detail.index || 0,
  45. });
  46. },
  47. onClickItem({
  48. detail = {}
  49. }) {
  50. const activeId = this.data.activeId === detail.id ? null : detail.id;
  51. console.log(activeId)
  52. this.setData({
  53. activeId
  54. });
  55. },
  56. /**
  57. * 生命周期函数--监听页面初次渲染完成
  58. */
  59. onReady() {
  60. //滚动区域高度
  61. getHeight.getHeight('.menu', this).then(res => {
  62. this.setData({
  63. scrollHeight: res
  64. })
  65. })
  66. },
  67. /**
  68. * 生命周期函数--监听页面显示
  69. */
  70. onShow() {
  71. },
  72. /**
  73. * 生命周期函数--监听页面隐藏
  74. */
  75. onHide() {
  76. },
  77. /**
  78. * 生命周期函数--监听页面卸载
  79. */
  80. onUnload() {
  81. },
  82. /**
  83. * 页面相关事件处理函数--监听用户下拉动作
  84. */
  85. onPullDownRefresh() {
  86. },
  87. /**
  88. * 页面上拉触底事件的处理函数
  89. */
  90. onReachBottom() {
  91. },
  92. /**
  93. * 用户点击右上角分享
  94. */
  95. onShareAppMessage() {
  96. }
  97. })