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

View File

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