diff --git a/pages/chat/index.vue b/pages/chat/index.vue
index 68235d6..28bf44e 100644
--- a/pages/chat/index.vue
+++ b/pages/chat/index.vue
@@ -14,7 +14,7 @@
scroll-y
:scroll-into-view="scrollToView"
:scroll-top="scrollTop"
- scroll-with-animation
+ :scroll-with-animation="!isLoading"
:upper-threshold="20"
@scroll="handleScroll"
@scrolltoupper="handleScrollToUpper"
@@ -47,6 +47,19 @@
+
+
+
+
+
+
+
+ 已经到顶了
+
+
{
this.scrollToBottom();
});
@@ -283,11 +296,22 @@ export default {
// 加载对话消息
getMsgList() {
- return this.$store.dispatch("fetchChatRecord", {
- dialogueManagementId: this.vuex_msgUser.dialogueManagementId,
- PageIndex: this.PageIndex,
- PageSize: this.PageSize,
- });
+ return this.$store
+ .dispatch("fetchChatRecord", {
+ dialogueManagementId: this.vuex_msgUser.dialogueManagementId,
+ PageIndex: this.PageIndex,
+ PageSize: this.PageSize,
+ })
+ .then((list) => {
+ console.log(list.length, "加载对话消息");
+
+ const len = Array.isArray(list) ? list.length : 0;
+ if (len === 0 && len < this.PageSize) {
+ this.noMoreData = true;
+ console.log("没有更多数据了", this.noMoreData);
+ }
+ return list;
+ });
},
handleScroll(e) {
@@ -298,25 +322,26 @@ export default {
// 滚动到顶部,加载下一页历史消息
handleScrollToUpper() {
- if (this.isLoadingHistory || this.noMoreHistory) return;
+ if (this.isLoading || this.noMoreData) return;
- this.isLoadingHistory = true;
+ this.isLoading = true;
const beforeTop = this.currentScrollTop || 0;
const beforeHeight = this.currentScrollHeight || 0;
- this.PageIndex += 1;
+ const nextPageIndex = this.PageIndex + 1;
this.scrollToView = "";
this.$store
.dispatch("fetchChatRecordNextPage", {
dialogueManagementId: this.vuex_msgUser.dialogueManagementId,
- PageIndex: this.PageIndex,
+ PageIndex: nextPageIndex,
PageSize: this.PageSize,
})
.then((list) => {
if (!list || !list.length) {
- this.noMoreHistory = true;
+ this.noMoreData = true;
return;
}
+ this.PageIndex = nextPageIndex;
this.$nextTick(() => {
const query = uni.createSelectorQuery().in(this);
query
@@ -331,12 +356,9 @@ export default {
.exec();
});
})
- .catch(() => {
- this.PageIndex = Math.max(1, this.PageIndex - 1);
- })
.finally(() => {
setTimeout(() => {
- this.isLoadingHistory = false;
+ this.isLoading = false;
}, 50);
});
},
@@ -448,18 +470,18 @@ export default {
height: 100%;
overflow-y: scroll;
- // .loading-more {
- // text-align: center;
- // margin-bottom: 32rpx;
- // }
+ .loading-more {
+ text-align: center;
+ margin-bottom: 32rpx;
+ }
- // .no-more-data {
- // text-align: center;
- // font-size: 24rpx;
- // color: #999;
- // margin-bottom: 32rpx;
- // padding: 10rpx 0;
- // }
+ .no-more-data {
+ text-align: center;
+ font-size: 24rpx;
+ color: #999;
+ margin-bottom: 32rpx;
+ padding: 10rpx 0;
+ }
.teacher-info-card {
background-color: #ffffff;