fix(home): 修复 home 页面无限滚动加载问题
- 调整 pageRef 的初始值,将 page 设置为 0 - 在 ItemList 组件中添加完成加载的判断条件 - 优化 getDetail 函数,使用 currentItem.value.uuid 替代 artworkUuid -移除首页初始化数据加载逻辑
This commit is contained in:
parent
ad9899d716
commit
fc3e833605
@ -15,6 +15,12 @@ const getArtworkList=async ()=>{
|
|||||||
if (Array.isArray(res.data.data)&&res.data.data?.length>0){
|
if (Array.isArray(res.data.data)&&res.data.data?.length>0){
|
||||||
itemList.value.push(...res.data.data)
|
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
|
pageRef.value.itemCount=res.data.count
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -45,11 +51,15 @@ const refreshData = async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const getDetail=async ()=>{
|
const getDetail=async ()=>{
|
||||||
const res=await artworkDetail({uuid:currentItem.value.artworkUuid})
|
const res=await artworkDetail({uuid:currentItem.value.uuid})
|
||||||
if (res.status===0){
|
if (res.status===0){
|
||||||
artWorkDetail.value
|
artWorkDetail.value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
watch(itemList,(newValue)=>{
|
||||||
|
console.log('newValue',newValue)
|
||||||
|
|
||||||
|
})
|
||||||
const openShow = (item,index) => {
|
const openShow = (item,index) => {
|
||||||
currentItem.value=item
|
currentItem.value=item
|
||||||
getDetail()
|
getDetail()
|
||||||
@ -63,7 +73,7 @@ const openShow = (item,index) => {
|
|||||||
<template>
|
<template>
|
||||||
<div class="px-[16px] pt-[16px]">
|
<div class="px-[16px] pt-[16px]">
|
||||||
<van-pull-refresh v-model="loading1" success-text="刷新成功" @refresh="refreshData">
|
<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">
|
@load="loadData">
|
||||||
<div class="w-full flex gap-[16px]">
|
<div class="w-full flex gap-[16px]">
|
||||||
<Column v-for="(column, colIndex) in columns" :key="colIndex" :colIndex="colIndex" :items="column" @openShow="openShow" />
|
<Column v-for="(column, colIndex) in columns" :key="colIndex" :colIndex="colIndex" :items="column" @openShow="openShow" />
|
||||||
|
@ -12,17 +12,7 @@ definePageMeta({
|
|||||||
const changeLive = () => {
|
const changeLive = () => {
|
||||||
fullLive.value = true;
|
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>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -8,7 +8,7 @@ export const goodStore = createGlobalState(() => {
|
|||||||
const currentItem=ref({})
|
const currentItem=ref({})
|
||||||
const myArtWorks=ref([])
|
const myArtWorks=ref([])
|
||||||
const pageRef = ref({
|
const pageRef = ref({
|
||||||
page: 1,
|
page: 0,
|
||||||
pageSize: 5,
|
pageSize: 5,
|
||||||
itemCount: 0
|
itemCount: 0
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user