dropdownmenu.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. Component({
  2. properties: {
  3. dropDownMenuTitle: {
  4. type: Array,
  5. value: [],
  6. },
  7. dropDownMenuDistrictData: {
  8. type: Array,
  9. value: [],
  10. observer: function(newVal, oldVal) {
  11. let model = newVal[0] ? newVal[0] : null
  12. this.selectDefaltDistrictLeft(model)
  13. }
  14. },
  15. dropDownMenuSourceData: {
  16. type: Array,
  17. value: []
  18. },
  19. dropDownMenuStyleData: {
  20. type: Array,
  21. value: []
  22. },
  23. dropDownMenuFilterData: {
  24. type: Array,
  25. value: []
  26. },
  27. },
  28. data: {
  29. // private properity
  30. district_open: false, // 区域
  31. source_open: false, // 来源
  32. style_open: false, // 出租 出售
  33. filteropen: false, // 筛选
  34. shownavindex: '',
  35. dropDownMenuDistrictDataRight: {},
  36. district_left_select: '',
  37. district_right_select: '',
  38. district_right_select_name: '',
  39. selected_style_id: 0,
  40. selected_style_name: '',
  41. selected_source_id: 0,
  42. selected_source_name: '',
  43. selected_filter_id: 0,
  44. selected_filter_name: ''
  45. },
  46. methods: {
  47. tapSourceNav: function(e) {
  48. if (this.data.source_open) {
  49. this.setData({
  50. source_open: false,
  51. shownavindex: 0
  52. })
  53. } else {
  54. this.setData({
  55. source_open: true,
  56. shownavindex: e.currentTarget.dataset.nav
  57. })
  58. }
  59. },
  60. selectSourceItem: function(e) {
  61. var selectedId = e.target.dataset.model.id
  62. var selectedTitle = e.target.dataset.model.title;
  63. this.closeHyFilter();
  64. this.setData({
  65. selected_source_id: selectedId,
  66. selected_source_name: selectedTitle
  67. })
  68. this.triggerEvent("selectedItem", {
  69. index: this.data.shownavindex,
  70. selectedId: selectedId,
  71. selectedTitle: selectedTitle
  72. })
  73. },
  74. /**关闭筛选 */
  75. closeHyFilter: function() {
  76. if (this.data.district_open) {
  77. this.setData({
  78. district_open: false,
  79. source_open: false,
  80. style_open: false,
  81. filter_open: false,
  82. })
  83. } else if (this.data.source_open) {
  84. this.setData({
  85. source_open: false,
  86. style_open: false,
  87. district_open: false,
  88. filter_open: false,
  89. })
  90. } else if (this.data.style_open) {
  91. this.setData({
  92. source_open: false,
  93. style_open: false,
  94. district_open: false,
  95. filter_open: false,
  96. })
  97. } else if (this.data.filter_open) {
  98. this.setData({
  99. source_open: false,
  100. style_open: false,
  101. district_open: false,
  102. filter_open: false,
  103. })
  104. }
  105. },
  106. },
  107. //组件生命周期函数,在组件实例进入页面节点树时执行
  108. attached: function() {
  109. },
  110. })