Commit ff9c78b8 authored by 罗超's avatar 罗超

Merge branch 'master' of http://gitlab.oytour.com/viitto/madara

parents f7356744 80bf7800
...@@ -670,7 +670,6 @@ export default { ...@@ -670,7 +670,6 @@ export default {
return result; return result;
}, },
formatCustom(item) { formatCustom(item) {
console.log(item)
if (item.content) { if (item.content) {
item.customData = JSON.parse(item.content).data; item.customData = JSON.parse(item.content).data;
......
...@@ -214,6 +214,7 @@ export default { ...@@ -214,6 +214,7 @@ export default {
}, },
data() { data() {
return { return {
sessionlistHis: [],
sessionKey: "", sessionKey: "",
currentSession: { currentSession: {
id: "" id: ""
...@@ -241,8 +242,28 @@ export default { ...@@ -241,8 +242,28 @@ export default {
// 提交sdk连接请求 // 提交sdk连接请求
this.$store.dispatch("connect"); this.$store.dispatch("connect");
this.$store.dispatch("updateRefreshState"); this.$store.dispatch("updateRefreshState");
}, watch: {
// 监听消息接受
sessionlistHis(newVal, oldVal) {
if (JSON.stringify(newVal) !== JSON.stringify(oldVal)) {
this.getUnreadHis()
}
}
}, },
methods: { 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() { showNotice() {
this.$electron.ipcRenderer.send('load-notice') this.$electron.ipcRenderer.send('load-notice')
}, },
...@@ -544,6 +565,7 @@ export default { ...@@ -544,6 +565,7 @@ export default {
}, },
sessionlist() { sessionlist() {
let unreadList = []; let unreadList = [];
let sessionlistHis = []
let historicList = window.localStorage.historicList ? JSON.parse(window.localStorage.historicList) : []; let historicList = window.localStorage.historicList ? JSON.parse(window.localStorage.historicList) : [];
// console.log("this.$store.state.sessionlist", this.$store.state.sessionlist) // console.log("this.$store.state.sessionlist", this.$store.state.sessionlist)
let sessionlist = this.$store.state.sessionlist.filter(item => { let sessionlist = this.$store.state.sessionlist.filter(item => {
...@@ -575,7 +597,7 @@ export default { ...@@ -575,7 +597,7 @@ export default {
} }
} else if (item.scene === "team") { } else if (item.scene === "team") {
if (item.unread > 0) { if (item.unread > 0) {
console.log(item.unread) sessionlistHis.push(item)
} }
let teamInfo = null; let teamInfo = null;
teamInfo = this.$store.state.teamlist.find(team => { teamInfo = this.$store.state.teamlist.find(team => {
...@@ -720,6 +742,7 @@ export default { ...@@ -720,6 +742,7 @@ export default {
this.newMsgList = unreadList; this.newMsgList = unreadList;
this.sessionlistHis = sessionlistHis;
return sessionlist; return sessionlist;
} }
// netState(){ // netState(){
......
...@@ -478,12 +478,16 @@ export function getHistoryMsgs({ state, commit }, obj) { ...@@ -478,12 +478,16 @@ export function getHistoryMsgs({ state, commit }, obj) {
return formatMsg(msg) return formatMsg(msg)
}) })
if (pageDatas) { 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') store.dispatch('hideLoading')
......
...@@ -257,6 +257,11 @@ export default { ...@@ -257,6 +257,11 @@ export default {
} }
} }
}, },
// 装入未读消息
unreadListHis(state, obj) {
state.unreadListHis[obj.to] = obj.msgs
console.log(state.unreadListHis, "装数据")
},
// clearMsgs(state, obj) { // clearMsgs(state, obj) {
// state.msgs = [] // state.msgs = []
// }, // },
......
...@@ -72,7 +72,8 @@ export default { ...@@ -72,7 +72,8 @@ export default {
noMoreHistoryMsgs: false, noMoreHistoryMsgs: false,
// 继续对话的机器人id // 继续对话的机器人id
continueRobotAccid: '', continueRobotAccid: '',
// 未读消息
unreadListHis: {},
// 系统消息 // 系统消息
sysMsgs: [], sysMsgs: [],
customSysMsgs: [], 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