258 lines
6.2 KiB
JavaScript
258 lines
6.2 KiB
JavaScript
|
|
/******************************************************************
|
||
|
|
*
|
||
|
|
* 个人信息
|
||
|
|
*
|
||
|
|
******************************************************************/
|
||
|
|
|
||
|
|
const BridgeWindow = require( "bridge.window" );
|
||
|
|
const RoleController = require( "role_controller" );
|
||
|
|
const TipController = require( "tips_controller" );
|
||
|
|
const HeroController = require( "hero_controller" );
|
||
|
|
|
||
|
|
cc.Class( {
|
||
|
|
|
||
|
|
extends: BridgeWindow,
|
||
|
|
|
||
|
|
properties: {
|
||
|
|
|
||
|
|
nodAvatar: { default: null, type: cc.Node },
|
||
|
|
nodUID: { default: null, type: cc.Node },
|
||
|
|
nodServer: { default: null, type: cc.Node },
|
||
|
|
nodLevel: { default: null, type: cc.Node },
|
||
|
|
nodUnion: { default: null, type: cc.Node },
|
||
|
|
nodDan: { default: null, type: cc.Node },
|
||
|
|
nodName: { default: null, type: cc.Node },
|
||
|
|
lstPartners: { default: null, type: cc.Node },
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
onLoad: function() {
|
||
|
|
|
||
|
|
// 主角信息
|
||
|
|
let RC = RoleController.getInstance();
|
||
|
|
this.role = RC ? RC.getRoleVo() : null;
|
||
|
|
if( !this.role ) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
// 基本信息
|
||
|
|
|
||
|
|
// UID
|
||
|
|
nx.gui.setString( this.nodUID, "txt", this.role.rid );
|
||
|
|
|
||
|
|
// 服务器
|
||
|
|
nx.gui.setString( this.nodServer, "txt", nx.text.getKey( this.role.srv_id ) );
|
||
|
|
|
||
|
|
// 名字
|
||
|
|
this.updateName();
|
||
|
|
|
||
|
|
// 头像更新
|
||
|
|
this.updateAvatar();
|
||
|
|
|
||
|
|
// 头像框更新
|
||
|
|
this.updateFrame();
|
||
|
|
|
||
|
|
// 等级
|
||
|
|
nx.gui.setString( this.nodLevel, "txt", this.role.lev );
|
||
|
|
|
||
|
|
// 工会
|
||
|
|
let txt = this.role.gname;
|
||
|
|
if( nx.dt.strEmpty( txt ) ) {
|
||
|
|
txt = "PLNoGuild";
|
||
|
|
}
|
||
|
|
nx.gui.setString( this.nodUnion, "txt", txt );
|
||
|
|
|
||
|
|
// 当前阵容
|
||
|
|
this.freshCurrentTeam();
|
||
|
|
|
||
|
|
// 段位
|
||
|
|
|
||
|
|
// 监听绑定
|
||
|
|
this.roleHandler = this.role.bind( EventId.UPDATE_ROLE_ATTRIBUTE, this.onRoleAttrUpdate, this );
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
onOpenConfigs( _params ) {
|
||
|
|
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
|
||
|
|
// 销毁
|
||
|
|
onDestroy: function() {
|
||
|
|
|
||
|
|
// 监听绑定解除
|
||
|
|
if( this.roleHandler ) {
|
||
|
|
this.role.unbind( this.roleHandler );
|
||
|
|
this.roleHandler = null;
|
||
|
|
}
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
// 角色属性改变
|
||
|
|
onRoleAttrUpdate: function( _key, _val ) {
|
||
|
|
|
||
|
|
// 名字
|
||
|
|
if( _key == "name" ) {
|
||
|
|
this.updateName();
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
// 头像更新
|
||
|
|
if( _key == "face_id" ) {
|
||
|
|
this.updateAvatar();
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
// 头像框更新
|
||
|
|
if( _key == "avatar_base_id" ) {
|
||
|
|
this.updateFrame();
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
// 名字更新
|
||
|
|
updateName: function() {
|
||
|
|
|
||
|
|
let name = this.role ? this.role.name : "";
|
||
|
|
nx.gui.setString( this.nodName, "txt", name );
|
||
|
|
},
|
||
|
|
|
||
|
|
// 头像更新
|
||
|
|
updateAvatar: function() {
|
||
|
|
nx.bridge.setAvatarByFaceId( this.nodAvatar, "mask/img", this.role.face_id );
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
// 头像框更新
|
||
|
|
updateFrame: function() {
|
||
|
|
let path = cc.path.join( 'resDB/aframes', this.role.avatar_base_id );
|
||
|
|
nx.gui.setSpriteFrame( this.nodAvatar, "frame", path );
|
||
|
|
},
|
||
|
|
|
||
|
|
// 当前阵容
|
||
|
|
freshCurrentTeam: function() {
|
||
|
|
|
||
|
|
this.teammates = [];
|
||
|
|
|
||
|
|
let model = HeroController.getInstance().getModel();
|
||
|
|
let list = model.getMyPosList() || [];
|
||
|
|
let chds = this.lstPartners.children;
|
||
|
|
for( let i = 0; i < 5; ++i ) {
|
||
|
|
let cmp = nx.gui.getComponent( chds[ i ], "", "cmp.partner.inbag" );
|
||
|
|
let ifo = list[ i + 1 ];
|
||
|
|
let partner = ifo ? model.getHeroById( ifo.id ) : null;
|
||
|
|
if( partner ) {
|
||
|
|
cmp.setData( partner );
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
cmp.setEmpty();
|
||
|
|
}
|
||
|
|
cmp.node.index = i;
|
||
|
|
this.teammates.push( partner );
|
||
|
|
}
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
// 点击成员
|
||
|
|
onTouchTeammate: function( _touch ) {
|
||
|
|
|
||
|
|
let index = _touch.currentTarget.parent.index;
|
||
|
|
let focus = this.teammates[ index ];
|
||
|
|
if( focus ) {
|
||
|
|
let HC = HeroController.getInstance();
|
||
|
|
HC.openHeroMainInfoWindow( true, focus, this.teammates );
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
// 打开编队
|
||
|
|
const HC = HeroController.getInstance();
|
||
|
|
if( HC ) {
|
||
|
|
HC.openFormMainWindow( true );
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
this.close();
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
// 改名
|
||
|
|
onTouchRename: function() {
|
||
|
|
|
||
|
|
let TC = TipController.getInstance();
|
||
|
|
let RC = RoleController.getInstance();
|
||
|
|
|
||
|
|
let self = this;
|
||
|
|
let modify = function( _name, _box ) {
|
||
|
|
let sex = Math.min( 1, self.role.sex );
|
||
|
|
RC.changeRoleName( _name, sex, ( _ret, _data ) => {
|
||
|
|
if( !_ret ) {
|
||
|
|
nx.tbox( _data );
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
_box.close();
|
||
|
|
} );
|
||
|
|
};
|
||
|
|
|
||
|
|
let role = RC.getRoleVo();
|
||
|
|
let tip = role.is_first_rename ? "PLRenameFirstTip" : "PLRenameTip";
|
||
|
|
TC.showInputString( {
|
||
|
|
tip: tip, limit: [ 4, 12 ], cb: ( _box, _str ) => {
|
||
|
|
modify( _str, _box );
|
||
|
|
}
|
||
|
|
} );
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
// 换头像
|
||
|
|
onTouchSwapAvatar: function() {
|
||
|
|
nx.bridge.createPanel( "WndPersonalAvatarChange" );
|
||
|
|
},
|
||
|
|
|
||
|
|
// 兑换码
|
||
|
|
onTouchExchange: function() {
|
||
|
|
|
||
|
|
let self = this;
|
||
|
|
let RC = RoleController.getInstance();
|
||
|
|
let exchange = function( _code ) {
|
||
|
|
RC.sender10945( _code );
|
||
|
|
};
|
||
|
|
|
||
|
|
nx.bridge.createPanel( "WndPersonalExchange", {
|
||
|
|
cb: ( _box, _code ) => {
|
||
|
|
_box.close();
|
||
|
|
exchange( _code );
|
||
|
|
}
|
||
|
|
} );
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
// 点击冒险形象
|
||
|
|
onTouchFigure: function() {
|
||
|
|
|
||
|
|
let RC = RoleController.getInstance();
|
||
|
|
RC.fetchFigureData( ( _ret, _data ) => {
|
||
|
|
|
||
|
|
if( !_ret ) {
|
||
|
|
nx.tbox( _data );
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
nx.bridge.createPanel( "WndPersonalFigure", _data );
|
||
|
|
} );
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
// 点击个性装饰
|
||
|
|
onTouchDecorate: function() {
|
||
|
|
nx.bridge.createPanel( "WndPersonalAvatarChange" );
|
||
|
|
},
|
||
|
|
|
||
|
|
// 点击秘书组
|
||
|
|
onTouchClerk: function() {
|
||
|
|
nx.bridge.createPanel( "WndPersonalClerk" );
|
||
|
|
nx.bridge.closePanel( "WndPersonal" );
|
||
|
|
},
|
||
|
|
|
||
|
|
} );
|