no message

This commit is contained in:
kuaifan 2021-06-06 23:14:54 +08:00
parent 2ca3e04221
commit ab5a7544f2
3 changed files with 28 additions and 7 deletions

View File

@ -22,6 +22,7 @@
<div class="dialog-box">
<div class="dialog-title">
<span>{{dialog.name}}</span>
<Icon v-if="dialog.type == 'user' && lastMsgReadDone(dialog.last_msg)" :type="lastMsgReadDone(dialog.last_msg)"/>
<em v-if="dialog.last_at">{{formatTime(dialog.last_at)}}</em>
</div>
<div class="dialog-text">{{formatLastMsg(dialog.last_msg)}}</div>
@ -82,7 +83,7 @@ export default {
},
computed: {
...mapState(['dialogId', 'dialogList']),
...mapState(['userId', 'dialogId', 'dialogList']),
dialogLists() {
const {dialogKey} = this;
@ -144,6 +145,16 @@ export default {
}
return '';
},
lastMsgReadDone(data) {
if ($A.isJson(data)) {
const {userid, percentage} = data;
if (userid === this.userId) {
return percentage === 100 ? 'md-done-all' : 'md-checkmark';
}
}
return null;
}
}
}
</script>

View File

@ -391,7 +391,6 @@ export default {
if (data) {
state.dialogMsgList.splice(index, 1, state.method.cloneJSON(data));
// 是最后一条消息时更新对话 last_msg
console.log(data);
if (state.dialogMsgList.length - 1 == index) {
const dialog = state.dialogList.find(({id}) => id == data.dialog_id);
if (dialog) dialog.last_msg = data;
@ -496,10 +495,16 @@ export default {
(function (msg, that) {
const {mode, data} = msg;
const {dialog_id} = data;
// 更新最后消息
let dialog = state.dialogList.find(({id}) => id == dialog_id);
if (dialog) {
dialog.last_msg = data;
} else {
that.commit('getDialogOne', dialog_id);
}
if (mode === "add") {
let dialog = state.dialogList.find(({id}) => id == dialog_id);
if (dialog) {
dialog.last_msg = data;
// 新增未读数
if (state.dialogId !== dialog_id) dialog.unread++;
// 移动到首位
const index = state.dialogList.findIndex(({id}) => id == dialog_id);
@ -508,9 +513,8 @@ export default {
state.dialogList.splice(index, 1);
state.dialogList.unshift(tmp);
}
} else {
that.commit('getDialogOne', dialog_id);
}
// 新增总未读数
if (state.dialogId !== dialog_id) state.dialogMsgUnread++;
}
})(msgDetail, this);

View File

@ -1124,11 +1124,17 @@ body {
overflow: hidden;
text-overflow: ellipsis;
}
> i {
margin-left: 8px;
transform: scale(0.9);
font-size: 12px;
color: #87d068;
}
> em {
margin-left: 8px;
font-style: normal;
color: #999999;
font-size: 12px;
padding-left: 10px;
}
}
.dialog-text {