fix: 提交

This commit is contained in:
wangdongbo 2026-01-30 14:25:36 +08:00
parent 01529b1b99
commit d74c06325d
3 changed files with 38 additions and 26 deletions

View File

@ -7,8 +7,14 @@
<view v-if="customScroll" class="page-scroll"> <view v-if="customScroll" class="page-scroll">
<slot></slot> <slot></slot>
</view> </view>
<scroll-view v-else scroll-y="true" :scroll-top="scrollTop" class="page-scroll" @scrolltolower="scrolltolower" <scroll-view
@scroll="onScroll"> v-else
scroll-y="true"
:scroll-top="scrollTop"
class="page-scroll"
@scrolltolower="scrolltolower"
@scroll="onScroll"
>
<slot></slot> <slot></slot>
</scroll-view> </scroll-view>
</view> </view>
@ -16,19 +22,19 @@
<slot name="footer"></slot> <slot name="footer"></slot>
</view> </view>
<!-- #ifdef MP--> <!-- #ifdef MP-->
<view class="safeareaBottom"></view> <!-- <view class="safeareaBottom"></view> -->
<!-- #endif --> <!-- #endif -->
</view> </view>
</template> </template>
<script setup> <script setup>
import { computed, useSlots, ref } from 'vue'; import { computed, useSlots, ref } from "vue";
import useDebounce from '@/utils/useDebounce'; import useDebounce from "@/utils/useDebounce";
const emits = defineEmits(['reachBottom']); const emits = defineEmits(["reachBottom"]);
const props = defineProps({ const props = defineProps({
customScroll: { type: Boolean, default: false }, customScroll: { type: Boolean, default: false },
mainStyle: { default: '' }, mainStyle: { default: "" },
pageStyle: { default: '' } pageStyle: { default: "" },
}); });
const slots = useSlots(); const slots = useSlots();
const hasHeader = computed(() => !!slots.header); const hasHeader = computed(() => !!slots.header);
@ -37,7 +43,7 @@ const hasFooter = computed(() => !!slots.footer);
const scrollTop = ref(0); const scrollTop = ref(0);
const scrolltolower = useDebounce(() => { const scrolltolower = useDebounce(() => {
emits('reachBottom'); emits("reachBottom");
}); });
const onScroll = useDebounce((e) => { const onScroll = useDebounce((e) => {
@ -49,9 +55,8 @@ function scrollToBottom() {
} }
defineExpose({ defineExpose({
scrollToBottom scrollToBottom,
}) });
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.full-page { .full-page {

View File

@ -285,14 +285,17 @@ const setupConversationListener = () => {
existing.lastMessageTime !== conversationData.lastMessageTime || existing.lastMessageTime !== conversationData.lastMessageTime ||
existing.unreadCount !== conversationData.unreadCount existing.unreadCount !== conversationData.unreadCount
) { ) {
// 使 Object.assign //
Object.assign( conversationList.value[existingIndex] = {
conversationList.value[existingIndex], ...conversationData,
conversationData //
); avatar: existing.avatar || conversationData.avatar,
//
unreadCount: Math.max(existing.unreadCount || 0, conversationData.unreadCount || 0)
};
needSort = true; needSort = true;
console.log( console.log(
`已更新会话: ${conversationData.name}, unreadCount: ${conversationData.unreadCount}` `已更新会话: ${conversationData.name}, unreadCount: ${conversationList.value[existingIndex].unreadCount}`
); );
} }
} else { } else {
@ -325,19 +328,23 @@ const setupConversationListener = () => {
if (conversationIndex !== -1) { if (conversationIndex !== -1) {
const conversation = conversationList.value[conversationIndex]; const conversation = conversationList.value[conversationIndex];
// //
const pages = getCurrentPages(); const pages = getCurrentPages();
const currentPage = pages[pages.length - 1]; const currentPage = pages[pages.length - 1];
const isViewingConversation =
currentPage?.route === "pages/message/index";
// // groupID
if (isViewingConversation) { const currentGroupID = currentPage?.options?.groupID;
const isViewingThisConversation =
currentPage?.route === "pages/message/index" &&
currentGroupID === conversation.groupID;
//
if (isViewingThisConversation) {
console.log("用户正在查看该会话,不增加未读数"); console.log("用户正在查看该会话,不增加未读数");
return; return;
} }
// //
conversation.unreadCount = (conversation.unreadCount || 0) + 1; conversation.unreadCount = (conversation.unreadCount || 0) + 1;
console.log( console.log(
"已更新会话未读数:", "已更新会话未读数:",

View File

@ -143,8 +143,8 @@ function mergeConversationData(conversation, groupDetailsMap) {
// 更新显示名称(使用后端的患者信息) // 更新显示名称(使用后端的患者信息)
name: formatConversationName(groupDetail), name: formatConversationName(groupDetail),
// 更新头像 // 更新头像(优先使用已有头像,避免闪动)
avatar: groupDetail.patient?.avatar || conversation.avatar || '/static/default-avatar.png' avatar: conversation.avatar || groupDetail.patient?.avatar || '/static/default-avatar.png'
} }
} }