You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

list-item.vue 2.1 KiB

4 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <template>
  2. <view @click="$emit('click', $event)" :class="arrow ? 'arrow' : ''" class="cu-item">
  3. <slot name="avatar">
  4. <l-avatar
  5. v-if="avatar"
  6. :src="avatar"
  7. :radius="!roundAvatar"
  8. :round="roundAvatar"
  9. :style="avatarStyle"
  10. size="lg"
  11. />
  12. <image
  13. v-else-if="imgAvatar"
  14. :src="imgAvatar"
  15. :style="`border-radius: ${roundAvatar ? '50%' : '3px'}; ` + imgStyle"
  16. mode="aspectFill"
  17. class="list-item-imgAvatar"
  18. />
  19. <l-icon
  20. v-else-if="iconAvatar"
  21. :type="iconAvatar"
  22. :style="`border-radius: ${roundAvatar ? '50%' : '3px'}; ` + iconStyle"
  23. class="list-item-iconAvatar flex justify-center align-center"
  24. />
  25. </slot>
  26. <view class="content">
  27. <view class="text-grey">
  28. <slot>{{ title }}</slot>
  29. </view>
  30. <view v-if="extra || $slots.extra" class="text-gray text-sm flex">
  31. <view class="text-cut text-grey">
  32. <slot name="extra">{{ extra }}</slot>
  33. </view>
  34. </view>
  35. </view>
  36. <view class="action">
  37. <view v-if="times" class="text-grey text-sm">
  38. <view v-if="times" style="display: flex; flex-direction: column; align-items: flex-end;">
  39. <view class="text-right margin-bottom-xs">{{ times[0] }}</view>
  40. <view v-if="times[1]" class="text-right">{{ times[1] }}</view>
  41. </view>
  42. </view>
  43. <view v-else-if="time || $slots.time || $slots.tips" class="text-grey text-sm">
  44. <slot name="time">{{ time }}</slot>
  45. <slot name="tips"></slot>
  46. </view>
  47. <template v-else>
  48. <slot name="action">{{ action }}</slot>
  49. </template>
  50. </view>
  51. </view>
  52. </template>
  53. <script>
  54. export default {
  55. name: 'l-list-item',
  56. props: {
  57. title: { default: '' },
  58. action: { default: '' },
  59. arrow: {},
  60. extra: { default: '' },
  61. time: { default: '' },
  62. times: {},
  63. roundAvatar: {},
  64. avatar: {},
  65. avatarStyle: { default: '' },
  66. iconAvatar: {},
  67. iconStyle: { default: '' },
  68. imgAvatar: { default: '' },
  69. imgStyle: { default: '' }
  70. }
  71. }
  72. </script>