消息提示

This commit is contained in:
luyuan 2020-08-08 16:32:37 +08:00
parent 217e8b51ed
commit 78d60bd9ac
Signed by: theluyuan
GPG Key ID: A7972FD973317FF3
2 changed files with 26 additions and 26 deletions

View File

@ -1,12 +1,13 @@
<template>
<!-- login页面 -->
<view>
<view :style="{'height':swiperHeight + 'px'}">
<!-- <view class="border_serach">
<view class="u-search">
<u-search :show-action="false" input-align="left" shape="round" placeholder="搜索" v-model="keyword"></u-search>
</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="images">
<image :src="item.avatar" ></image>
@ -50,11 +51,12 @@
},
},
onShow(){
this.list = this.imService.friends;
// this.list = this.imService.friends;
this.imService.onFriendListChange=this.onFriendListChange;
},
onLoad(){
const res = uni.getSystemInfoSync();
this.swiperHeight = res.windowHeight;
this.list = this.imService.friends;
}
};

View File

@ -367,23 +367,23 @@ IMService.prototype.initialIMListeners = function () {
this.onNewPrivateMessageReceive(friendId, message);
});
//监听群聊消息
this.im.on(GoEasyIM.EVENT.GROUP_MESSAGE_RECEIVED, (message) => {
let groupId = message.groupId;
//群未读消息+1
let group = this.groups[groupId];
group.unReadMessage++;
removeGroupPendingMessage(this, groupId, message);
//如果页面传入了相应的listener执行listener
this.onGroupListChange(this.groups);
// //监听群聊消息
// this.im.on(GoEasyIM.EVENT.GROUP_MESSAGE_RECEIVED, (message) => {
// let groupId = message.groupId;
// //群未读消息+1
// let group = this.groups[groupId];
// group.unReadMessage++;
// removeGroupPendingMessage(this, groupId, message);
// //如果页面传入了相应的listener执行listener
// this.onGroupListChange(this.groups);
//更新群聊消息记录
let groupMessages = this.getGroupMessages(groupId);
let sentMessages = groupMessages.sentMessages;
sentMessages.push(message);
//如果页面传入了相应的listener执行listener
this.onNewGroupMessageReceive(groupId, message);
})
// //更新群聊消息记录
// let groupMessages = this.getGroupMessages(groupId);
// let sentMessages = groupMessages.sentMessages;
// sentMessages.push(message);
// //如果页面传入了相应的listener执行listener
// 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) {
this.room = new Room(room.id, room.name, user);
this.room.onlineUsers = {
count: 0,
users: []
};
this.room.messages = [];
//监听上下线提醒
this.listenerGroupPresence();
@ -799,11 +796,11 @@ IMService.prototype.subscribeRoomMessage = function (room, user) {
this.subscribePresence(this.room.id);
//订阅聊天室消息
// this.subscribeRoomMessage(this.room.id);
this.im.subscribeGroup(this.room.id)
this.im.subscribeGroup([this.room.id])
.then(result => {
console.log('消息订阅成功')
}).catch(e => {
console.log(e)
console.log(e,'失败')
})
}
@ -844,4 +841,5 @@ IMService.prototype.quitRoom = function (roomId) {
this.im.disconnect()
};
export default IMService;