t添加了提示和直播
This commit is contained in:
parent
6d4c9dc5a4
commit
4e02daa854
@ -126,6 +126,7 @@
|
||||
this.friend = JSON.parse(options.id);
|
||||
this.currentUser = this.imService.currentUser;
|
||||
let privateMessages = this.imService.getPrivateMessages(this.friend.uuid);
|
||||
this.imService.uid = this.friend.uuid;
|
||||
this.messages = privateMessages.sentMessages;
|
||||
this.pendingMessages = privateMessages.pendingMessages;
|
||||
|
||||
@ -151,6 +152,7 @@
|
||||
this.imService.onPrivateHistoryLoad = (friendId, messages) =>{};
|
||||
//将未读消息数清零
|
||||
this.imService.resetFriendUnReadMessage(this.friend);
|
||||
this.imService.uid = 0;
|
||||
},
|
||||
methods: {
|
||||
initialListeners () {
|
||||
|
@ -476,6 +476,7 @@
|
||||
//构造chatRoomService
|
||||
that.chatRoomService.subscribeRoomMessage(room,currentUser)
|
||||
that.chatRoomService.initialWhenNewMessage(that.whenNewMessage);
|
||||
that.chatRoomService.warrings = that.jinggao
|
||||
//获取当前聊天室数据
|
||||
that.room = that.chatRoomService.room;
|
||||
that.chatRoomService.initialWhenOnlineUserChange(that.renqu)
|
||||
@ -560,6 +561,32 @@
|
||||
|
||||
},
|
||||
methods: {
|
||||
jinggao(text){
|
||||
console.log(text)
|
||||
if(text.message_type == 1){
|
||||
uni.showModal({
|
||||
title: '警告',
|
||||
content: text.content,
|
||||
showCancel:false,
|
||||
success: function (res) {
|
||||
|
||||
}
|
||||
});
|
||||
}else if(text.message_type == 2){
|
||||
uni.showModal({
|
||||
title: '警告',
|
||||
content: text.content,
|
||||
showCancel:false,
|
||||
success: function (res) {
|
||||
uni.navigateBack({
|
||||
delta: 1
|
||||
});
|
||||
}
|
||||
});
|
||||
this.stop()
|
||||
|
||||
}
|
||||
},
|
||||
renqu(res){
|
||||
if(res.users.length > this.renqu){
|
||||
this.renqu = res.users.length
|
||||
|
@ -50,7 +50,7 @@ function IMService() {
|
||||
//群聊消息记录,map格式,每个群对应一个数组
|
||||
this.groupMessages = {};
|
||||
|
||||
|
||||
this.uid = 0;
|
||||
/*
|
||||
* 监听器们
|
||||
*
|
||||
@ -77,6 +77,10 @@ function IMService() {
|
||||
this.whenOnlineUserChange = function () {
|
||||
|
||||
};
|
||||
this.warrings = function() {
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
//登录
|
||||
@ -258,6 +262,11 @@ IMService.prototype.initialIMListeners = function () {
|
||||
//监听私聊消息
|
||||
this.im.on(GoEasyIM.EVENT.PRIVATE_MESSAGE_RECEIVED, (message) => {
|
||||
console.log(message)
|
||||
if(message.senderId == 0){
|
||||
console.log(message.payload.text)
|
||||
this.warrings(JSON.parse(message.payload.text))
|
||||
return;
|
||||
}
|
||||
//如果不是自己发的,朋友未读消息数 +1
|
||||
if (message.senderId != this.currentUser.uuid) {
|
||||
let friend = this.friends[message.senderId];
|
||||
@ -275,6 +284,14 @@ IMService.prototype.initialIMListeners = function () {
|
||||
friends.sort(paixu)
|
||||
|
||||
}
|
||||
if(message.senderId != this.uid){
|
||||
const innerAudioContext = uni.createInnerAudioContext();
|
||||
innerAudioContext.autoplay = true;
|
||||
innerAudioContext.src = 'https://img-cdn-qiniu.dcloud.net.cn/uniapp/audio/music.mp3';
|
||||
innerAudioContext.onPlay(() => {
|
||||
console.log('开始播放');
|
||||
});
|
||||
}
|
||||
|
||||
let that = this
|
||||
if(!friend && friend == undefined){
|
||||
|
Loading…
Reference in New Issue
Block a user