fix: 提交
This commit is contained in:
parent
01529b1b99
commit
d74c06325d
@ -7,8 +7,14 @@
|
||||
<view v-if="customScroll" class="page-scroll">
|
||||
<slot></slot>
|
||||
</view>
|
||||
<scroll-view v-else scroll-y="true" :scroll-top="scrollTop" class="page-scroll" @scrolltolower="scrolltolower"
|
||||
@scroll="onScroll">
|
||||
<scroll-view
|
||||
v-else
|
||||
scroll-y="true"
|
||||
:scroll-top="scrollTop"
|
||||
class="page-scroll"
|
||||
@scrolltolower="scrolltolower"
|
||||
@scroll="onScroll"
|
||||
>
|
||||
<slot></slot>
|
||||
</scroll-view>
|
||||
</view>
|
||||
@ -16,19 +22,19 @@
|
||||
<slot name="footer"></slot>
|
||||
</view>
|
||||
<!-- #ifdef MP-->
|
||||
<view class="safeareaBottom"></view>
|
||||
<!-- <view class="safeareaBottom"></view> -->
|
||||
<!-- #endif -->
|
||||
</view>
|
||||
</template>
|
||||
<script setup>
|
||||
import { computed, useSlots, ref } from 'vue';
|
||||
import useDebounce from '@/utils/useDebounce';
|
||||
import { computed, useSlots, ref } from "vue";
|
||||
import useDebounce from "@/utils/useDebounce";
|
||||
|
||||
const emits = defineEmits(['reachBottom']);
|
||||
const emits = defineEmits(["reachBottom"]);
|
||||
const props = defineProps({
|
||||
customScroll: { type: Boolean, default: false },
|
||||
mainStyle: { default: '' },
|
||||
pageStyle: { default: '' }
|
||||
mainStyle: { default: "" },
|
||||
pageStyle: { default: "" },
|
||||
});
|
||||
const slots = useSlots();
|
||||
const hasHeader = computed(() => !!slots.header);
|
||||
@ -37,7 +43,7 @@ const hasFooter = computed(() => !!slots.footer);
|
||||
const scrollTop = ref(0);
|
||||
|
||||
const scrolltolower = useDebounce(() => {
|
||||
emits('reachBottom');
|
||||
emits("reachBottom");
|
||||
});
|
||||
|
||||
const onScroll = useDebounce((e) => {
|
||||
@ -49,9 +55,8 @@ function scrollToBottom() {
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
scrollToBottom
|
||||
})
|
||||
|
||||
scrollToBottom,
|
||||
});
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.full-page {
|
||||
|
||||
@ -285,14 +285,17 @@ const setupConversationListener = () => {
|
||||
existing.lastMessageTime !== conversationData.lastMessageTime ||
|
||||
existing.unreadCount !== conversationData.unreadCount
|
||||
) {
|
||||
// 使用 Object.assign 更新,保持引用稳定
|
||||
Object.assign(
|
||||
conversationList.value[existingIndex],
|
||||
conversationData
|
||||
);
|
||||
// 只更新变化的字段,保持头像和未读数稳定
|
||||
conversationList.value[existingIndex] = {
|
||||
...conversationData,
|
||||
// 保持原有头像,避免闪动
|
||||
avatar: existing.avatar || conversationData.avatar,
|
||||
// 保留较大的未读数(避免被后端数据覆盖)
|
||||
unreadCount: Math.max(existing.unreadCount || 0, conversationData.unreadCount || 0)
|
||||
};
|
||||
needSort = true;
|
||||
console.log(
|
||||
`已更新会话: ${conversationData.name}, unreadCount: ${conversationData.unreadCount}`
|
||||
`已更新会话: ${conversationData.name}, unreadCount: ${conversationList.value[existingIndex].unreadCount}`
|
||||
);
|
||||
}
|
||||
} else {
|
||||
@ -325,19 +328,23 @@ const setupConversationListener = () => {
|
||||
if (conversationIndex !== -1) {
|
||||
const conversation = conversationList.value[conversationIndex];
|
||||
|
||||
// 检查当前页面栈,判断用户是否正在查看该会话
|
||||
// 检查当前页面栈,判断用户是否正在查看该会话的聊天详情页
|
||||
const pages = getCurrentPages();
|
||||
const currentPage = pages[pages.length - 1];
|
||||
const isViewingConversation =
|
||||
currentPage?.route === "pages/message/index";
|
||||
|
||||
// 如果用户正在查看该会话,不增加未读数
|
||||
if (isViewingConversation) {
|
||||
// 获取当前页面的 groupID 参数(如果在聊天详情页)
|
||||
const currentGroupID = currentPage?.options?.groupID;
|
||||
const isViewingThisConversation =
|
||||
currentPage?.route === "pages/message/index" &&
|
||||
currentGroupID === conversation.groupID;
|
||||
|
||||
// 如果用户正在查看这个具体的会话,不增加未读数
|
||||
if (isViewingThisConversation) {
|
||||
console.log("用户正在查看该会话,不增加未读数");
|
||||
return;
|
||||
}
|
||||
|
||||
// 只在用户不在聊天页面时才增加未读数
|
||||
// 只在用户不在该会话的聊天页面时才增加未读数
|
||||
conversation.unreadCount = (conversation.unreadCount || 0) + 1;
|
||||
console.log(
|
||||
"已更新会话未读数:",
|
||||
|
||||
@ -143,8 +143,8 @@ function mergeConversationData(conversation, groupDetailsMap) {
|
||||
// 更新显示名称(使用后端的患者信息)
|
||||
name: formatConversationName(groupDetail),
|
||||
|
||||
// 更新头像
|
||||
avatar: groupDetail.patient?.avatar || conversation.avatar || '/static/default-avatar.png'
|
||||
// 更新头像(优先使用已有头像,避免闪动)
|
||||
avatar: conversation.avatar || groupDetail.patient?.avatar || '/static/default-avatar.png'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user