fix(home): 修复 home 页面无限滚动加载问题

- 调整 pageRef 的初始值,将 page 设置为 0
- 在 ItemList 组件中添加完成加载的判断条件
- 优化 getDetail 函数,使用 currentItem.value.uuid 替代 artworkUuid
-移除首页初始化数据加载逻辑
This commit is contained in:
xingyy 2025-01-22 09:32:24 +08:00
parent ad9899d716
commit fc3e833605
3 changed files with 14 additions and 14 deletions

View File

@ -15,6 +15,12 @@ const getArtworkList=async ()=>{
if (Array.isArray(res.data.data)&&res.data.data?.length>0){
itemList.value.push(...res.data.data)
}
if (!res.data.data){
finished.value=true
}
if (res.data.data?.length<pageRef.value.pageSize){
finished.value=true
}
pageRef.value.itemCount=res.data.count
}
}
@ -45,11 +51,15 @@ const refreshData = async () => {
}
const getDetail=async ()=>{
const res=await artworkDetail({uuid:currentItem.value.artworkUuid})
const res=await artworkDetail({uuid:currentItem.value.uuid})
if (res.status===0){
artWorkDetail.value
}
}
watch(itemList,(newValue)=>{
console.log('newValue',newValue)
})
const openShow = (item,index) => {
currentItem.value=item
getDetail()
@ -63,7 +73,7 @@ const openShow = (item,index) => {
<template>
<div class="px-[16px] pt-[16px]">
<van-pull-refresh v-model="loading1" success-text="刷新成功" @refresh="refreshData">
<van-list :immediate-check="false" v-model:loading="loading" :finished="finished" finished-text="没有更多了"
<van-list v-model:loading="loading" :finished="finished" finished-text="没有更多了"
@load="loadData">
<div class="w-full flex gap-[16px]">
<Column v-for="(column, colIndex) in columns" :key="colIndex" :colIndex="colIndex" :items="column" @openShow="openShow" />

View File

@ -12,17 +12,7 @@ definePageMeta({
const changeLive = () => {
fullLive.value = true;
};
const initData=async ()=>{
await getAuctionDetail()
const res= await artworkList({auctionUuid: auctionDetail.value.uuid,...pageRef.value})
if (res.status===0){
if (Array.isArray(res.data.data)&&res.data.data?.length>0){
itemList.value=res.data.data
}
pageRef.value.itemCount=res.data.count
}
}
initData()
</script>
<template>

View File

@ -8,7 +8,7 @@ export const goodStore = createGlobalState(() => {
const currentItem=ref({})
const myArtWorks=ref([])
const pageRef = ref({
page: 1,
page: 0,
pageSize: 5,
itemCount: 0
})