add: 新增宠物手册分类接口对接

This commit is contained in:
zlong committed 2024-12-10 23:46:02 +08:00
1 parent 5ca4ef7522
commit c096a2c69b
3 files changed
+25 -13

No files matched your search

+5 -2
View File
@@ -1,10 +1,13 @@
import type { CreateCarousalsRequest } from '@/model/carousals' import type { CreateCarousalsRequest, TypeList } from '@/model/carousals'
import httpClient from '@/api/httpClient' import httpClient from '@/api/httpClient'
function getCarousalList() { function getCarousalList() {
return httpClient.get<CreateCarousalsRequest[]>('/carousals/active-list') return httpClient.get<CreateCarousalsRequest[]>('/carousals/active-list')
} }
function getTypeList() {
return httpClient.get<TypeList[]>('/categories/list')
}
export default { export default {
getCarousalList, getCarousalList,
getTypeList,
} }
+7
View File
@@ -4,3 +4,10 @@ export interface CreateCarousalsRequest {
targetUrl: string targetUrl: string
targetId?: string targetId?: string
} }
export interface TypeList {
id: string
code: string
name: string
isClick?: boolean
}
+13 -11
View File
@@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import type { CreateCarousalsRequest } from '@/model/carousals' import type { CreateCarousalsRequest, TypeList } from '@/model/carousals'
import carousalApi from '@/api/carousal' import carousalApi from '@/api/carousal'
import CardList from '@/pages/pet-manual/components/CardList.vue' import CardList from '@/pages/pet-manual/components/CardList.vue'
// const searchValue = ref('') // const searchValue = ref('')
@@ -97,12 +97,7 @@ function change(e: CustomEvent<{ current: number }>): void {
current.value = e.detail.current current.value = e.detail.current
} }
const typeList = ref<TypeItem[]>([ const typeList = ref<TypeList[]>([])
{ name: '趣味科普', isClick: true },
{ name: '科学喂养', isClick: false },
{ name: '科学喂养', isClick: false },
{ name: '科学喂养', isClick: false },
])
function handleClickType(item: TypeItem) { function handleClickType(item: TypeItem) {
typeList.value.forEach(i => (i.isClick = false)) typeList.value.forEach(i => (i.isClick = false))
@@ -120,13 +115,20 @@ const historyList = ref<{ name: string }[]>([
{ name: '狗' }, { name: '狗' },
{ name: '烘培粮' }, { name: '烘培粮' },
]) ])
const findList = ref<{ name: string }[]>([ const findList = ref<{ name: string }[]>([
{ name: '宠物吃饭慢' }, { name: '宠物吃饭慢' },
{ name: '猫咪尿闭怎么办' }, { name: '猫咪尿闭怎么办' },
]) ])
async function onLoad() { async function init() {
info.value = await carousalApi.getCarousalList() info.value = await carousalApi.getCarousalList()
typeList.value = (await carousalApi.getTypeList()).map((item, index) => {
return {
name: item.name,
id: item.id,
code: item.code,
isClick: index === 0,
}
})
} }
function handleJumpUrl(item: CreateCarousalsRequest) { function handleJumpUrl(item: CreateCarousalsRequest) {
if (item.targetType === 'url') { if (item.targetType === 'url') {
@@ -135,7 +137,7 @@ function handleJumpUrl(item: CreateCarousalsRequest) {
}) })
} }
} }
onLoad() init()
</script> </script>
<template> <template>
@@ -198,7 +200,7 @@ onLoad()
<view class="ml-4 mt-5 text-[20px] font-600"> <view class="ml-4 mt-5 text-[20px] font-600">
养宠贴士 养宠贴士
</view> </view>
<view class="mx-4"> <view class="mx-4 sticky top-0 bg-[#f5f6f7]">
<scroll-view class="scroll mt-2" scroll-x="auto"> <scroll-view class="scroll mt-2" scroll-x="auto">
<view class="group h-[40px] mt-1"> <view class="group h-[40px] mt-1">
<view <view