index.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // common/components/drop-down/index.js
  2. Component({
  3. /**
  4. * 组件的属性列表
  5. */
  6. options: {
  7. addGlobalClass: true,
  8. externalClasses: ['drop-con']
  9. },
  10. properties: {
  11. navItems: {
  12. type: Object,
  13. value: false,
  14. observer(newVal, oldVal, changedPath) {
  15. }
  16. },
  17. exhiNum: {
  18. type: Number,
  19. value: 0,
  20. observer(newVal, oldVal, changedPath) {
  21. }
  22. },
  23. activeType: {
  24. type: String,
  25. value: 0,
  26. observer(newVal, oldVal, changedPath) {
  27. }
  28. },
  29. activeDist: {
  30. type: String,
  31. value: 0,
  32. observer(newVal, oldVal, changedPath) {
  33. }
  34. }
  35. },
  36. /**
  37. * 组件的初始数据
  38. */
  39. data: {
  40. activeIdx: 1
  41. },
  42. /**
  43. * 组件的方法列表
  44. */
  45. methods: {
  46. closeMask() {
  47. const myEventDetail = false // detail对象,提供给事件监听函数
  48. const myEventOption = {} // 触发事件的选项
  49. this.triggerEvent('closeMask', myEventDetail, myEventOption)
  50. },
  51. topItem(e) {
  52. console.log()
  53. let type = this.data.navItems.type
  54. let id = e.currentTarget.dataset.id
  55. let myEventDetail, myEventOption
  56. if (type){
  57. if (type === "dist") {
  58. myEventDetail = {
  59. activeType: this.data.activeType,
  60. activeDist: id
  61. } // detail对象,提供给事件监听函数
  62. myEventOption = {} // 触发事件的选项
  63. }
  64. else {
  65. myEventDetail = {
  66. activeType: id,
  67. activeDist: this.data.activeDist
  68. } // detail对象,提供给事件监听函数
  69. myEventOption = {} // 触发事件的选项
  70. }
  71. this.triggerEvent('activeItem', myEventDetail, myEventOption)
  72. }
  73. }
  74. }
  75. })