feat: 文章详情完成
This commit is contained in:
1 parent
b730f7966b
commit
1dfddbf1da
11 files changed
+88
-17
No files matched your search
@@ -0,0 +1,46 @@
|
||||
<script setup lang="ts">
|
||||
import type { Article } from '@/model/pet-manual'
|
||||
import { getArticle } from '@/api/article'
|
||||
|
||||
const article = ref<Article | null>()
|
||||
|
||||
const id = ref('')
|
||||
|
||||
onLoad((options) => {
|
||||
id.value = options!.id as string
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
fetchData()
|
||||
})
|
||||
|
||||
async function fetchData() {
|
||||
article.value = await getArticle(id.value)
|
||||
await uni.setNavigationBarTitle({
|
||||
title: article.value.category.name,
|
||||
})
|
||||
}
|
||||
|
||||
const fixedContent = computed(() => {
|
||||
if (!article.value) {
|
||||
return ''
|
||||
}
|
||||
return article.value.content.replace(/<img/g, '<img class="w-full"')
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view v-if="article" class="w-full h-screen p-4 bg-[#F5F6F7]">
|
||||
<view class="mb-2 text-xl font-semibold">
|
||||
{{ article.title }}
|
||||
</view>
|
||||
<view class="flex text-xs text-[#999] mb-6">
|
||||
<view>{{ article.createdTime }}</view>
|
||||
</view>
|
||||
<rich-text :nodes="fixedContent" />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@@ -1,63 +0,0 @@
|
||||
<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')
|
||||
}
|
||||
</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"
|
||||
>
|
||||
<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>
|
||||
@@ -2,7 +2,7 @@
|
||||
import type { Paging } from '@/model/base'
|
||||
import type { Article, ArticleParams, Category, CreateCarousalsRequest, Recommends } from '@/model/pet-manual'
|
||||
import carousalApi from '@/api/carousal'
|
||||
import CardList from '@/pages/pet-manual/components/CardList.vue'
|
||||
import CardList from '@/components/CardList.vue'
|
||||
import circle from '@/static/image/feed-plan/circle.png'
|
||||
import message from '@/static/image/feed-plan/message.png'
|
||||
import ToolApi from '@/utils'
|
||||
|
||||
Reference in new issue
Block a user