Commit 1d5410ef authored by 华国豪's avatar 华国豪 🙄

获取消息列表未读消息

parent 52fd672b
......@@ -670,7 +670,6 @@ export default {
return result;
},
formatCustom(item) {
console.log(item)
if (item.content) {
item.customData = JSON.parse(item.content).data;
......
......@@ -214,6 +214,7 @@ export default {
},
data() {
return {
sessionlistHis: [],
sessionKey: "",
currentSession: {
id: ""
......@@ -241,8 +242,28 @@ export default {
// 提交sdk连接请求
this.$store.dispatch("connect");
this.$store.dispatch("updateRefreshState");
}, watch: {
// 监听消息接受
sessionlistHis(newVal, oldVal) {
if (JSON.stringify(newVal) !== JSON.stringify(oldVal)) {
this.getUnreadHis()
}
}
},
methods: {
// 获取会话列表有未读消息的会话的所有聊天记录
getUnreadHis: function (){
let list = this.sessionlistHis
for(let i = 0; i < list.length; i++){
this.$store.dispatch("getHistoryMsgs", {
scene: list[i].scene,
to: list[i].to,
pageDatas: list[i].unread,
});
}
// let msgs = this.$store.state.unreadListHis;
// console.log(msgs, "// 获取会话列表有未读消息的会话的所有聊天记录")
},
showNotice() {
this.$electron.ipcRenderer.send('load-notice')
},
......@@ -544,6 +565,7 @@ export default {
},
sessionlist() {
let unreadList = [];
let sessionlistHis = []
let historicList = window.localStorage.historicList ? JSON.parse(window.localStorage.historicList) : [];
// console.log("this.$store.state.sessionlist", this.$store.state.sessionlist)
let sessionlist = this.$store.state.sessionlist.filter(item => {
......@@ -575,7 +597,7 @@ export default {
}
} else if (item.scene === "team") {
if (item.unread > 0) {
console.log(item.unread)
sessionlistHis.push(item)
}
let teamInfo = null;
teamInfo = this.$store.state.teamlist.find(team => {
......@@ -720,6 +742,7 @@ export default {
this.newMsgList = unreadList;
this.sessionlistHis = sessionlistHis;
return sessionlist;
}
// netState(){
......
......@@ -478,12 +478,16 @@ export function getHistoryMsgs({ state, commit }, obj) {
return formatMsg(msg)
})
if (pageDatas) {
console.log(msgs)
commit('unreadListHis', {
msgs: msgs,
to: to
})
} else {
commit('updateCurrSessionMsgs', {
type: 'concat',
msgs: msgs
})
}
commit('updateCurrSessionMsgs', {
type: 'concat',
msgs: msgs
})
}
}
store.dispatch('hideLoading')
......
......@@ -257,6 +257,11 @@ export default {
}
}
},
// 装入未读消息
unreadListHis(state, obj) {
state.unreadListHis[obj.to] = obj.msgs
console.log(state.unreadListHis, "装数据")
},
// clearMsgs(state, obj) {
// state.msgs = []
// },
......
......@@ -72,7 +72,8 @@ export default {
noMoreHistoryMsgs: false,
// 继续对话的机器人id
continueRobotAccid: '',
// 未读消息
unreadListHis: {},
// 系统消息
sysMsgs: [],
customSysMsgs: [],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment