fix: bug修复

This commit is contained in:
kaizheng(郑凯) 2025-03-02 16:56:23 +08:00
parent bde3379cb6
commit 5672b74037
2 changed files with 18 additions and 7 deletions

View File

@ -91,7 +91,7 @@ export default {
groupId(value) { groupId(value) {
this.params.id = value; this.params.id = value;
this.keyword = ""; this.keyword = "";
this.getPrivateChatList(); this.searchMsg();
}, },
privateNewMsg(msg) { privateNewMsg(msg) {
if (this.userIdsMsgObj[msg.privateUserId]) { if (this.userIdsMsgObj[msg.privateUserId]) {
@ -126,8 +126,12 @@ export default {
new Date(y.createTime).getTime() - new Date(x.createTime).getTime() new Date(y.createTime).getTime() - new Date(x.createTime).getTime()
); );
}); });
list.forEach(item => { list.forEach((item, index) => {
this.userIdsMsgObj[item.privateUserId] = item; if (this.userIdsMsgObj[item.privateUserId]) {
list.splice(index, 1);
} else {
this.userIdsMsgObj[item.privateUserId] = item;
}
}); });
this.list = this.list.concat(list); this.list = this.list.concat(list);
this.filterList = this.list; this.filterList = this.list;
@ -136,6 +140,9 @@ export default {
this.loading = false; this.loading = false;
}, },
async searchMsg() { async searchMsg() {
this.hasNext = true;
this.list = [];
this.userIdsMsgObj = {};
this.params.current = 0; this.params.current = 0;
await this.getPrivateChatList(); await this.getPrivateChatList();
// if (this.keyword) { // if (this.keyword) {
@ -153,7 +160,6 @@ export default {
.list-wrap { .list-wrap {
height: 600px; height: 600px;
overflow-y: scroll; overflow-y: scroll;
background: #fff;
} }
.search { .search {
display: flex; display: flex;
@ -210,5 +216,6 @@ ul {
.load-tip { .load-tip {
text-align: center; text-align: center;
line-height: 50px; line-height: 50px;
background: #fff;
} }
</style> </style>

View File

@ -67,7 +67,6 @@ export default {
}, },
methods: { methods: {
modifyStateCallback(item) { modifyStateCallback(item) {
debugger;
this.$emit("modifyStateCallback", item); this.$emit("modifyStateCallback", item);
}, },
async getList() { async getList() {
@ -79,8 +78,12 @@ export default {
if (ret && ret.code === 0 && ret.data.list) { if (ret && ret.code === 0 && ret.data.list) {
const list = ret.data.list; const list = ret.data.list;
list.forEach(item => { list.forEach((item, index) => {
this.userIdsObj[item.privateUserId] = item; if (this.userIdsObj[item.privateUserId]) {
list.splice(index, 1);
} else {
this.userIdsObj[item.privateUserId] = item;
}
}); });
this.list = this.list.concat(list); this.list = this.list.concat(list);
this.hasNext = ret.data.list.length === this.params.size; this.hasNext = ret.data.list.length === this.params.size;
@ -90,6 +93,7 @@ export default {
searchMsg() { searchMsg() {
this.hasNext = true; this.hasNext = true;
this.params.current = 0; this.params.current = 0;
this.userIdsObj = {};
this.list = []; this.list = [];
this.getList(); this.getList();
}, },