fix: bug修复

This commit is contained in:
kaizheng(郑凯) 2025-02-14 14:19:08 +08:00
parent 8b791d244f
commit 7cf28d106b
4 changed files with 20 additions and 17 deletions

View File

@ -139,7 +139,7 @@ export default {
privateNewMsg(msg) {
if (
msg.userType !== 2 ||
(msg.userType === 2 && this.privateNewMsg.privateUserId === this.userId)
(msg.userType === 2 && msg.privateUserId === this.userId)
) {
this.list.unshift(msg);
}

View File

@ -2,11 +2,9 @@
<div class="privat-chat">
<div class="header">
<div class="left">
<el-button
size="mini"
type="primary"
@click="closePrivateChat"
>返回群聊</el-button>
<el-button size="mini" type="primary" @click="closePrivateChat"
>返回群聊</el-button
>
<h5>{{ userInfo.userName }}</h5>
</div>
<div>私聊中</div>

View File

@ -19,7 +19,7 @@
<!-- <el-badge is-dot class="item"
><img :src="defaultAvatar.student" alt="" />
</el-badge> -->
<img :src="defaultAvatar.student" alt="">
<img :src="defaultAvatar.student" alt="" />
</div>
<div class="user-info">
<p>
@ -76,10 +76,10 @@ export default {
privateNewMsg(msg) {
if (this.userIdsMsgObj[msg.privateUserId]) {
Object.assign(this.userIdsMsgObj[msg.privateUserId], msg);
this.$set(msg, "newMsgTip", true);
this.$set(this.userIdsMsgObj[msg.privateUserId], "newMsgTip", true);
} else {
this.list.unshift(msg);
this.$set(msg, "newMsgTip", true);
this.$set(this.userIdsMsgObj[msg.privateUserId], "newMsgTip", true);
}
this.list = this.list.sort((x, y) => {
return (
@ -113,15 +113,14 @@ export default {
}
this.loading = false;
},
searchMsg() {
async searchMsg() {
await this.getPrivateChatList();
if (this.keyword) {
this.filterList = this.list.filter(item => {
const userName =
item.userType !== 2 ? item.privateUserName : item.userName;
return userName.includes(this.keyword);
});
} else {
this.filterList = this.list;
}
}
}

View File

@ -321,10 +321,17 @@ export default {
});
},
toPrivateChat(userInfo) {
this.privateUserInfo = Object.assign({
privateUserId: userInfo.userId,
privateUserName: userInfo.userName
});
this.privateUserInfo = Object.assign(
userInfo.userType === 2
? {
privateUserId: userInfo.userId,
privateUserName: userInfo.userName
}
: {
privateUserId: userInfo.privateUserId,
privateUserName: userInfo.privateUserName
}
);
this.chatType = 2;
},
closePrivateChat() {
@ -382,7 +389,6 @@ export default {
}
},
handlePrivateChatTopic(msg) {
debugger;
console.log("handlePrivateChatTopic", msg);
const body = JSON.parse(msg.body);
if ([1].includes(body.type)) {