import CellsysMessage from './cellsysMessage'; import { EditTask, EditType, SubmitType } from './cellsysUtil'; import cellsysMessage from './cellsysMessage'; class CellsysChatUser { constructor(params = {}) { this.userId = params.userId; this.mobile = params.mobile; this.realName = params.realName; this.name = params.name; this.avatar = params.avatar; this.unReadMessages = []; //CellsysMessage集合 this.groups = []; } setGroups(groups) { this.groups = groups; } getGroups() { return this.groups; } /** * 添加单个消息 * @param message */ addMessage(cellsysMessage) { this.unReadMessages.push(cellsysMessage); } getMessages() { return this.unReadMessages; } getMessageCount() { return this.unReadMessages.length; } hasMessage() { return this.getMessageCount() > 0; } setUserInfo(param) { this.userId = param.userId; this.mobile = param.mobile; this.realName = param.realName; this.name = param.name; this.avatar = param.avatar; this.description = param.description; this.groups = param.groups || []; } getUserInfo() { return { userId: this.userId, mobile: this.mobile, realName: this.realName, name: this.name, avatar: this.avatar, description: this.description, groups: this.groups, }; } formatterChat() { return { userId: this.userId, groups: this.groups.map((o) => { return { id: o.id, //group id memberId: o.memberId, //成员id }; }), messages: this.unReadMessages, }; } } export default CellsysChatUser;