修改listing分页
This commit is contained in:
parent
a912c1fe61
commit
64fa8dd4c4
@ -83,12 +83,8 @@ const getMyAssets = async () => {
|
|||||||
try {
|
try {
|
||||||
let nftListBox
|
let nftListBox
|
||||||
let res = await apiAssetsState(myADdress, data)
|
let res = await apiAssetsState(myADdress, data)
|
||||||
// nftList.value = Array.from(new Set([...res.rows, ...nftList.value].map(JSON.stringify))).map(JSON.parse);
|
nftList.value = [...nftList.value, ...res.rows]
|
||||||
nftList.value = [...res.rows, ...nftList.value]
|
|
||||||
// console.log(toRaw(nftList.value))
|
|
||||||
// debugger
|
|
||||||
nftListBox = nftList.value.reduce((acc, obj) => {
|
nftListBox = nftList.value.reduce((acc, obj) => {
|
||||||
// console.log(acc,obj)
|
|
||||||
const existingObj = acc.find(item => item.token_id == obj.token_id)
|
const existingObj = acc.find(item => item.token_id == obj.token_id)
|
||||||
if(!existingObj) {
|
if(!existingObj) {
|
||||||
acc.push(obj)
|
acc.push(obj)
|
||||||
@ -96,7 +92,6 @@ const getMyAssets = async () => {
|
|||||||
return acc
|
return acc
|
||||||
},[])
|
},[])
|
||||||
nftList.value = nftListBox
|
nftList.value = nftListBox
|
||||||
// console.log(nftListBox)
|
|
||||||
marketplaceStore.cursorObj = res.page
|
marketplaceStore.cursorObj = res.page
|
||||||
next_cursor.value = res.page.next_cursor
|
next_cursor.value = res.page.next_cursor
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
|
@ -40,18 +40,36 @@ const statusChild = (val) => {
|
|||||||
getHistoryList()
|
getHistoryList()
|
||||||
}
|
}
|
||||||
|
|
||||||
const next_cursor = ref()
|
const next_cursor = ref({
|
||||||
|
type: 0,
|
||||||
|
page_size: '20',
|
||||||
|
cursor: '',
|
||||||
|
search_name: '',
|
||||||
|
total_count: 0,
|
||||||
|
})
|
||||||
const getHistoryList = async () => {
|
const getHistoryList = async () => {
|
||||||
const myADdress = localWalletStore.address
|
const myADdress = localWalletStore.address
|
||||||
const data = {
|
const data = {
|
||||||
type: statusValue.value,
|
type: statusValue.value,
|
||||||
page_size: '20',
|
page_size: '20',
|
||||||
cursor: '',
|
cursor: next_cursor.value.next_cursor,
|
||||||
search_name: overviewValue.value,
|
search_name: overviewValue.value,
|
||||||
}
|
}
|
||||||
if(myADdress) {
|
if(myADdress) {
|
||||||
|
let nftListBox
|
||||||
let res = await apiHistoryState(myADdress,data)
|
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) {
|
if (sub.event?.data) {
|
||||||
const _data = parseTradeEvent(sub.event)
|
const _data = parseTradeEvent(sub.event)
|
||||||
sub.event.icon = _data.icon
|
sub.event.icon = _data.icon
|
||||||
@ -61,35 +79,28 @@ const getHistoryList = async () => {
|
|||||||
sub.event.decimals = _data.decimals
|
sub.event.decimals = _data.decimals
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nftList.value = res.rows
|
nftList.value = nftListBox
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// const handleScroll = () => {
|
const handleScroll = () => {
|
||||||
// const myADdress = localWalletStore.address
|
const myADdress = localWalletStore.address
|
||||||
// var scrollTop =
|
var scrollTop =
|
||||||
// document.documentElement.scrollTop || document.body.scrollTop; //变量windowHeight是可视区的高度
|
document.documentElement.scrollTop || document.body.scrollTop; //变量windowHeight是可视区的高度
|
||||||
// var windowHeight =
|
var windowHeight =
|
||||||
// document.documentElement.clientHeight || document.body.clientHeight; //变量scrollHeight是滚动条的总高度
|
document.documentElement.clientHeight || document.body.clientHeight; //变量scrollHeight是滚动条的总高度
|
||||||
// var scrollHeight =
|
var scrollHeight =
|
||||||
// document.documentElement.scrollHeight || document.body.scrollHeight;
|
document.documentElement.scrollHeight || document.body.scrollHeight;
|
||||||
// if (scrollTop + windowHeight == scrollHeight) {
|
if (scrollTop + windowHeight == scrollHeight) {
|
||||||
// //请求数据接口
|
//请求数据接口
|
||||||
// // this.seeMoreSchoolList();
|
// this.seeMoreSchoolList();
|
||||||
// // console.log('scrollTop + windowHeight == scrollHeight请求接口',toRaw(marketplaceStore.cursorObj), scrollTop, windowHeight, scrollHeight)
|
// console.log('scrollTop + windowHeight == scrollHeight请求接口',toRaw(marketplaceStore.cursorObj), scrollTop, windowHeight, scrollHeight)
|
||||||
// if(myADdress) {
|
if(next_cursor.value.remaining != 0) {
|
||||||
// // if(toRaw(marketplaceStore.cursorObj).remaining != 0) {
|
getHistoryList()
|
||||||
// getHistoryList()
|
}
|
||||||
// console.log('请求')
|
return false;
|
||||||
// // // } else {
|
}
|
||||||
// // // console.log('不用请求')
|
}
|
||||||
// // } else {
|
|
||||||
// // return false;
|
|
||||||
// // }
|
|
||||||
// // return false;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
watch(localWalletStore,() => {
|
watch(localWalletStore,() => {
|
||||||
if(!localWalletStore.token) {
|
if(!localWalletStore.token) {
|
||||||
@ -101,12 +112,12 @@ watch(localWalletStore,() => {
|
|||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
getHistoryList()
|
getHistoryList()
|
||||||
// window.addEventListener("scroll", handleScroll, true);
|
window.addEventListener("scroll", handleScroll, true);
|
||||||
})
|
})
|
||||||
|
|
||||||
// onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
// window.removeEventListener('scroll', handleScroll)
|
window.removeEventListener('scroll', handleScroll)
|
||||||
// })
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
@ -342,7 +342,6 @@ const selectChange = (index) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.hero-name {
|
.hero-name {
|
||||||
// width: 120px;
|
|
||||||
height: 40px;
|
height: 40px;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
font-size: 90px;
|
font-size: 90px;
|
||||||
|
@ -269,6 +269,7 @@ const searchName = (id) => {
|
|||||||
const renewNft = async() => {
|
const renewNft = async() => {
|
||||||
let timer = setTimeout(() => {
|
let timer = setTimeout(() => {
|
||||||
getHeroData()
|
getHeroData()
|
||||||
|
// location.reload()
|
||||||
clearTimeout(timer);
|
clearTimeout(timer);
|
||||||
}, 2000);
|
}, 2000);
|
||||||
}
|
}
|
||||||
@ -279,19 +280,21 @@ const totalCount = ref(0)
|
|||||||
const getHeroData = async () => {
|
const getHeroData = async () => {
|
||||||
// loadingDialogVisible.value = false;
|
// loadingDialogVisible.value = false;
|
||||||
try {
|
try {
|
||||||
|
let nftListBox
|
||||||
// const { errcode, errmsg, rows, page } = await marketplaceList.getMarketplaceState(reqData.value)
|
// const { errcode, errmsg, rows, page } = await marketplaceList.getMarketplaceState(reqData.value)
|
||||||
const { errcode, errmsg, rows, page } = await apiMarketplaceState(reqData.value)
|
const { errcode, errmsg, rows, page } = await apiMarketplaceState(reqData.value)
|
||||||
// console.log((toRaw(marketplaceList.cursorObj))
|
// console.log((toRaw(marketplaceList.cursorObj))
|
||||||
if(!errmsg) {
|
if(!errmsg) {
|
||||||
nftList.value = [...rows, ...nftList.value]
|
nftList.value = [...nftList.value, ...rows]
|
||||||
nftList.value = Array.from(new Set(nftList.value.map(JSON.stringify))).map(JSON.parse);
|
// nftList.value = Array.from(new Set(nftList.value.map(JSON.stringify))).map(JSON.parse);
|
||||||
// nftList.value = nftList.value.reduce((acc, obj) => {
|
nftListBox = nftList.value.reduce((acc, obj) => {
|
||||||
// const existingObj = acc.find(item => item.nft.token_id == obj.nft.token_id)
|
const existingObj = acc.find(item => item.event == obj.event)
|
||||||
// if(!existingObj) {
|
if(!existingObj) {
|
||||||
// acc.push(obj)
|
acc.push(obj)
|
||||||
// }
|
}
|
||||||
// return acc
|
return acc
|
||||||
// },[])
|
},[])
|
||||||
|
nftList.value = nftListBox
|
||||||
totalCount.value = page.total_count
|
totalCount.value = page.total_count
|
||||||
cursorObj.value = page
|
cursorObj.value = page
|
||||||
marketplaceList.cursorObj = page
|
marketplaceList.cursorObj = page
|
||||||
|
Loading…
x
Reference in New Issue
Block a user