index.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import baseComponent from '../helpers/baseComponent'
  2. import classNames from '../helpers/classNames'
  3. baseComponent({
  4. relations: {
  5. '../grids/index': {
  6. type: 'parent',
  7. },
  8. },
  9. properties: {
  10. prefixCls: {
  11. type: String,
  12. value: 'wux-grid',
  13. },
  14. hoverClass: {
  15. type: String,
  16. value: 'default',
  17. },
  18. thumb: {
  19. type: String,
  20. value: '',
  21. },
  22. label: {
  23. type: String,
  24. value: '',
  25. },
  26. },
  27. data: {
  28. width: '100%',
  29. bordered: true,
  30. square: true,
  31. index: 0,
  32. },
  33. computed: {
  34. classes() {
  35. const { prefixCls, hoverClass, bordered, square } = this.data
  36. const wrap = classNames(prefixCls, {
  37. [`${prefixCls}--bordered`]: bordered,
  38. [`${prefixCls}--square`]: square,
  39. })
  40. const content = `${prefixCls}__content`
  41. const inner = `${prefixCls}__inner`
  42. const hd = `${prefixCls}__hd`
  43. const thumb = `${prefixCls}__thumb`
  44. const bd = `${prefixCls}__bd`
  45. const label = `${prefixCls}__label`
  46. const hover = hoverClass && hoverClass !== 'default' ? hoverClass : `${prefixCls}--hover`
  47. return {
  48. wrap,
  49. content,
  50. inner,
  51. hd,
  52. thumb,
  53. bd,
  54. label,
  55. hover,
  56. }
  57. },
  58. },
  59. methods: {
  60. changeCurrent(width, bordered, square, index) {
  61. this.setData({
  62. width,
  63. bordered,
  64. square,
  65. index,
  66. })
  67. },
  68. onTap() {
  69. this.triggerEvent('click', this.data)
  70. },
  71. },
  72. })