|
|
@ -5,7 +5,7 @@ |
|
|
import * as enums from './common/enums'; |
|
|
import * as enums from './common/enums'; |
|
|
import * as wsApi from './common/wssocket'; |
|
|
import * as wsApi from './common/wssocket'; |
|
|
import UNI_APP from '@/.env.js' |
|
|
import UNI_APP from '@/.env.js' |
|
|
import { getCurrentInstance } from 'vue' |
|
|
|
|
|
export default { |
|
|
export default { |
|
|
data() { |
|
|
data() { |
|
|
return { |
|
|
return { |
|
|
@ -129,10 +129,9 @@ |
|
|
msg.selfSend = msg.sendId == this.userStore.userInfo.id; |
|
|
msg.selfSend = msg.sendId == this.userStore.userInfo.id; |
|
|
// 好友id |
|
|
// 好友id |
|
|
let friendId = msg.selfSend ? msg.recvId : msg.sendId; |
|
|
let friendId = msg.selfSend ? msg.recvId : msg.sendId; |
|
|
this.loadFriendInfo(friendId).then((friend) => { |
|
|
this.loadFriendInfo(friendId, (friend) => { |
|
|
this.insertPrivateMessage(friend, msg); |
|
|
this.insertPrivateMessage(friend, msg); |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
}, |
|
|
}, |
|
|
insertPrivateMessage(friend, msg) { |
|
|
insertPrivateMessage(friend, msg) { |
|
|
// 单人视频信令 |
|
|
// 单人视频信令 |
|
|
@ -205,7 +204,7 @@ |
|
|
} |
|
|
} |
|
|
// 标记这条消息是不是自己发的 |
|
|
// 标记这条消息是不是自己发的 |
|
|
msg.selfSend = msg.sendId == this.userStore.userInfo.id; |
|
|
msg.selfSend = msg.sendId == this.userStore.userInfo.id; |
|
|
this.loadGroupInfo(msg.groupId).then((group) => { |
|
|
this.loadGroupInfo(msg.groupId, (group) => { |
|
|
// 插入群聊消息 |
|
|
// 插入群聊消息 |
|
|
this.insertGroupMessage(group, msg); |
|
|
this.insertGroupMessage(group, msg); |
|
|
}) |
|
|
}) |
|
|
@ -264,37 +263,33 @@ |
|
|
// 播放提示音 |
|
|
// 播放提示音 |
|
|
this.playAudioTip(); |
|
|
this.playAudioTip(); |
|
|
}, |
|
|
}, |
|
|
loadFriendInfo(id) { |
|
|
loadFriendInfo(id, callback) { |
|
|
return new Promise((resolve, reject) => { |
|
|
|
|
|
let friend = this.friendStore.findFriend(id); |
|
|
let friend = this.friendStore.findFriend(id); |
|
|
if (friend) { |
|
|
if (friend) { |
|
|
resolve(friend); |
|
|
callback(friend); |
|
|
} else { |
|
|
} else { |
|
|
http({ |
|
|
http({ |
|
|
url: `/friend/find/${id}`, |
|
|
url: `/friend/find/${id}`, |
|
|
method: 'GET' |
|
|
method: 'GET' |
|
|
}).then((friend) => { |
|
|
}).then((friend) => { |
|
|
this.friendStore.addFriend(friend); |
|
|
this.friendStore.addFriend(friend); |
|
|
resolve(friend) |
|
|
callback(friend) |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
}); |
|
|
|
|
|
}, |
|
|
}, |
|
|
loadGroupInfo(id) { |
|
|
loadGroupInfo(id, callback) { |
|
|
return new Promise((resolve, reject) => { |
|
|
let group = this.groupStore.findGroup(id); |
|
|
let group = this.groupStore.groups.find((g) => g.id == id); |
|
|
|
|
|
if (group) { |
|
|
if (group) { |
|
|
resolve(group); |
|
|
callback(group); |
|
|
} else { |
|
|
} else { |
|
|
http({ |
|
|
http({ |
|
|
url: `/group/find/${id}`, |
|
|
url: `/group/find/${id}`, |
|
|
method: 'GET' |
|
|
method: 'GET' |
|
|
}).then((group) => { |
|
|
}).then((group) => { |
|
|
this.groupStore.addGroup(group); |
|
|
this.groupStore.addGroup(group); |
|
|
resolve(group) |
|
|
callback(group) |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
}); |
|
|
|
|
|
}, |
|
|
}, |
|
|
exit() { |
|
|
exit() { |
|
|
console.log("exit"); |
|
|
console.log("exit"); |
|
|
|