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) { privateNewMsg(msg) {
if ( if (
msg.userType !== 2 || msg.userType !== 2 ||
(msg.userType === 2 && this.privateNewMsg.privateUserId === this.userId) (msg.userType === 2 && msg.privateUserId === this.userId)
) { ) {
this.list.unshift(msg); this.list.unshift(msg);
} }

View File

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

View File

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

View File

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