分页处理暂存

This commit is contained in:
dragon
2024-12-24 10:28:40 +08:00
parent e352ab6148
commit 20b49801fb

View File

@@ -74,7 +74,10 @@
<div class="r">{{ formatDate(item.date, 1) }}</div>
</div>
</div>
<!-- <div class="noMore" v-show="(!res.recordList || res.recordList.length == 0 )">
<!-- <div
class="noMore"
v-show="!res.recordList || res.recordList.length == 0"
>
{{ $t("diamondLog.沒有更多了") }}
</div> -->
</div>
@@ -229,7 +232,6 @@ export default {
formatDate,
// tab切换按钮
cutTab(type) {
console.log(type);
this.tabAct = type;
this.time = null;
this.lock = true;
@@ -258,10 +260,9 @@ export default {
if (this.page == 1) {
this.list = res.data.data;
} else {
if (res.data.data.length == 0) {
return;
if (res.data.data.length >= 1) {
this.list = this.mergeArrays(this.list, res.data.data);
}
this.list.push(res.data.data);
}
if (this.page == 1 && res.data.data.length == 0) {
this.dateLists = false;
@@ -273,7 +274,6 @@ export default {
this.lock = false;
}
}
console.log(this.list, "sssssssss");
} else {
this.lock = true;
Toast(res.data.message);
@@ -319,6 +319,20 @@ export default {
this.loading = false;
});
},
mergeArrays(arr1, arr2) {
const resultMap = new Map();
[...arr1, ...arr2].forEach((item) => {
if (resultMap.has(item.date)) {
const existing = resultMap.get(item.date);
existing.recordList = [...existing.recordList, ...item.recordList];
existing.totalAmount += item.totalAmount;
} else {
resultMap.set(item.date, { ...item });
}
});
return Array.from(resultMap.values());
},
handleScroll(event) {
const container = event.target; // 获取滚动容器
if (
@@ -327,11 +341,13 @@ export default {
) {
// 滚动到底部
console.log("已经到底部");
this.page++;
if (this.tabAct == 4) {
this.giftReceiveFun(1);
} else {
this.getDate(1);
if (this.lock) {
this.page++;
if (this.tabAct == 4) {
this.giftReceiveFun(1);
} else {
this.getDate(1);
}
}
}
},