临时测试
This commit is contained in:
parent
74a9778a62
commit
217e8b51ed
@ -271,6 +271,7 @@
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script>
|
<script>
|
||||||
|
const ChatRoomService =require('../../static/chatservice');
|
||||||
export default {
|
export default {
|
||||||
data: {
|
data: {
|
||||||
fil: true,
|
fil: true,
|
||||||
@ -361,17 +362,27 @@
|
|||||||
console.log(res.data)
|
console.log(res.data)
|
||||||
that.info = res.data.data.memberInfo
|
that.info = res.data.data.memberInfo
|
||||||
|
|
||||||
|
console.log(uni.getStorageSync('userinfo'),123)
|
||||||
|
//当前用户
|
||||||
|
var currentUser = {
|
||||||
|
id : Date.parse(new Date()) + "",
|
||||||
|
nickname : res.data.data.memberInfo.member_nickname + "",
|
||||||
|
avatar: res.data.data.memberInfo.member_avatar
|
||||||
|
};
|
||||||
|
|
||||||
var room = {
|
var room = {
|
||||||
id : a.id + "",
|
id : a.id + "",
|
||||||
name : a.id + ""
|
name : a.id + ""
|
||||||
};
|
};
|
||||||
|
that.chatRoomService = getApp().globalData.im
|
||||||
|
console.log(room,currentUser)
|
||||||
|
//构造chatRoomService
|
||||||
|
that.chatRoomService.subscribeRoomMessage(room,currentUser)
|
||||||
|
that.chatRoomService.initialWhenNewMessage(that.whenNewMessage);
|
||||||
|
//获取当前聊天室数据
|
||||||
|
that.room = that.chatRoomService.room;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
this.chatRoomService = getApp().globalData.im
|
|
||||||
this.chatRoomService.subscribeGroupMessage(a.id)
|
|
||||||
let shi = 0;
|
let shi = 0;
|
||||||
let fen = 0;
|
let fen = 0;
|
||||||
let miao = 0;
|
let miao = 0;
|
||||||
|
@ -616,6 +616,53 @@ function removeGroupPendingMessage(imService,groupId, message){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//下面是合并的
|
||||||
|
|
||||||
|
|
||||||
|
//用户
|
||||||
|
function User(id, nickname, avatar) {
|
||||||
|
this.id = id;
|
||||||
|
this.nickname = nickname;
|
||||||
|
this.avatar = avatar;
|
||||||
|
}
|
||||||
|
|
||||||
|
//消息
|
||||||
|
function Message(senderUserId, senderNickname, content, type) {
|
||||||
|
this.senderNickname = senderNickname;
|
||||||
|
this.senderUserId = senderUserId;
|
||||||
|
this.content = content;
|
||||||
|
this.type = type
|
||||||
|
}
|
||||||
|
|
||||||
|
//聊天室
|
||||||
|
function Room(id, name, currentUser) {
|
||||||
|
|
||||||
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
|
this.currentUser = currentUser;
|
||||||
|
|
||||||
|
this.onlineUsers = {
|
||||||
|
count: 0,
|
||||||
|
users: []
|
||||||
|
};
|
||||||
|
|
||||||
|
this.messages = [];
|
||||||
|
|
||||||
|
this.MessageType = {
|
||||||
|
CHAT: 0,//文字聊天
|
||||||
|
PROP: 1//道具
|
||||||
|
};
|
||||||
|
|
||||||
|
this.Prop = {
|
||||||
|
HEART: 0,//桃心
|
||||||
|
ROCKET: 1//火箭
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
IMService.prototype.initialWhenNewMessage = function (whenNewMessage) {
|
IMService.prototype.initialWhenNewMessage = function (whenNewMessage) {
|
||||||
this.whenNewMessage = whenNewMessage;
|
this.whenNewMessage = whenNewMessage;
|
||||||
};
|
};
|
||||||
@ -737,6 +784,12 @@ 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();
|
||||||
|
|
||||||
@ -745,8 +798,8 @@ 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([roomId])
|
this.im.subscribeGroup(this.room.id)
|
||||||
.then(result => {
|
.then(result => {
|
||||||
console.log('消息订阅成功')
|
console.log('消息订阅成功')
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user