CardList.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <script setup lang="ts">
  2. import type { Paging } from '@/model/base'
  3. import type { Article } from '@/model/pet-manual'
  4. import titleBg from '@/static/image/feed-plan/bg.png'
  5. interface ContentText {
  6. contentdown: string
  7. contentrefresh: string
  8. contentnomore: string
  9. }
  10. const props = withDefaults(defineProps<{
  11. cardList: Article[]
  12. pagination: Paging
  13. }>(), {
  14. pagination: {
  15. page: 0,
  16. size: 10,
  17. total: 0,
  18. },
  19. })
  20. const emit = defineEmits(['loadMore'])
  21. const loadMoreStatus = computed(() => {
  22. return props.pagination.size > props.pagination.total ? 'nomore' : 'more'
  23. })
  24. const contentText = ref<ContentText>({
  25. contentdown: '查看更多',
  26. contentrefresh: '加载中',
  27. contentnomore: '没有更多',
  28. })
  29. function handleLoadMore() {
  30. if (props.pagination.size > props.pagination.total) {
  31. return
  32. }
  33. emit('loadMore')
  34. }
  35. </script>
  36. <template>
  37. <view class="flex flex-col gap-4 px-4">
  38. <view
  39. v-for="(item, index) in props.cardList" :key="index" class="bg-[white] rounded-md shadow-lg flex w-full h-[120px] overflow-hidden"
  40. >
  41. <image class="w-[120px] h-[120px] rounded-l-md shrink-0" :src="item?.imageUrl || titleBg" />
  42. <view class="p-4 flex flex-col">
  43. <view class="text-[14px]">
  44. {{ item.title }}
  45. </view>
  46. <view class="mt-2 flex-1 text-[11px] leading-3 text-[#999] whitespace-pre-line line-clamp-3 w-full overflow-hidden">
  47. {{ item.description }}
  48. </view>
  49. <view class="mt-3 text-[10px] text-[#D8D8D8]">
  50. {{ item.updatedTime }}
  51. </view>
  52. </view>
  53. </view>
  54. <uni-load-more :status="loadMoreStatus" :content-text="contentText" @click-load-more="handleLoadMore" />
  55. </view>
  56. </template>
  57. <style scoped>
  58. </style>