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.4 KiB

4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <view @click="$emit('click', $event)" :class="[arrow ? 'arrow' : '', className]" :style="style" 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. <text
  20. v-else-if="iconAvatar"
  21. :class="'cuIcon-' + iconAvatar"
  22. :style="`border-radius: ${roundAvatar ? '50%' : '3px'}; ` + iconStyle"
  23. class="list-item-iconAvatar flex justify-center align-center"
  24. ></text>
  25. <!-- 支付宝小程序,使用 l-icon 报错 -->
  26. <!--
  27. <l-icon
  28. v-else-if="iconAvatar"
  29. :type="iconAvatar"
  30. :style="`border-radius: ${roundAvatar ? '50%' : '3px'}; ` + iconStyle"
  31. class="flex justify-center align-center"
  32. />
  33. -->
  34. </slot>
  35. <view class="content">
  36. <view class="text-grey">
  37. <slot></slot>
  38. {{ title || '' }}
  39. </view>
  40. <view v-if="extra || $slots.extra" class="text-gray text-sm flex">
  41. <view class="text-cut text-grey">
  42. <slot name="extra">{{ extra }}</slot>
  43. </view>
  44. </view>
  45. </view>
  46. <view class="action">
  47. <view v-if="times" class="text-grey text-sm">
  48. <view v-if="times" style="display: flex; flex-direction: column; align-items: flex-end;">
  49. <view class="text-right margin-bottom-xs">{{ times[0] }}</view>
  50. <view v-if="times[1]" class="text-right">{{ times[1] }}</view>
  51. </view>
  52. </view>
  53. <view v-else-if="time || $slots.time || $slots.tips" class="text-grey text-sm">
  54. <slot name="time">{{ time || '' }}</slot>
  55. <slot name="tips"></slot>
  56. </view>
  57. <template v-else>
  58. <slot name="action">{{ action }}</slot>
  59. </template>
  60. </view>
  61. </view>
  62. </template>
  63. <script>
  64. export default {
  65. name: 'l-list-item',
  66. props: {
  67. title: {},
  68. action: {},
  69. arrow: {},
  70. extra: {},
  71. time: { default: '' },
  72. times: {},
  73. roundAvatar: {},
  74. avatar: {},
  75. avatarStyle: { default: '' },
  76. iconAvatar: {},
  77. iconStyle: { default: '' },
  78. imgAvatar: { default: '' },
  79. imgStyle: { default: '' }
  80. }
  81. }
  82. </script>