|
|
@@ -1,80 +1,24 @@
|
|
|
<script setup lang="ts">
|
|
|
-import type { CreateCarousalsRequest, TypeList } from '@/model/carousals'
|
|
|
+import type { Paging } from '@/model/base'
|
|
|
+import type { Article, ArticleParams, Category, CreateCarousalsRequest } from '@/model/pet-manual'
|
|
|
import carousalApi from '@/api/carousal'
|
|
|
import CardList from '@/pages/pet-manual/components/CardList.vue'
|
|
|
-// const searchValue = ref('')
|
|
|
-import bg from '@/static/image/feed-plan/bg.png'
|
|
|
import circle from '@/static/image/feed-plan/circle.png'
|
|
|
import message from '@/static/image/feed-plan/message.png'
|
|
|
import ToolApi from '@/utils'
|
|
|
|
|
|
-interface ListItem {
|
|
|
- img: string
|
|
|
- title: string
|
|
|
- desc: string
|
|
|
- time: string
|
|
|
-}
|
|
|
-// interface Item {
|
|
|
-// content: string
|
|
|
-// }
|
|
|
interface DotStyle {
|
|
|
backgroundColor: string
|
|
|
selectedBackgroundColor: string
|
|
|
selectedBorder: string
|
|
|
border: string
|
|
|
}
|
|
|
-interface TypeItem {
|
|
|
- name: string
|
|
|
- isClick: boolean
|
|
|
-}
|
|
|
+
|
|
|
const titleName = ref<string>('养宠手册')
|
|
|
-const listModel = ref<ListItem[]>([
|
|
|
- {
|
|
|
- img: bg,
|
|
|
- title: '猫咪食物禁忌',
|
|
|
- desc: '1 饮食不慎 2 寄生虫\n 3 病毒感染 4 细菌和毒素感染',
|
|
|
- time: '2025年1月1日',
|
|
|
- },
|
|
|
- {
|
|
|
- img: bg,
|
|
|
- title: '猫咪食物禁忌',
|
|
|
- desc: '1 饮食不慎 2 寄生虫\n 3 病毒感染 4 细菌和毒素感染',
|
|
|
- time: '2025年1月1日',
|
|
|
- },
|
|
|
- {
|
|
|
- img: bg,
|
|
|
- title: '猫咪食物禁忌',
|
|
|
- desc: '1 饮食不慎 2 寄生虫\n 3 病毒感染 4 细菌和毒素感染',
|
|
|
- time: '2025年1月1日',
|
|
|
- },
|
|
|
- {
|
|
|
- img: bg,
|
|
|
- title: '猫咪食物禁忌',
|
|
|
- desc: '1 饮食不慎 2 寄生虫\n 3 病毒感染 4 细菌和毒素感染',
|
|
|
- time: '2025年1月1日',
|
|
|
- },
|
|
|
- {
|
|
|
- img: bg,
|
|
|
- title: '猫咪食物禁忌',
|
|
|
- desc: '1 饮食不慎 2 寄生虫\n 3 病毒感染 4 细菌和毒素感染',
|
|
|
- time: '2025年1月1日',
|
|
|
- },
|
|
|
- {
|
|
|
- img: bg,
|
|
|
- title: '猫咪食物禁忌',
|
|
|
- desc: '1 饮食不慎 2 寄生虫\n 3 病毒感染 4 细菌和毒素感染',
|
|
|
- time: '2025年1月1日',
|
|
|
- },
|
|
|
- {
|
|
|
- img: bg,
|
|
|
- title: '猫咪食物禁忌',
|
|
|
- desc: '1 饮食不慎 2 寄生虫\n 3 病毒感染 4 细菌和毒素感染',
|
|
|
- time: '2025年1月1日',
|
|
|
- },
|
|
|
-])
|
|
|
+const listModel = ref<Article[]>([])
|
|
|
const safeHeight = ToolApi.getSafeHeight()
|
|
|
const searchValue = ref<string>('')
|
|
|
-
|
|
|
+const cardState = ref<'update' | 'updatePage'>('update')
|
|
|
const info = ref<CreateCarousalsRequest[]>([
|
|
|
{
|
|
|
imageUrl: '',
|
|
|
@@ -97,11 +41,25 @@ function change(e: CustomEvent<{ current: number }>): void {
|
|
|
current.value = e.detail.current
|
|
|
}
|
|
|
|
|
|
-const typeList = ref<TypeList[]>([])
|
|
|
+const typeList = ref<Category[]>([])
|
|
|
+const articleParams = ref<ArticleParams>({
|
|
|
+ page: 1,
|
|
|
+ size: 10,
|
|
|
+ title: '',
|
|
|
+ categoryId: '',
|
|
|
+})
|
|
|
+const articlePaging = ref<Paging>({
|
|
|
+ page: 1,
|
|
|
+ size: 10,
|
|
|
+ total: 0,
|
|
|
+})
|
|
|
|
|
|
-function handleClickType(item: TypeItem) {
|
|
|
+async function handleClickType(item: Category) {
|
|
|
typeList.value.forEach(i => (i.isClick = false))
|
|
|
item.isClick = true
|
|
|
+ articleParams.value.categoryId = item.id
|
|
|
+ cardState.value = 'updatePage'
|
|
|
+ await updateArticleList()
|
|
|
}
|
|
|
const isSearch = ref<boolean>(true)
|
|
|
function handleSearchFocus() {
|
|
|
@@ -119,6 +77,25 @@ const findList = ref<{ name: string }[]>([
|
|
|
{ name: '宠物吃饭慢' },
|
|
|
{ name: '猫咪尿闭怎么办' },
|
|
|
])
|
|
|
+async function updateArticleList() {
|
|
|
+ const articleListApi = await carousalApi.getArticleList(articleParams.value)
|
|
|
+ if (cardState.value === 'update') {
|
|
|
+ listModel.value = articleListApi.data
|
|
|
+ }
|
|
|
+ else if (cardState.value === 'updatePage') {
|
|
|
+ listModel.value.push(...articleListApi.data)
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ listModel.value = articleListApi.data
|
|
|
+ }
|
|
|
+ articlePaging.value = articleListApi.pagination
|
|
|
+}
|
|
|
+
|
|
|
+async function handleLoadArticle() {
|
|
|
+ articleParams.value.page += 1
|
|
|
+ cardState.value = 'updatePage'
|
|
|
+ await updateArticleList()
|
|
|
+}
|
|
|
async function init() {
|
|
|
info.value = await carousalApi.getCarousalList()
|
|
|
typeList.value = (await carousalApi.getTypeList()).map((item, index) => {
|
|
|
@@ -129,7 +106,10 @@ async function init() {
|
|
|
isClick: index === 0,
|
|
|
}
|
|
|
})
|
|
|
+ articleParams.value.categoryId = typeList.value[0].id
|
|
|
+ await updateArticleList()
|
|
|
}
|
|
|
+
|
|
|
function handleJumpUrl(item: CreateCarousalsRequest) {
|
|
|
if (item.targetType === 'url') {
|
|
|
uni.navigateTo({
|
|
|
@@ -218,7 +198,7 @@ init()
|
|
|
</view>
|
|
|
</scroll-view>
|
|
|
</view>
|
|
|
- <CardList :card-list="listModel" />
|
|
|
+ <CardList :card-list="listModel" @load-more="handleLoadArticle" />
|
|
|
</view>
|
|
|
</view>
|
|
|
</template>
|