Merge pull request 'xbx' (#73) from xbx into master
Reviewed-on: http://git.luyuan.tk/luyuan/demingshangjia/pulls/73
This commit is contained in:
commit
5dd01ffa93
@ -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
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
import GoEasyIM from './goeasy-im-1.0.9';
|
||||
import restApi from './restapi';
|
||||
import music from './music.mp3'
|
||||
|
||||
function Friend(uuid, name, avatar,time = "", text = "",date = "",unReadMessage = 0) {
|
||||
this.uuid = uuid;
|
||||
@ -50,7 +51,7 @@ function IMService() {
|
||||
//群聊消息记录,map格式,每个群对应一个数组
|
||||
this.groupMessages = {};
|
||||
|
||||
|
||||
this.uid = 0;
|
||||
/*
|
||||
* 监听器们
|
||||
*
|
||||
@ -77,6 +78,10 @@ function IMService() {
|
||||
this.whenOnlineUserChange = function () {
|
||||
|
||||
};
|
||||
this.warrings = function() {
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
//登录
|
||||
@ -258,6 +263,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 +285,14 @@ IMService.prototype.initialIMListeners = function () {
|
||||
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
|
||||
if(!friend && friend == undefined){
|
||||
|
BIN
static/music.mp3
Normal file
BIN
static/music.mp3
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user