diff --git a/pages/deepMate/deepMate.vue b/pages/deepMate/deepMate.vue index 3de84b6..f1e774f 100644 --- a/pages/deepMate/deepMate.vue +++ b/pages/deepMate/deepMate.vue @@ -816,7 +816,17 @@ const scrollToBottom = () => { }); }; const scrollToTop = () => { - chatScrollTop.value = 0; + // 聊天区存在:控制 scroll-view 回到顶部 + if (messages.value.length > 0) { + chatScrollTop.value = 0; + return; + } + // 未发起对话:页面级滚动回到顶部 + try { + uni.pageScrollTo({ scrollTop: 0, duration: 200 }); + } catch (e) { + // 兜底,无需处理 + } }; // 自动滚动控制:用户向上滚动时暂停自动滚到底部 const shouldAutoScroll = ref(true); @@ -830,6 +840,9 @@ const onChatScroll = (e) => { const delta = st - lastScrollTop.value; lastScrollTop.value = st; + // 同步当前滚动位置,确保点击回顶能产生数值变化 + chatScrollTop.value = st; + if (delta < 0) { shouldAutoScroll.value = false; return;