feat: 文章详情完成

This commit is contained in:
ilhamtahir committed 2025-01-22 07:28:07 +08:00
1 parent b730f7966b
commit 1dfddbf1da
11 files changed
+88 -17

No files matched your search

+70
View File
@@ -0,0 +1,70 @@
<script setup lang="ts">
import type { Paging } from '@/model/base'
import type { Article } from '@/model/pet-manual'
import titleBg from '@/static/image/feed-plan/bg.png'
interface ContentText {
contentdown: string
contentrefresh: string
contentnomore: string
}
const props = withDefaults(defineProps<{
cardList: Article[]
pagination: Paging
}>(), {
pagination: {
page: 0,
size: 10,
total: 0,
},
})
const emit = defineEmits(['loadMore'])
const loadMoreStatus = computed(() => {
return props.pagination.size > props.pagination.total ? 'nomore' : 'more'
})
const contentText = ref<ContentText>({
contentdown: '查看更多',
contentrefresh: '加载中',
contentnomore: '没有更多',
})
function handleLoadMore() {
if (props.pagination.size > props.pagination.total) {
return
}
emit('loadMore')
}
function goToArticle(id: string) {
uni.navigateTo({
url: `/pages/article/detail?id=${id}`,
})
}
</script>
<template>
<view class="flex flex-col gap-4 px-4">
<view
v-for="(item, index) in props.cardList" :key="index" class="bg-[white] rounded-md shadow-lg flex w-full h-[120px] overflow-hidden"
@tap="() => goToArticle(item.id)"
>
<image class="w-[120px] h-[120px] rounded-l-md shrink-0" :src="item?.imageUrl || titleBg" />
<view class="p-4 flex flex-col">
<view class="text-[14px]">
{{ item.title }}
</view>
<view class="mt-2 flex-1 text-[11px] leading-3 text-[#999] whitespace-pre-line line-clamp-3 w-full overflow-hidden">
{{ item.description }}
</view>
<view class="mt-3 text-[10px] text-[#D8D8D8]">
{{ item.updatedTime }}
</view>
</view>
</view>
<uni-load-more :status="loadMoreStatus" :content-text="contentText" @click-load-more="handleLoadMore" />
</view>
</template>
<style scoped>
</style>