Compare commits

...

2 Commits

Author SHA1 Message Date
04dcbdf331 处理未读消息数量场景补全情况
Some checks are pending
Check / lint (push) Waiting to run
Check / typecheck (push) Waiting to run
Check / build (build, 18.x, ubuntu-latest) (push) Waiting to run
Check / build (build, 18.x, windows-latest) (push) Waiting to run
Check / build (build:app, 18.x, ubuntu-latest) (push) Waiting to run
Check / build (build:app, 18.x, windows-latest) (push) Waiting to run
Check / build (build:mp-weixin, 18.x, ubuntu-latest) (push) Waiting to run
Check / build (build:mp-weixin, 18.x, windows-latest) (push) Waiting to run
2025-03-25 10:33:30 +08:00
fa2098c565 处理oa底部tabbar未读消息数量显示 2025-03-24 20:03:52 +08:00
10 changed files with 110 additions and 43 deletions

2
components.d.ts vendored
View File

@ -30,6 +30,8 @@ declare module 'vue' {
LoginMessage: typeof import('./src/components/talk/message/LoginMessage.vue')['default']
Message: typeof import('./src/components/x-message/message/index.vue')['default']
MixedMessage: typeof import('./src/components/talk/message/MixedMessage.vue')['default']
NButton: typeof import('naive-ui')['NButton']
NIcon: typeof import('naive-ui')['NIcon']
PageAnimation: typeof import('./src/components/page-animation/index.vue')['default']
RevokeMessage: typeof import('./src/components/talk/message/RevokeMessage.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']

View File

@ -38,7 +38,19 @@ export const ServeTopTalkList = (data) => {
}
// 清除聊天消息未读数服务接口
export const ServeClearTalkUnreadNum = (data) => {
export const ServeClearTalkUnreadNum = (data, unReadNum) => {
console.log("=======chatApp==UnreadNum",unReadNum)
if (typeof plus !== 'undefined') {
let OAWebView = plus.webview.all()
//all里面第一个是入口webview
OAWebView[0].evalJS(`updateUnreadMsgNumReduce('${unReadNum}')`)
} else {
document.addEventListener('plusready', () => {
let OAWebView = plus.webview.all()
//all里面第一个是入口webview
OAWebView[0].evalJS(`updateUnreadMsgNumReduce('${unReadNum}')`)
})
}
return request({
url: '/api/v1/talk/unread/clear',
method: 'POST',

View File

@ -5,8 +5,16 @@ import { parseTime } from '@/utils/datetime'
import * as message from '@/constant/message'
import { formatTalkItem, palyMusic, formatTalkRecord } from '@/utils/talk'
// import { isElectronMode } from '@/utils/common'
import { ServeClearTalkUnreadNum, ServeCreateTalkList } from '@/api/chat/index.js'
import { useTalkStore, useDialogueStore,useDialogueListStore,useGroupStore } from '@/store'
import {
ServeClearTalkUnreadNum,
ServeCreateTalkList,
} from '@/api/chat/index.js'
import {
useTalkStore,
useDialogueStore,
useDialogueListStore,
useGroupStore,
} from '@/store'
/**
* 好友状态事件
@ -98,7 +106,6 @@ class Talk extends Base {
play() {
// 客户端有消息提示
// if (isElectronMode()) return
// useSettingsStore().isPromptTone && palyMusic()
}
@ -118,6 +125,17 @@ class Talk extends Base {
this.insertTalkRecord()
} else {
this.updateTalkItem()
if (typeof plus !== 'undefined') {
let OAWebView = plus.webview.all()
//all里面第一个是入口webview
OAWebView[0].evalJS(`updateUnreadMsgNumAdd()`)
} else {
document.addEventListener('plusready', () => {
let OAWebView = plus.webview.all()
//all里面第一个是入口webview
OAWebView[0].evalJS(`updateUnreadMsgNumAdd()`)
})
}
}
}
@ -132,7 +150,6 @@ class Talk extends Base {
// lang: 'zh-CN',
// body: '您有新的消息请注意查收'
// })
// notification.onclick = () => {
// notification.close()
// }
@ -160,7 +177,7 @@ class Talk extends Base {
ServeCreateTalkList({
talk_type,
receiver_id
receiver_id,
}).then(({ code, data }) => {
if (code == 200) {
let item = formatTalkItem(data)
@ -175,7 +192,7 @@ class Talk extends Base {
*/
insertTalkRecord() {
let record = this.resource
let newRecord = formatTalkRecord(this.getAccountId(), this.resource);
let newRecord = formatTalkRecord(this.getAccountId(), this.resource)
const { addDialogueRecord, addChatRecord } = useDialogueListStore()
// 群成员变化的消息,需要更新群成员列表
if ([1102, 1103, 1104, 1115].includes(record.msg_type)) {
@ -194,7 +211,9 @@ class Talk extends Base {
avatar: record.extra.group_avatar,
})
// 更新会话列表中的会话信息
const dialogue = useDialogueListStore().getDialogueList(`${record.talk_type}_${record.receiver_id}`)
const dialogue = useDialogueListStore().getDialogueList(
`${record.talk_type}_${record.receiver_id}`,
)
if (dialogue) {
dialogue.talk.username = record.extra.group_name
}
@ -208,7 +227,7 @@ class Talk extends Base {
setTimeout(() => {
ws.emit('im.message.read', {
receiver_id: this.sender_id,
msg_ids: [this.resource.msg_id]
msg_ids: [this.resource.msg_id],
})
}, 1000)
}
@ -218,7 +237,8 @@ class Talk extends Base {
if (!el) return
// 判断的滚动条是否在底部
const isBottom = Math.ceil(el.scrollTop) + el.clientHeight >= el.scrollHeight
const isBottom =
Math.ceil(el.scrollTop) + el.clientHeight >= el.scrollHeight
if (isBottom || record.user_id == this.getAccountId()) {
nextTick(() => {
@ -231,14 +251,15 @@ class Talk extends Base {
useTalkStore().updateItem({
index_name: this.getIndexName(),
msg_text: this.getTalkText(),
updated_at: parseTime(new Date())
updated_at: parseTime(new Date()),
})
if (this.talk_type == 1 && this.getAccountId() !== this.sender_id) {
ServeClearTalkUnreadNum({
talk_type: 1,
receiver_id: this.sender_id
})
//不在此处维护未读消息数量
// ServeClearTalkUnreadNum({
// talk_type: 1,
// receiver_id: this.sender_id,
// })
}
}
@ -249,11 +270,13 @@ class Talk extends Base {
useTalkStore().updateMessage({
index_name: this.getIndexName(),
msg_text: this.getTalkText(),
updated_at: parseTime(new Date())
updated_at: parseTime(new Date()),
})
if (this.resource.msg_type == 1116) {
// 更新会话列表中的会话信息
const dialogue = useDialogueListStore().getDialogueList(`${this.resource.talk_type}_${this.resource.receiver_id}`)
const dialogue = useDialogueListStore().getDialogueList(
`${this.resource.talk_type}_${this.resource.receiver_id}`,
)
if (dialogue) {
dialogue.talk.username = this.resource.extra.group_name
}

View File

@ -17,10 +17,17 @@
</div>
<div class="avatarImg">
<avatarModule
:mode="2"
:mode="props?.data?.group_type === 0 ? 1 : 2"
:avatar="props?.data?.avatar"
:groupType="props?.data?.group_type"
:userName="props?.data?.name"
:customStyle="{ width: '96rpx', height: '96rpx' }"
:customTextStyle="{
fontSize: '32rpx',
fontWeight: 'bold',
color: '#fff',
lineHeight: '44rpx',
}"
></avatarModule>
</div>
<div class="chatInfo">
@ -30,7 +37,9 @@
class="text-[#171717] text-[32rpx] font-medium leading-[44rpx]"
>
<span>{{ props.data.name }}</span>
<span v-if="props.data.talk_type === 2">{{ props.data.group_member_num }}</span>
<span v-if="props.data.talk_type === 2">
{{ props.data.group_member_num }}
</span>
<span v-if="props.data.group_type === 2" class="depTag tag">
部门
</span>

View File

@ -219,7 +219,7 @@ watch(
onMounted(() => {
talkStore.loadTalkList()
console.log(talkStore.talkItems)
items.value = lodash.cloneDeep(talkStore.talkItems)
items.value = lodash.cloneDeep(talkStore.talkItems).filter(item=>item.is_dismiss === 0 && item.is_quit === 0)
})
onUnmounted(() => {
dialogueStore.setForwardType('')

View File

@ -544,6 +544,7 @@ const talkParams = reactive({
isDismiss: computed(() => dialogueStore.isDismiss),
isQuit: computed(() => dialogueStore.isQuit),
adminList: computed(() => dialogueStore.getAdminList),
unReadNum: computed(() => dialogueStore.unreadNum),
})
const state = ref({
@ -597,11 +598,12 @@ uniOnUnload(() => {
ServeClearTalkUnreadNum({
talk_type: Number(talkParams.type),
receiver_id: Number(talkParams.receiver_id),
}).then(() => {
},talkParams.unReadNum).then(() => {
talkStore.updateItem({
index_name: talkParams.index_name,
unread_num: 0,
})
dialogueStore.clearUnreadNum()
})
})
const handleEmojiPanel = () => {

View File

@ -107,6 +107,9 @@ import { useSessionMenu } from '@/hooks'
const talkStore = useTalkStore()
const { onToTopTalk, onRemoveTalk } = useSessionMenu()
const dialogueStore = useDialogueStore()
const dialogueParams = reactive({
unReadNum: computed(() => dialogueStore.unreadNum),
})
const props = defineProps({
data: {
type: Object,
@ -135,11 +138,12 @@ const cellClick = () => {
ServeClearTalkUnreadNum({
talk_type: props.data.talk_type,
receiver_id: props.data.receiver_id,
}).then(() => {
},dialogueParams.unReadNum).then(() => {
talkStore.updateItem({
index_name: props.data.index_name,
unread_num: 0,
})
dialogueStore.clearUnreadNum()
})
}
uni.navigateTo({

View File

@ -138,6 +138,9 @@ const isEmptyViewShow = ref(false)
const talkStore = useTalkStore()
const userStore = useUserStore()
const dialogueStore = useDialogueStore()
const dialogueParams = reactive({
unReadNum: computed(() => dialogueStore.unreadNum),
})
const { userInfo } = useAuth()
const topItems = computed(() => talkStore.topItems)
@ -244,11 +247,12 @@ onLoad((options) => {
ServeClearTalkUnreadNum({
talk_type: openSession.talk_type,
receiver_id: openSession.receiver_id,
}).then(() => {
},dialogueParams.unReadNum).then(() => {
talkStore.updateItem({
index_name: openSession.index_name,
unread_num: 0,
})
dialogueStore.clearUnreadNum()
})
}
uni.navigateTo({

View File

@ -54,6 +54,9 @@ export const useDialogueStore = defineStore('dialogue', {
//是否退群/移出群
isQuit: false,
//未读消息数量
unreadNum:0,
// 群成员列表
members: [],
@ -90,6 +93,11 @@ export const useDialogueStore = defineStore('dialogue', {
this.online = status
},
// 更新未读消息数量-清空未读
clearUnreadNum() {
this.unreadNum = 0
},
// 更新对话信息
setDialogue(data = {}) {
this.online = data.is_online == 1
@ -107,6 +115,8 @@ export const useDialogueStore = defineStore('dialogue', {
this.isDismiss = data?.is_dismiss === 1 ? true : false
this.isQuit = data?.is_quit === 1 ? true : false
this.unreadNum = data?.unread_num || 0
this.members = []
if (data.talk_type == 2) {
this.updateGroupMembers()

View File

@ -42,6 +42,7 @@ export const useDialogueListStore = createGlobalState(() => {
isShowSessionList: dialogue.isShowSessionList,
isDismiss: dialogue.isDismiss,
isQuit: dialogue.isQuit,
unreadNum: dialogue.unreadNum,
members: dialogue.members.map(member => ({
id: member.id,
nickname: member.nickname,