移动端聊天实现

This commit is contained in:
2023-10-08 21:38:22 +08:00
parent 7aa2e17897
commit df59768830
25 changed files with 505 additions and 377 deletions

View File

@@ -2,6 +2,9 @@ import http from '@/common/request'
import browser from '@/common/browser'
import store from '../store'
import pinyin from '@/common/pinyin.js';
import * as dayjs from 'dayjs'
export default {
// 获取字典
getdict(dict) {
@@ -464,6 +467,12 @@ export default {
store.dispatch('getChatList');
var chatWindowData = store.state.chatDatalist[userId].list
var chatListInfo = store.state.chatlist[userId]
var data2 = this.getKeyObjectStorage(store.state.userInfo.userId + '_' +
'chatlistData')
// var _num=data2[userId].num||
console.log("===========data2:",JSON.stringify(data2[userId]))
// 找到数组中对象属性值一样的对象并返回
function arrfindobject({
arr,
@@ -508,11 +517,11 @@ export default {
nickName: fromInfo.nickName,
portrait: fromInfo.portrait,
content: msgTypeLabel,
time: time,
time: dayjs(time).format("YYYY/MM/DD HH:mm:ss"),
num: disturb == 'Y' ? 'dot' : (chatListInfo.num ? chatListInfo.num + 1 : 1),
windowType: windowType,
disturb: disturb, //是否静默消息
top: top, //是否置顶
disturb: "N", //是否静默消息
top: "N", //是否置顶
userType: fromInfo.userType
}
}
@@ -526,7 +535,7 @@ export default {
time: time,
num: disturb == 'Y' ? 'dot' : (chatListInfo.num ? chatListInfo.num + 1 : 1),
windowType: windowType,
disturb: disturb, //是否静默消息
disturb: "N", //是否静默消息
top: top, //是否置顶
userType: 'GROUP'
}
@@ -990,6 +999,31 @@ export default {
});
// #endif
},
formatMessage(msg){
msg.pushType="MSG"
const _data=JSON.parse(msg.messageBody)
msg.msgContent={
msgType:"TEXT",
content:_data.content,
disturb:false,
top:false,
}
msg.windowType="SINGLE"
msg.createTime=msg.messageTime;
msg.userId=msg.fromId;
msg.fromInfo={
userId:msg.fromId,
userType:1,
nickName:msg.fromId,
portrait:"https://shudong2022.oss-cn-hangzhou.aliyuncs.com/common/user/logo.png"
};
msg.groupInfo={};
msg.msgId=msg.messageKey;
return msg
},
debounce(func, wait = 1000, immediate = true) {
/**
* @desc 函数防抖