Browse Source

fix: 重连后已读状态异常的bug

master
xsx 8 months ago
parent
commit
40ac808f56
  1. 39
      im-uniapp/pages/chat/chat-box.vue
  2. 11
      im-web/src/components/chat/ChatBox.vue

39
im-uniapp/pages/chat/chat-box.vue

@ -257,12 +257,12 @@ export default {
this.atUserIds = atUserIds; this.atUserIds = atUserIds;
}, },
onLongPressHead(msgInfo) { onLongPressHead(msgInfo) {
if (!msgInfo.selfSend && this.chat.type == "GROUP" && this.atUserIds.indexOf(msgInfo.sendId) < 0) { if (!msgInfo.selfSend && this.isGroup && this.atUserIds.indexOf(msgInfo.sendId) < 0) {
this.atUserIds.push(msgInfo.sendId); this.atUserIds.push(msgInfo.sendId);
} }
}, },
headImage(msgInfo) { headImage(msgInfo) {
if (this.chat.type == 'GROUP') { if (this.isGroup) {
let member = this.groupMembers.find((m) => m.userId == msgInfo.sendId); let member = this.groupMembers.find((m) => m.userId == msgInfo.sendId);
return member ? member.headImage : ""; return member ? member.headImage : "";
} else { } else {
@ -270,7 +270,7 @@ export default {
} }
}, },
showName(msgInfo) { showName(msgInfo) {
if (this.chat.type == 'GROUP') { if (this.isGroup) {
let member = this.groupMembers.find((m) => m.userId == msgInfo.sendId); let member = this.groupMembers.find((m) => m.userId == msgInfo.sendId);
return member ? member.showNickName : ""; return member ? member.showNickName : "";
} else { } else {
@ -357,7 +357,7 @@ export default {
return atText; return atText;
}, },
fillTargetId(msgInfo, targetId) { fillTargetId(msgInfo, targetId) {
if (this.chat.type == "GROUP") { if (this.isGroup) {
msgInfo.groupId = targetId; msgInfo.groupId = targetId;
} else { } else {
msgInfo.recvId = targetId; msgInfo.recvId = targetId;
@ -675,7 +675,7 @@ export default {
}, 50) }, 50)
}, },
onShowMore() { onShowMore() {
if (this.chat.type == "GROUP") { if (this.isGroup) {
uni.navigateTo({ uni.navigateTo({
url: "/pages/group/group-info?id=" + this.group.id url: "/pages/group/group-info?id=" + this.group.id
}) })
@ -728,7 +728,7 @@ export default {
readedMessage() { readedMessage() {
if (this.unreadCount > 0) { if (this.unreadCount > 0) {
let url = "" let url = ""
if (this.chat.type == "GROUP") { if (this.isGroup) {
url = `/message/group/readed?groupId=${this.chat.targetId}` url = `/message/group/readed?groupId=${this.chat.targetId}`
} else { } else {
url = `/message/private/readed?friendId=${this.chat.targetId}` url = `/message/private/readed?friendId=${this.chat.targetId}`
@ -919,7 +919,7 @@ export default {
sendTime: new Date().getTime(), sendTime: new Date().getTime(),
type: this.$enums.MESSAGE_TYPE.TIP_TEXT type: this.$enums.MESSAGE_TYPE.TIP_TEXT
} }
if (this.chat.type == "PRIVATE") { if (this.isPrivate) {
msgInfo.recvId = this.mine.id msgInfo.recvId = this.mine.id
msgInfo.content = "该用户已被管理员封禁,原因:" + this.userInfo.reason msgInfo.content = "该用户已被管理员封禁,原因:" + this.userInfo.reason
} else { } else {
@ -969,7 +969,7 @@ export default {
return ""; return "";
} }
let title = this.chat.showName; let title = this.chat.showName;
if (this.chat.type == "GROUP") { if (this.isGroup) {
let size = this.groupMembers.filter(m => !m.quit).length; let size = this.groupMembers.filter(m => !m.quit).length;
title += `(${size})`; title += `(${size})`;
} }
@ -991,8 +991,8 @@ export default {
return this.chat.unreadCount; return this.chat.unreadCount;
}, },
isBanned() { isBanned() {
return (this.chat.type == "PRIVATE" && this.userInfo.isBanned) || return (this.isPrivate && this.userInfo.isBanned) ||
(this.chat.type == "GROUP" && this.group.isBanned) (this.isGroup && this.group.isBanned)
}, },
atUserItems() { atUserItems() {
let atUsers = []; let atUsers = [];
@ -1013,6 +1013,15 @@ export default {
}, },
memberSize() { memberSize() {
return this.groupMembers.filter(m => !m.quit).length; return this.groupMembers.filter(m => !m.quit).length;
},
isGroup() {
return this.chat.type == 'GROUP';
},
isPrivate() {
return this.chat.type == 'PRIVATE';
},
loading() {
return this.chatStore.loading;
} }
}, },
watch: { watch: {
@ -1038,6 +1047,14 @@ export default {
this.readedMessage() this.readedMessage()
} }
} }
},
loading: {
handler(newLoading, oldLoading) {
// 线
if (!newLoading && this.isPrivate) {
this.loadReaded(this.chat.targetId)
}
}
} }
}, },
onLoad(options) { onLoad(options) {
@ -1049,7 +1066,7 @@ export default {
// //
this.readedMessage() this.readedMessage()
// //
if (this.chat.type == "GROUP") { if (this.isGroup) {
this.loadGroup(this.chat.targetId); this.loadGroup(this.chat.targetId);
} else { } else {
this.loadFriend(this.chat.targetId); this.loadFriend(this.chat.targetId);

11
im-web/src/components/chat/ChatBox.vue

@ -784,6 +784,9 @@ export default {
}, },
isPrivate() { isPrivate() {
return this.chat.type == 'PRIVATE'; return this.chat.type == 'PRIVATE';
},
loading() {
return this.chatStore.loading;
} }
}, },
watch: { watch: {
@ -833,6 +836,14 @@ export default {
} }
} }
} }
},
loading: {
handler(newLoading, oldLoading) {
// 线
if (!newLoading && this.isPrivate) {
this.loadReaded(this.chat.targetId)
}
}
} }
}, },
mounted() { mounted() {

Loading…
Cancel
Save