From 31af22face4ba533556137a7c8114669e5b0327d Mon Sep 17 00:00:00 2001 From: yangzhe Date: Wed, 17 Dec 2025 16:42:52 +0800 Subject: [PATCH] =?UTF-8?q?fix(chat):=20=E4=BC=98=E5=8C=96=E8=81=8A?= =?UTF-8?q?=E5=A4=A9=E9=A1=B5=E9=9D=A2=E5=8A=A0=E8=BD=BD=E5=92=8C=E6=BB=9A?= =?UTF-8?q?=E5=8A=A8=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/chat/index.vue | 58 ++++++++++++++++++-------------------- pages/home/index/index.vue | 2 +- 2 files changed, 28 insertions(+), 32 deletions(-) diff --git a/pages/chat/index.vue b/pages/chat/index.vue index 28bf44e..f9756c8 100644 --- a/pages/chat/index.vue +++ b/pages/chat/index.vue @@ -303,12 +303,9 @@ export default { PageSize: this.PageSize, }) .then((list) => { - console.log(list.length, "加载对话消息"); - const len = Array.isArray(list) ? list.length : 0; - if (len === 0 && len < this.PageSize) { + if (len === 0 && this.PageIndex === 1) { this.noMoreData = true; - console.log("没有更多数据了", this.noMoreData); } return list; }); @@ -342,43 +339,42 @@ export default { return; } this.PageIndex = nextPageIndex; - this.$nextTick(() => { - const query = uni.createSelectorQuery().in(this); - query - .select(".chat-content") - .boundingClientRect((rect) => { - const afterHeight = Number(rect && rect.height) || 0; - const delta = afterHeight - beforeHeight; - if (delta > 0) { - this.scrollTop = beforeTop + delta; - } - }) - .exec(); - }); + // this.$nextTick(() => { + // const query = uni.createSelectorQuery().in(this); + // query + // .select(".chat-content") + // .boundingClientRect((rect) => { + // const afterHeight = Number(rect && rect.height) || 0; + // const delta = afterHeight - beforeHeight; + // if (delta > 0) { + // this.scrollTop = beforeTop + delta; + // } + // }) + // .exec(); + // }); }) .finally(() => { setTimeout(() => { this.isLoading = false; - }, 50); + }, 100); }); }, // 滚动到底部 scrollToBottom() { - // if (this.vuex_msglist.length > 0) { - // const lastMsg = this.vuex_msglist[this.vuex_msglist.length - 1]; - // this.scrollToView = "msg-" + lastMsg.id; - // } + if (this.isLoading) return; - // 滚动到底部锚点 - if (this.scrollToView === "bottom-anchor") { - this.scrollToView = ""; - this.$nextTick(() => { - this.scrollToView = "bottom-anchor"; - }); - return; - } - this.scrollToView = "bottom-anchor"; + this.$nextTick(() => { + const query = uni.createSelectorQuery().in(this); + query + .select(".chat-content") + .boundingClientRect((data) => { + if (data) { + this.scrollTop = Number(data.height || 0) + 200; + } + }) + .exec(); + }); }, // 格式化时间 diff --git a/pages/home/index/index.vue b/pages/home/index/index.vue index 144d51c..0556eab 100644 --- a/pages/home/index/index.vue +++ b/pages/home/index/index.vue @@ -1041,7 +1041,7 @@ export default { .finally(() => { setTimeout(() => { this.isLoading = false; - }, 300); + }, 100); }); },