Merge pull request 'xbx' (#73) from xbx into master

Reviewed-on: http://git.luyuan.tk/luyuan/demingshangjia/pulls/73
This commit is contained in:
luyuan 2020-08-27 14:04:24 +08:00
commit 5dd01ffa93
4 changed files with 48 additions and 1 deletions

View File

@ -126,6 +126,7 @@
this.friend = JSON.parse(options.id); this.friend = JSON.parse(options.id);
this.currentUser = this.imService.currentUser; this.currentUser = this.imService.currentUser;
let privateMessages = this.imService.getPrivateMessages(this.friend.uuid); let privateMessages = this.imService.getPrivateMessages(this.friend.uuid);
this.imService.uid = this.friend.uuid;
this.messages = privateMessages.sentMessages; this.messages = privateMessages.sentMessages;
this.pendingMessages = privateMessages.pendingMessages; this.pendingMessages = privateMessages.pendingMessages;
@ -151,6 +152,7 @@
this.imService.onPrivateHistoryLoad = (friendId, messages) =>{}; this.imService.onPrivateHistoryLoad = (friendId, messages) =>{};
// //
this.imService.resetFriendUnReadMessage(this.friend); this.imService.resetFriendUnReadMessage(this.friend);
this.imService.uid = 0;
}, },
methods: { methods: {
initialListeners () { initialListeners () {

View File

@ -476,6 +476,7 @@
//构造chatRoomService //构造chatRoomService
that.chatRoomService.subscribeRoomMessage(room,currentUser) that.chatRoomService.subscribeRoomMessage(room,currentUser)
that.chatRoomService.initialWhenNewMessage(that.whenNewMessage); that.chatRoomService.initialWhenNewMessage(that.whenNewMessage);
that.chatRoomService.warrings = that.jinggao
//获取当前聊天室数据 //获取当前聊天室数据
that.room = that.chatRoomService.room; that.room = that.chatRoomService.room;
that.chatRoomService.initialWhenOnlineUserChange(that.renqu) that.chatRoomService.initialWhenOnlineUserChange(that.renqu)
@ -560,6 +561,32 @@
}, },
methods: { 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){ renqu(res){
if(res.users.length > this.renqu){ if(res.users.length > this.renqu){
this.renqu = res.users.length this.renqu = res.users.length

View File

@ -7,6 +7,7 @@
import GoEasyIM from './goeasy-im-1.0.9'; import GoEasyIM from './goeasy-im-1.0.9';
import restApi from './restapi'; import restApi from './restapi';
import music from './music.mp3'
function Friend(uuid, name, avatar,time = "", text = "",date = "",unReadMessage = 0) { function Friend(uuid, name, avatar,time = "", text = "",date = "",unReadMessage = 0) {
this.uuid = uuid; this.uuid = uuid;
@ -50,7 +51,7 @@ function IMService() {
//群聊消息记录map格式每个群对应一个数组 //群聊消息记录map格式每个群对应一个数组
this.groupMessages = {}; this.groupMessages = {};
this.uid = 0;
/* /*
* 监听器们 * 监听器们
* *
@ -77,6 +78,10 @@ function IMService() {
this.whenOnlineUserChange = function () { this.whenOnlineUserChange = function () {
}; };
this.warrings = function() {
};
} }
//登录 //登录
@ -258,6 +263,11 @@ IMService.prototype.initialIMListeners = function () {
//监听私聊消息 //监听私聊消息
this.im.on(GoEasyIM.EVENT.PRIVATE_MESSAGE_RECEIVED, (message) => { this.im.on(GoEasyIM.EVENT.PRIVATE_MESSAGE_RECEIVED, (message) => {
console.log(message) console.log(message)
if(message.senderId == 0){
console.log(message.payload.text)
this.warrings(JSON.parse(message.payload.text))
return;
}
//如果不是自己发的,朋友未读消息数 +1 //如果不是自己发的,朋友未读消息数 +1
if (message.senderId != this.currentUser.uuid) { if (message.senderId != this.currentUser.uuid) {
let friend = this.friends[message.senderId]; let friend = this.friends[message.senderId];
@ -275,6 +285,14 @@ IMService.prototype.initialIMListeners = function () {
friends.sort(paixu) friends.sort(paixu)
} }
if(message.senderId != this.uid){
const innerAudioContext = uni.createInnerAudioContext();
innerAudioContext.autoplay = true;
innerAudioContext.src = music;
innerAudioContext.onPlay(() => {
console.log('开始播放');
});
}
let that = this let that = this
if(!friend && friend == undefined){ if(!friend && friend == undefined){

BIN
static/music.mp3 Normal file

Binary file not shown.