修改listing分页

This commit is contained in:
yuyongdong 2024-07-04 18:56:44 +08:00
parent a912c1fe61
commit 64fa8dd4c4
4 changed files with 57 additions and 49 deletions

View File

@ -83,12 +83,8 @@ const getMyAssets = async () => {
try {
let nftListBox
let res = await apiAssetsState(myADdress, data)
// nftList.value = Array.from(new Set([...res.rows, ...nftList.value].map(JSON.stringify))).map(JSON.parse);
nftList.value = [...res.rows, ...nftList.value]
// console.log(toRaw(nftList.value))
// debugger
nftList.value = [...nftList.value, ...res.rows]
nftListBox = nftList.value.reduce((acc, obj) => {
// console.log(acc,obj)
const existingObj = acc.find(item => item.token_id == obj.token_id)
if(!existingObj) {
acc.push(obj)
@ -96,7 +92,6 @@ const getMyAssets = async () => {
return acc
},[])
nftList.value = nftListBox
// console.log(nftListBox)
marketplaceStore.cursorObj = res.page
next_cursor.value = res.page.next_cursor
} catch(e) {

View File

@ -40,18 +40,36 @@ const statusChild = (val) => {
getHistoryList()
}
const next_cursor = ref()
const next_cursor = ref({
type: 0,
page_size: '20',
cursor: '',
search_name: '',
total_count: 0,
})
const getHistoryList = async () => {
const myADdress = localWalletStore.address
const data = {
type: statusValue.value,
page_size: '20',
cursor: '',
cursor: next_cursor.value.next_cursor,
search_name: overviewValue.value,
}
if(myADdress) {
let nftListBox
let res = await apiHistoryState(myADdress,data)
for (let sub of res.rows) {
console.log(res)
next_cursor.value = res.page
nftList.value = [...nftList.value, ...res.rows]
nftListBox = nftList.value.reduce((acc, obj) => {
const existingObj = acc.find(item => item.nft.token_id == obj.nft.token_id)
if(!existingObj) {
acc.push(obj)
}
return acc
},[])
// nftList.value = nftListBox
for (let sub of nftListBox) {
if (sub.event?.data) {
const _data = parseTradeEvent(sub.event)
sub.event.icon = _data.icon
@ -61,35 +79,28 @@ const getHistoryList = async () => {
sub.event.decimals = _data.decimals
}
}
nftList.value = res.rows
nftList.value = nftListBox
}
}
// const handleScroll = () => {
// const myADdress = localWalletStore.address
// var scrollTop =
// document.documentElement.scrollTop || document.body.scrollTop; //windowHeight
// var windowHeight =
// document.documentElement.clientHeight || document.body.clientHeight; //scrollHeight
// var scrollHeight =
// document.documentElement.scrollHeight || document.body.scrollHeight;
// if (scrollTop + windowHeight == scrollHeight) {
// //
// // this.seeMoreSchoolList();
// // console.log('scrollTop + windowHeight == scrollHeight',toRaw(marketplaceStore.cursorObj), scrollTop, windowHeight, scrollHeight)
// if(myADdress) {
// // if(toRaw(marketplaceStore.cursorObj).remaining != 0) {
// getHistoryList()
// console.log('')
// // // } else {
// // // console.log('')
// // } else {
// // return false;
// // }
// // return false;
// }
// }
// }
const handleScroll = () => {
const myADdress = localWalletStore.address
var scrollTop =
document.documentElement.scrollTop || document.body.scrollTop; //windowHeight
var windowHeight =
document.documentElement.clientHeight || document.body.clientHeight; //scrollHeight
var scrollHeight =
document.documentElement.scrollHeight || document.body.scrollHeight;
if (scrollTop + windowHeight == scrollHeight) {
//
// this.seeMoreSchoolList();
// console.log('scrollTop + windowHeight == scrollHeight',toRaw(marketplaceStore.cursorObj), scrollTop, windowHeight, scrollHeight)
if(next_cursor.value.remaining != 0) {
getHistoryList()
}
return false;
}
}
watch(localWalletStore,() => {
if(!localWalletStore.token) {
@ -101,12 +112,12 @@ watch(localWalletStore,() => {
onMounted(() => {
getHistoryList()
// window.addEventListener("scroll", handleScroll, true);
window.addEventListener("scroll", handleScroll, true);
})
// onUnmounted(() => {
// window.removeEventListener('scroll', handleScroll)
// })
onUnmounted(() => {
window.removeEventListener('scroll', handleScroll)
})
</script>
<style lang="scss" scoped>

View File

@ -342,7 +342,6 @@ const selectChange = (index) => {
}
}
.hero-name {
// width: 120px;
height: 40px;
color: #fff;
font-size: 90px;

View File

@ -269,6 +269,7 @@ const searchName = (id) => {
const renewNft = async() => {
let timer = setTimeout(() => {
getHeroData()
// location.reload()
clearTimeout(timer);
}, 2000);
}
@ -279,19 +280,21 @@ const totalCount = ref(0)
const getHeroData = async () => {
// loadingDialogVisible.value = false;
try {
let nftListBox
// const { errcode, errmsg, rows, page } = await marketplaceList.getMarketplaceState(reqData.value)
const { errcode, errmsg, rows, page } = await apiMarketplaceState(reqData.value)
// console.log((toRaw(marketplaceList.cursorObj))
if(!errmsg) {
nftList.value = [...rows, ...nftList.value]
nftList.value = Array.from(new Set(nftList.value.map(JSON.stringify))).map(JSON.parse);
// nftList.value = nftList.value.reduce((acc, obj) => {
// const existingObj = acc.find(item => item.nft.token_id == obj.nft.token_id)
// if(!existingObj) {
// acc.push(obj)
// }
// return acc
// },[])
nftList.value = [...nftList.value, ...rows]
// nftList.value = Array.from(new Set(nftList.value.map(JSON.stringify))).map(JSON.parse);
nftListBox = nftList.value.reduce((acc, obj) => {
const existingObj = acc.find(item => item.event == obj.event)
if(!existingObj) {
acc.push(obj)
}
return acc
},[])
nftList.value = nftListBox
totalCount.value = page.total_count
cursorObj.value = page
marketplaceList.cursorObj = page