index.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. import baseComponent from '../helpers/baseComponent'
  2. import classNames from '../helpers/libs/classNames'
  3. import { useNativeRoute } from '../helpers/hooks/useNativeRoute'
  4. baseComponent({
  5. properties: {
  6. prefixCls: {
  7. type: String,
  8. value: 'wux-footer',
  9. },
  10. theme: {
  11. type: String,
  12. value: 'balanced',
  13. },
  14. label: {
  15. type: String,
  16. value: '',
  17. },
  18. content: {
  19. type: String,
  20. value: '',
  21. },
  22. links: {
  23. type: Array,
  24. value: [],
  25. },
  26. chips: {
  27. type: Array,
  28. value: [],
  29. },
  30. },
  31. computed: {
  32. classes: ['prefixCls, theme', function(prefixCls, theme) {
  33. const wrap = classNames(prefixCls, {
  34. [`${prefixCls}--${theme}`]: theme,
  35. })
  36. const label = `${prefixCls}__label`
  37. const content = `${prefixCls}__content`
  38. const links = `${prefixCls}__links`
  39. const link = `${prefixCls}__link`
  40. const chips = `${prefixCls}__chips`
  41. const chip = `${prefixCls}__chip`
  42. return {
  43. wrap,
  44. label,
  45. content,
  46. links,
  47. link,
  48. chips,
  49. chip,
  50. }
  51. }],
  52. },
  53. methods: {
  54. clickLinkItem(e) {
  55. const { index } = e.target.dataset
  56. const link = this.data.links[index]
  57. if (link) {
  58. if (link.url !== undefined) {
  59. useNativeRoute({
  60. url: link.url,
  61. openType: link.openType,
  62. delta: link.delta,
  63. }, this)
  64. }
  65. this.triggerEvent('linkClick', {
  66. item: link,
  67. index,
  68. })
  69. }
  70. },
  71. clickChipItem(e) {
  72. const { index } = e.target.dataset
  73. const chip = this.data.chips[index]
  74. if (chip && chip.type === 'link') {
  75. this.triggerEvent('chipClick', {
  76. item: chip,
  77. index,
  78. })
  79. }
  80. },
  81. },
  82. })