移动端聊天实现
This commit is contained in:
@@ -174,7 +174,7 @@
|
||||
onLoad(e) {
|
||||
|
||||
// // 监听接收聊天信息
|
||||
// uni.$on('onP2PMessage', this.onMessage)
|
||||
uni.$on('onP2PMessage', this.onMessage)
|
||||
|
||||
this.talkTo = e;
|
||||
console.log(this.talkTo)
|
||||
@@ -232,8 +232,6 @@
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
},
|
||||
onPageScroll() {
|
||||
this.clickToSubmitSure();
|
||||
@@ -267,7 +265,19 @@
|
||||
},
|
||||
methods: {
|
||||
onMessage(message) {
|
||||
|
||||
//判断当前是单聊还是群聊
|
||||
if (this.talkTo.windowType != 'SINGLE') {
|
||||
return;
|
||||
}
|
||||
//如果是单聊,则判断当前消息发送人是不是当前窗口的聊天对象
|
||||
if(this.talkTo.userId!=message.fromId){
|
||||
return;
|
||||
}
|
||||
console.log("message 聊天页收到回调")
|
||||
console.log(message)
|
||||
//如果当前消息发送人和当前窗口的聊天对象一致,则发送已读回执
|
||||
console.log("########### 此时需要发送已读回执 ###########")
|
||||
this.$store.dispatch('sendP2PMessageReciveAck',message)
|
||||
},
|
||||
addMsg(e) {
|
||||
this.msg += e;
|
||||
|
||||
@@ -158,12 +158,7 @@
|
||||
this.$store.dispatch('tabBarpull');
|
||||
},
|
||||
mounted() {
|
||||
|
||||
|
||||
this.$socketTask.connectSocket()
|
||||
|
||||
|
||||
|
||||
},
|
||||
methods: {
|
||||
longpressItem(e, i, v) {
|
||||
|
||||
Reference in New Issue
Block a user