消息提示
This commit is contained in:
parent
217e8b51ed
commit
78d60bd9ac
@ -1,12 +1,13 @@
|
|||||||
<template>
|
<template>
|
||||||
<!-- login页面 -->
|
<!-- login页面 -->
|
||||||
<view>
|
<view :style="{'height':swiperHeight + 'px'}">
|
||||||
<!-- <view class="border_serach">
|
<!-- <view class="border_serach">
|
||||||
<view class="u-search">
|
<view class="u-search">
|
||||||
<u-search :show-action="false" input-align="left" shape="round" placeholder="搜索" v-model="keyword"></u-search>
|
<u-search :show-action="false" input-align="left" shape="round" placeholder="搜索" v-model="keyword"></u-search>
|
||||||
</view>
|
</view>
|
||||||
</view> -->
|
</view> -->
|
||||||
<!-- 消息列表 -->
|
<!-- 消息列表 -->
|
||||||
|
<u-empty text="并没有什么消息" mode="message" v-if="Object.keys(list).length == 0" style="margin: auto"></u-empty>
|
||||||
<view class="massage_list" v-for="(item,index) in list" :key="index" @click="gochat(item)">
|
<view class="massage_list" v-for="(item,index) in list" :key="index" @click="gochat(item)">
|
||||||
<view class="images">
|
<view class="images">
|
||||||
<image :src="item.avatar" ></image>
|
<image :src="item.avatar" ></image>
|
||||||
@ -50,11 +51,12 @@
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
onShow(){
|
onShow(){
|
||||||
this.list = this.imService.friends;
|
// this.list = this.imService.friends;
|
||||||
this.imService.onFriendListChange=this.onFriendListChange;
|
this.imService.onFriendListChange=this.onFriendListChange;
|
||||||
},
|
},
|
||||||
onLoad(){
|
onLoad(){
|
||||||
|
const res = uni.getSystemInfoSync();
|
||||||
|
this.swiperHeight = res.windowHeight;
|
||||||
this.list = this.imService.friends;
|
this.list = this.imService.friends;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -367,23 +367,23 @@ IMService.prototype.initialIMListeners = function () {
|
|||||||
this.onNewPrivateMessageReceive(friendId, message);
|
this.onNewPrivateMessageReceive(friendId, message);
|
||||||
});
|
});
|
||||||
|
|
||||||
//监听群聊消息
|
// //监听群聊消息
|
||||||
this.im.on(GoEasyIM.EVENT.GROUP_MESSAGE_RECEIVED, (message) => {
|
// this.im.on(GoEasyIM.EVENT.GROUP_MESSAGE_RECEIVED, (message) => {
|
||||||
let groupId = message.groupId;
|
// let groupId = message.groupId;
|
||||||
//群未读消息+1
|
// //群未读消息+1
|
||||||
let group = this.groups[groupId];
|
// let group = this.groups[groupId];
|
||||||
group.unReadMessage++;
|
// group.unReadMessage++;
|
||||||
removeGroupPendingMessage(this, groupId, message);
|
// removeGroupPendingMessage(this, groupId, message);
|
||||||
//如果页面传入了相应的listener,执行listener
|
// //如果页面传入了相应的listener,执行listener
|
||||||
this.onGroupListChange(this.groups);
|
// this.onGroupListChange(this.groups);
|
||||||
|
|
||||||
//更新群聊消息记录
|
// //更新群聊消息记录
|
||||||
let groupMessages = this.getGroupMessages(groupId);
|
// let groupMessages = this.getGroupMessages(groupId);
|
||||||
let sentMessages = groupMessages.sentMessages;
|
// let sentMessages = groupMessages.sentMessages;
|
||||||
sentMessages.push(message);
|
// sentMessages.push(message);
|
||||||
//如果页面传入了相应的listener,执行listener
|
// //如果页面传入了相应的listener,执行listener
|
||||||
this.onNewGroupMessageReceive(groupId, message);
|
// this.onNewGroupMessageReceive(groupId, message);
|
||||||
})
|
// })
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -620,6 +620,7 @@ function removeGroupPendingMessage(imService,groupId, message){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//下面是合并的
|
//下面是合并的
|
||||||
|
|
||||||
|
|
||||||
@ -784,12 +785,8 @@ IMService.prototype.subscribePresence = function (roomId) {
|
|||||||
//订阅聊天室消息
|
//订阅聊天室消息
|
||||||
IMService.prototype.subscribeRoomMessage = function (room, user) {
|
IMService.prototype.subscribeRoomMessage = function (room, user) {
|
||||||
this.room = new Room(room.id, room.name, user);
|
this.room = new Room(room.id, room.name, user);
|
||||||
this.room.onlineUsers = {
|
|
||||||
count: 0,
|
|
||||||
users: []
|
|
||||||
};
|
|
||||||
|
|
||||||
this.room.messages = [];
|
|
||||||
//监听上下线提醒
|
//监听上下线提醒
|
||||||
this.listenerGroupPresence();
|
this.listenerGroupPresence();
|
||||||
|
|
||||||
@ -799,11 +796,11 @@ IMService.prototype.subscribeRoomMessage = function (room, user) {
|
|||||||
this.subscribePresence(this.room.id);
|
this.subscribePresence(this.room.id);
|
||||||
//订阅聊天室消息
|
//订阅聊天室消息
|
||||||
// this.subscribeRoomMessage(this.room.id);
|
// this.subscribeRoomMessage(this.room.id);
|
||||||
this.im.subscribeGroup(this.room.id)
|
this.im.subscribeGroup([this.room.id])
|
||||||
.then(result => {
|
.then(result => {
|
||||||
console.log('消息订阅成功')
|
console.log('消息订阅成功')
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
console.log(e)
|
console.log(e,'失败')
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -844,4 +841,5 @@ IMService.prototype.quitRoom = function (roomId) {
|
|||||||
this.im.disconnect()
|
this.im.disconnect()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default IMService;
|
export default IMService;
|
Loading…
Reference in New Issue
Block a user