121 lines
3.0 KiB
JavaScript
121 lines
3.0 KiB
JavaScript
const BridgeComp = require("bridge.component");
|
|
var ChatEvent = require("chat_event");
|
|
var RoleController = require("role_controller");
|
|
var ChatItemController = require("chat_item_controller");
|
|
var ChatConst = require("chat_const");
|
|
var ChatCtrl = require("chat_controller")
|
|
|
|
const CHANNEL_TXT = {
|
|
[1]:"MsgWorld",
|
|
[4]:"MsgGud",
|
|
[7]:"MsgPri",
|
|
[16]:"MsgSys",
|
|
[1024]:"MsgWorld"
|
|
}
|
|
const CHANNEL_COL = {
|
|
[1]:new cc.Color().fromHEX("#00d8ff"),
|
|
[4]:new cc.Color().fromHEX("#46db9a"),
|
|
[7]:new cc.Color().fromHEX("#7c46db"),
|
|
[16]:new cc.Color().fromHEX("#ffc700"),
|
|
[1024]:new cc.Color().fromHEX("#00d8ff"),
|
|
}
|
|
|
|
cc.Class({
|
|
extends: BridgeComp,
|
|
|
|
properties: {
|
|
container:{
|
|
default:null,
|
|
type:cc.Node
|
|
},
|
|
type_lb:{
|
|
default:null,
|
|
type:cc.Label
|
|
},
|
|
pname:{
|
|
default:null,
|
|
type:cc.Label
|
|
},
|
|
msg_rx:{
|
|
default:null,
|
|
type:cc.RichText
|
|
}
|
|
},
|
|
|
|
// LIFE-CYCLE CALLBACKS:
|
|
|
|
|
|
onLoad () {
|
|
this._super();
|
|
|
|
this.chat_item_ctrl = ChatItemController.getInstance();
|
|
this.ctrl = ChatCtrl.getInstance();
|
|
this.role_vo = RoleController.getInstance().getRoleVo();
|
|
this.rx_math = 260;//超过最大长度旧省略
|
|
|
|
this.bindGEvent(ChatEvent.MessageUpdateOnWnd,this.onEditText.bind(this));
|
|
},
|
|
|
|
start () {
|
|
// this.ctrl.sender12766();
|
|
this.ctrl.sender12731();
|
|
},
|
|
|
|
onEnable(){
|
|
|
|
},
|
|
|
|
onDisable(){
|
|
// 监听事件释放
|
|
this.unbindGEvents();
|
|
},
|
|
|
|
onEditText(msgData){
|
|
if(nx.dt.objEmpty(msgData)){
|
|
return;
|
|
}
|
|
let self = this;
|
|
|
|
self.data = msgData;
|
|
if(self.data){
|
|
if(msgData.channel == ChatConst.Channel.System){
|
|
self.pname.string = "";
|
|
self.pname.node.active = false;
|
|
}else if(msgData.channel == ChatConst.Channel.Friend){
|
|
self.pname.node.active = true;
|
|
if(msgData.msg_data.flag == 1){
|
|
self.pname.string = self.role_vo.name + ":";
|
|
}else if(msgData.msg_data.flag == 2){
|
|
self.pname.string = msgData.msg_data.name + ":";
|
|
}
|
|
}else{
|
|
self.pname.node.active = true;
|
|
self.pname.string = msgData.role_list[0].name + ":";
|
|
}
|
|
|
|
self.type_lb.string = nx.text.getKey(CHANNEL_TXT[msgData.channel]);
|
|
self.type_lb.node.color = CHANNEL_COL[msgData.channel]
|
|
|
|
// 设置Imag
|
|
let msg = msgData.msg || msgData.msg_data.msg;
|
|
|
|
self.msg_rx.string = msg;
|
|
self.container.getComponent(cc.Layout).updateLayout();
|
|
|
|
// if(this.container.width >320){
|
|
|
|
// }
|
|
}else{
|
|
this.type_lb.string = "";
|
|
this.pname.string = "";
|
|
this.msg_rx.string = "";
|
|
}
|
|
},
|
|
|
|
touchChat(){
|
|
this.ctrl.openChatPanel();
|
|
}
|
|
|
|
// update (dt) {},
|
|
});
|