no message

This commit is contained in:
kuaifan 2021-06-24 22:41:15 +08:00
parent ce36792303
commit 15df2707b5
2 changed files with 42 additions and 24 deletions

View File

@ -201,7 +201,7 @@ export default {
},
dialogMsgPush(data) {
if (this.natificationHidden && this.natificationReady) {
const {userid, type, msg} = data;
const {id, dialog_id, type, msg} = data;
let body = '';
switch (type) {
case 'text':
@ -213,20 +213,26 @@ export default {
default:
return;
}
this.$store.dispatch("getUserBasic", {
userid: userid,
success: (user) => {
this.notificationClass.replaceTitle(user.nickname);
this.notificationClass.replaceOptions({
icon: user.userimg,
body: body,
data: data,
tag: "dialog",
requireInteraction: true
});
this.notificationClass.userAgreed();
}
this._notificationId = id;
this.notificationClass.replaceOptions({
icon: $A.serverUrl('images/logo.png'),
body: body,
data: data,
tag: "dialog",
requireInteraction: true
});
let dialog = this.dialogs.find((item) => item.id == dialog_id);
if (dialog) {
this.notificationClass.replaceTitle(dialog.name);
this.notificationClass.userAgreed();
} else {
this.$store.dispatch("getDialogOne", dialog_id).then(({data}) => {
if (this._notificationId === id) {
this.notificationClass.replaceTitle(data.name);
this.notificationClass.userAgreed();
}
})
}
}
}
},
@ -323,6 +329,7 @@ export default {
if (this.notificationClass.support) {
this.notificationClass.notificationEvent({
onclick: ({target}) => {
console.log("[Notification] Click", target);
this.notificationClass.close();
window.focus();
//

View File

@ -1093,19 +1093,30 @@ export default {
},
/**
* 获取会话基础信息
* 获取单个会话信息
* @param state
* @param dispatch
* @param dialog_id
* @returns {Promise<unknown>}
*/
getDialogOne({state, dispatch}, dialog_id) {
dispatch("call", {
url: 'dialog/one',
data: {
dialog_id,
},
}).then(result => {
dispatch("saveDialog", result.data);
return new Promise(function (resolve, reject) {
if (state.method.runNum(dialog_id) === 0) {
reject({msg: 'Parameter error'});
return;
}
dispatch("call", {
url: 'dialog/one',
data: {
dialog_id,
},
}).then(result => {
dispatch("saveDialog", result.data);
resolve(result);
}).catch(e => {
console.error(e);
reject(e);
});
});
},
@ -1381,8 +1392,6 @@ export default {
(function (msg) {
const {mode, data} = msg;
const {dialog_id} = data;
// 更新消息列表
dispatch("saveDialogMsg", data)
if (mode === "add" || mode === "chat") {
// 新增任务消息数量
dispatch("increaseTaskMsgNum", dialog_id);
@ -1399,6 +1408,8 @@ export default {
}
state.dialogMsgPush = data;
}
// 更新消息列表
dispatch("saveDialogMsg", data)
// 更新最后消息
dispatch("updateDialogLastMsg", data);
})(msgDetail);