Update API formatting and routing structure
This commit is contained in:
@ -2,8 +2,8 @@
|
||||
<!-- 导航 -->
|
||||
<KlNavTab active="交流频道" />
|
||||
<div class="ma-auto mt-[30px] w-[1440px] flex">
|
||||
<LeftContent v-model="pageReq.channelId"></LeftContent>
|
||||
<RightContent v-model="pageRes" v-model:lun-tan-res="lunTanRes" v-model:page-no="pageReq.pageNo" @update-page-no="handleUpdatePageNo"></RightContent>
|
||||
<LeftContent v-model="pageReq.channelId" v-model:channelIdList="channelIdList"></LeftContent>
|
||||
<!-- <RightContent v-model="pageRes" v-model:lun-tan-res="lunTanRes" v-model:page-no="pageReq.pageNo" @update-page-no="handleUpdatePageNo"></RightContent> -->
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
import KlNavTab from '~/components/kl-nav-tab/index.vue'
|
||||
import LeftContent from './components/LeftContent.vue'
|
||||
import RightContent from './components/RightContent.vue'
|
||||
import { page, getChannelLunTanDetail } from '~/api/channel/index'
|
||||
import { page, getChannelLunTanDetail, list } from '~/api/channel/index'
|
||||
import { reactive, watch, ref } from 'vue'
|
||||
import type { TpageRes, ChannelRespVO } from '~/api/channel/types'
|
||||
|
||||
@ -25,44 +25,59 @@
|
||||
total: 0,
|
||||
})
|
||||
|
||||
// 获取频道列表
|
||||
const { data: channelIdList } = await useAsyncData(`prod-api/app-api/business/channel/list-${Date.now()}`, async () => {
|
||||
const res = await list()
|
||||
return res.data as any[]
|
||||
})
|
||||
|
||||
// console.log(channelIdList)
|
||||
|
||||
// 获取第一个论坛详情
|
||||
// if (!channelIdList.value?.length) return
|
||||
// const { data: lunTanRes, execute } = await useAsyncData(`prod-api/app-api/business/channel/detail-${Date.now()}`, async () => {
|
||||
// const res = await getChannelLunTanDetail({
|
||||
// id: channelIdList.value?.[0].channelId,
|
||||
// })
|
||||
// return res.data as ChannelRespVO
|
||||
// })
|
||||
|
||||
// const {data:pageRes, refresh:getPage} = await useAsyncData(`prod-api/app-api/business/posts/page-${Date.now()}`, async () => {
|
||||
// const res = await page(pageReq)
|
||||
// return res.data as TpageRes
|
||||
// })
|
||||
// 获得频道帖子分页
|
||||
const getPage = () => {
|
||||
page(pageReq).then((res) => {
|
||||
pageRes.list = res.data.list
|
||||
pageRes.total = res.data.total
|
||||
})
|
||||
}
|
||||
getPage()
|
||||
// 获得频道帖子分页
|
||||
// const getPage = () => {
|
||||
// page(pageReq).then((res) => {
|
||||
// pageRes.list = res.data.list
|
||||
// pageRes.total = res.data.total
|
||||
// })
|
||||
// }
|
||||
// getPage()
|
||||
|
||||
const handleUpdatePageNo = (pageNo: number) => {
|
||||
pageReq.pageNo = pageNo
|
||||
getPage()
|
||||
}
|
||||
// const handleUpdatePageNo = (pageNo: number) => {
|
||||
// pageReq.pageNo = pageNo
|
||||
// getPage()
|
||||
// }
|
||||
|
||||
// 获取论坛详情
|
||||
const lunTanRes = ref({} as ChannelRespVO)
|
||||
const getLunTanDetaiil = (val: string) => {
|
||||
getChannelLunTanDetail({
|
||||
id: val,
|
||||
}).then((res) => {
|
||||
lunTanRes.value = res.data
|
||||
})
|
||||
}
|
||||
// const lunTanRes = ref({} as ChannelRespVO)
|
||||
// const getLunTanDetaiil = (val: string) => {
|
||||
// getChannelLunTanDetail({
|
||||
// id: val,
|
||||
// }).then((res) => {
|
||||
// lunTanRes.value = res.data
|
||||
// })
|
||||
// }
|
||||
|
||||
watch(
|
||||
() => pageReq.channelId,
|
||||
() => channelIdList.value,
|
||||
(val) => {
|
||||
if (val) {
|
||||
console.log(val);
|
||||
|
||||
getPage()
|
||||
getLunTanDetaiil(val)
|
||||
navigateTo(`/channel/${val[0].channelId}/1`)
|
||||
}
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user