From a586c449665e1605a3a5a1d8624e02566b8dbcff Mon Sep 17 00:00:00 2001 From: jiangjunjie Date: Mon, 28 Sep 2026 16:20:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E5=8E=86=E5=8F=B2=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/chat-new.vue | 38 ++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/src/components/chat-new.vue b/src/components/chat-new.vue index f551370..6d250d3 100644 --- a/src/components/chat-new.vue +++ b/src/components/chat-new.vue @@ -54,7 +54,7 @@ function appraiseIsClose(val, param) { const historylist = ref([]) const historyLoading = ref(false) -const historyReady = ref(false) +const historyReady = ref(true) const introReadyCount = ref(0) const businessHandleRef = ref(null) const businessClick = () => { @@ -323,6 +323,10 @@ function onMainScroll(event) { const top = event?.target?.scrollTop if (top == null) return persistScrollTop(top, { allowZero: true }) + // 上滑到顶部附近时加载更多历史记录 + if (top <= 60 && !nolist.value && !historyLoading.value) { + getChatHistory() + } } onBeforeRouteLeave(() => { @@ -374,7 +378,7 @@ function getHeaderUrl(context, payload) { }); }); } -const getChatHistory = async () => { +const getChatHistory = async (isAuto = false) => { const params = { page: pageNum.value, pageSize: pageSize.value, @@ -382,10 +386,6 @@ const getChatHistory = async () => { userId: userId.value || store?.userId, } historyLoading.value = true - if (pageNum.value === 1) { - historyReady.value = false - introReadyCount.value = 0 - } Post('history/chatInfo', params) .then((response) => { @@ -444,7 +444,8 @@ const getChatHistory = async () => { updateReadStatus(dataList) nextTick(() => { - if (pageNum.value <= 2) { + if (isAuto) { + // 参考 chat-main:有未读自动加载时滚到底部并提示未读 if (isLostMessage.value === 3) { showToast('您有新消息未读,请及时查看历史消息') } @@ -458,6 +459,11 @@ const getChatHistory = async () => { setTimeout(() => { if (view) scrollMainTo(view.offsetTop - 20) }, 150) + } else { + // 首次手动上拉加载:停在顶部 + setTimeout(() => { + scrollMainTo(0) + }, 150) } }) } else { @@ -466,15 +472,14 @@ const getChatHistory = async () => { } }) .catch(() => { + // 网络异常不置 nolist,用户再次上滑可重试(chat-main 靠下拉手势重置 nolist,这里等价放开) historyLoading.value = false historyReady.value = true pageNum.value-- - nolist.value = true }) } onMounted(async () => { getHeaderUrl() - getChatHistory() await nextTick() if (mainContainerRef.value) { store?.setMescrollContent?.(mainContainerRef.value) @@ -483,6 +488,12 @@ onMounted(async () => { if (persisted != null && persisted > 0) { shouldRestoreScroll.value = true restoreScrollPosition() + } else { + // 参考 chat-main 的 mescroll down.auto:有未读消息或投诉直连渠道时,进入页面自动加载历史 + const hasUnread = isLostMessage.value == '1' || isLostMessage.value == '3' + if (hasUnread || store.source === '95460000') { + getChatHistory(true) + } } }) watch( @@ -504,6 +515,7 @@ watch(
+
{{ nolistTxt }}