first commit
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
import {Service} from "@/Service/Service"
|
||||
export class EventHandler {
|
||||
//处理事件
|
||||
static Events(data: any) {
|
||||
var result = JSON.parse(data.data);
|
||||
// console.log('接收消息', result);
|
||||
this.ChatEnent(result);
|
||||
// if (result.code == 'Chat') {
|
||||
// this.ChatEnent(result);
|
||||
// } else if (result.code == 'System') {
|
||||
// this.SystemEnent(result);
|
||||
// } else if (result.code == 'User') {
|
||||
// this.ChatUserEnent(result);
|
||||
// }
|
||||
}
|
||||
|
||||
static ChatEnent(data: any) {
|
||||
console.log(data,'xxx')
|
||||
var eventName = `chat_${data.chanId}`;
|
||||
uni.$emit(eventName, data);
|
||||
}
|
||||
|
||||
static ChatUserEnent(data: any) {
|
||||
var eventUserName = `chatUser_${data.sendId}`;
|
||||
uni.$emit('UpdatePrivateMsg', data);
|
||||
uni.$emit(eventUserName, data);
|
||||
this.plusPush();
|
||||
}
|
||||
|
||||
static plusPush() {
|
||||
//#ifdef APP-PLUS
|
||||
if(!Service.getIsHede()){
|
||||
return
|
||||
}
|
||||
|
||||
let content = '您有一条新的消息~';
|
||||
let options = {
|
||||
cover: false,
|
||||
when: new Date(),
|
||||
title: '通知消息'
|
||||
};
|
||||
let body = {
|
||||
id: 'id',
|
||||
key: 'key'
|
||||
};
|
||||
let payload = JSON.stringify(body);
|
||||
plus.push.createMessage(content, payload, options);
|
||||
//#endif
|
||||
}
|
||||
|
||||
static SystemEnent(data: any) {
|
||||
let obj = JSON.parse(data.data);
|
||||
if (obj.code == 'Like' || obj.code == 'Aite' || obj.code == 'Comment' || obj.code == 'Notice') {
|
||||
uni.$emit('MegEvent', obj);
|
||||
} else if (obj.code == 'Off') {
|
||||
uni.$emit('ImComOff', 'user');
|
||||
} else if (obj.code == 'UpdateUserInfo') {
|
||||
uni.$emit('UpdateUserInfo');
|
||||
} else if (obj.code == 'Friend') {
|
||||
uni.$emit('Friend');
|
||||
}
|
||||
}
|
||||
|
||||
static ConnectBus() {
|
||||
uni.$emit('UpdateChat');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user