244 lines
7.5 KiB
JavaScript
244 lines
7.5 KiB
JavaScript
/******************************************************************
|
|
*
|
|
* 联盟成员项
|
|
*
|
|
******************************************************************/
|
|
|
|
const SVCItem = require( "nx.fx.sv.expand.item" );
|
|
const GuildConst = require( "guild_const" );
|
|
const GuildController = require( "guild_controller" );
|
|
const RoleController = require( "role_controller" );
|
|
|
|
// 工会职位
|
|
const GPT = GuildConst.PositionType;
|
|
|
|
// 职位颜色
|
|
const JobColors = [
|
|
cc.Color.BLACK,
|
|
cc.Color.ORANGE,
|
|
cc.Color.GREEN,
|
|
cc.Color.BLACK,
|
|
];
|
|
|
|
cc.Class( {
|
|
|
|
extends: SVCItem,
|
|
|
|
properties: {
|
|
nodBase: { default: null, type: cc.Node },
|
|
nodInfos: { default: null, type: cc.Node },
|
|
nodExpand: { default: null, type: cc.Node },
|
|
isExpand: { default: false, displayName: "扩展模式" },
|
|
},
|
|
|
|
// 数据重置
|
|
rebind: function( _idx, _data, _key ) {
|
|
|
|
this._super( _idx, _data, _key );
|
|
if( nx.dt.objEmpty( _data ) ) {
|
|
return;
|
|
}
|
|
|
|
this.freshBase();
|
|
|
|
// 隐藏扩展项
|
|
nx.gui.setActive( this.nodExpand, "", false );
|
|
|
|
},
|
|
|
|
// 更新
|
|
freshBase: function() {
|
|
|
|
// 头像
|
|
nx.bridge.setAvatarByFaceId( this.nodBase, "avatar/img", this.mdata.face );
|
|
nx.bridge.setAvatarFrame( this.nodBase, "avatar/frame", this.mdata.avatar_bid );
|
|
nx.gui.setString( this.nodBase, "avatar/level/txt", nx.text.format( "LvNumber", this.mdata.lev ) );
|
|
|
|
// 基本信息
|
|
nx.gui.setString( this.nodBase, "name", this.mdata.name );
|
|
nx.gui.setString( this.nodInfos, "bp/txt", this.mdata.power );
|
|
nx.gui.setString( this.nodBase, "vip/txt", this.mdata.vip_lev );
|
|
|
|
// 入会时间
|
|
let txt = nx.bridge.time.toLocalString( this.mdata.join_time, true, false );
|
|
nx.gui.setString( this.nodInfos, "date", txt );
|
|
|
|
// 最后在线时间
|
|
if( this.mdata.online ) {
|
|
nx.gui.setString( this.nodInfos, "time", nx.text.getKey( "Online" ) );
|
|
nx.gui.setColor( this.nodInfos, "time", cc.Color.BLACK );
|
|
} else {
|
|
txt = nx.bridge.time.toDescAgo( this.mdata.login_time );
|
|
nx.gui.setString( this.nodInfos, "time", txt );
|
|
nx.gui.setColor( this.nodInfos, "time", cc.Color.RED );
|
|
}
|
|
|
|
// 职位
|
|
txt = nx.text.getKey( "GuildJob" + this.mdata.post );
|
|
nx.gui.setString( this.nodInfos, "job", nx.text.format( "GuildJobC", txt ) );
|
|
nx.gui.setColor( this.nodInfos, "job", JobColors[ this.mdata.post ] );
|
|
|
|
// 贡献
|
|
nx.gui.setString( this.nodInfos, "gx1", this.mdata.donate );
|
|
nx.gui.setString( this.nodInfos, "gx2", nx.text.format( "GuildContributionToday", this.mdata.day_donate ) );
|
|
|
|
// 活跃度
|
|
nx.gui.setString( this.nodInfos, "active", this.mdata.active_lev );
|
|
|
|
// 操作栏
|
|
nx.gui.setActive( this.nodBase, "fold", this.isExpand && !this.mdata.is_self && this.getOps().length > 0 );
|
|
if( this.isExpand ) {
|
|
nx.gui.setActive( this.nodBase, "fold/fold", false );
|
|
nx.gui.setActive( this.nodBase, "fold/unfold", true );
|
|
}
|
|
|
|
},
|
|
|
|
// 收展切换
|
|
onTogFold: function() {
|
|
|
|
if( !this.nodExpand || this.mdata.is_self ) {
|
|
return;
|
|
}
|
|
|
|
let self = this;
|
|
let togExpand = function( _show ) {
|
|
self.nodExpand.active = _show;
|
|
self.nodInfos.active = !_show;
|
|
nx.gui.setActive( self.nodBase, "fold/fold", _show );
|
|
nx.gui.setActive( self.nodBase, "fold/unfold", !_show );
|
|
};
|
|
|
|
// 隐藏
|
|
if( this.nodExpand.active || this.getOps().length == 0 ) {
|
|
togExpand( false );
|
|
return;
|
|
}
|
|
|
|
// 展示
|
|
togExpand( true );
|
|
|
|
// 按照职位区分操作
|
|
// 盟主
|
|
let role = RoleController.getInstance().getRoleVo();
|
|
if( role.position == GPT.Leader ) {
|
|
nx.gui.setActive( this.nodExpand, "leader", true );
|
|
nx.gui.setActive( this.nodExpand, "kick", true );
|
|
if( this.mdata.post == GPT.Assistant ) {
|
|
nx.gui.setActive( this.nodExpand, "assistant", false );
|
|
nx.gui.setActive( this.nodExpand, "unassistant", true );
|
|
} else {
|
|
nx.gui.setActive( this.nodExpand, "assistant", true );
|
|
nx.gui.setActive( this.nodExpand, "unassistant", false );
|
|
}
|
|
return;
|
|
}
|
|
|
|
// 副盟主
|
|
if( true ) {
|
|
nx.gui.setActive( this.nodExpand, "leader", false );
|
|
nx.gui.setActive( this.nodExpand, "assistant", false );
|
|
nx.gui.setActive( this.nodExpand, "unassistant", false );
|
|
if( this.mdata.post == GPT.Leader ) {
|
|
nx.gui.setActive( this.nodExpand, "kick", false );
|
|
} else {
|
|
nx.gui.setActive( this.nodExpand, "kick", true );
|
|
}
|
|
}
|
|
},
|
|
|
|
// 获取有效操作
|
|
getOps: function() {
|
|
|
|
let ops = [];
|
|
let role = RoleController.getInstance().getRoleVo();
|
|
if( role.position == GPT.Leader ) {
|
|
ops.push( "leader" );
|
|
ops.push( "kick" );
|
|
if( this.mdata.post == GPT.Assistant ) {
|
|
ops.push( "unassistant" );
|
|
} else {
|
|
ops.push( "assistant" );
|
|
}
|
|
} else {
|
|
nx.gui.setActive( this.nodExpand, "leader", false );
|
|
nx.gui.setActive( this.nodExpand, "assistant", false );
|
|
nx.gui.setActive( this.nodExpand, "unassistant", false );
|
|
if( this.mdata.post != GPT.Leader && this.mdata.post != GPT.Assistant ) {
|
|
ops.push( "kick" );
|
|
}
|
|
}
|
|
|
|
return ops;
|
|
},
|
|
|
|
// 转让盟主
|
|
onTouchTransLeader: function() {
|
|
|
|
let self = this;
|
|
let GC = GuildController.getInstance();
|
|
let done = function() {
|
|
GC.requestOperationPost( self.mdata.rid, self.mdata.srv_id, GPT.Leader, ( _ret, _data ) => {
|
|
if( !_ret ) {
|
|
nx.tbox( _data );
|
|
return;
|
|
}
|
|
} );
|
|
};
|
|
|
|
let msg = nx.text.format( "GuildTransLeaderAsk", this.mdata.name );
|
|
nx.mbox( msg, [ 'cancel', 'confirm' ], ( _key, _box ) => {
|
|
_box.close();
|
|
if( _key == 'confirm' ) {
|
|
done();
|
|
}
|
|
} );
|
|
},
|
|
|
|
// 设副盟主
|
|
onTouchSetAssistant: function() {
|
|
|
|
let GC = GuildController.getInstance();
|
|
GC.requestOperationPost( this.mdata.rid, this.mdata.srv_id, GPT.Assistant, ( _ret, _data ) => {
|
|
|
|
if( !_ret ) {
|
|
nx.tbox( _data );
|
|
return;
|
|
}
|
|
} );
|
|
|
|
},
|
|
|
|
// 解除副盟主
|
|
onTouchFreeAssistant: function() {
|
|
|
|
let GC = GuildController.getInstance();
|
|
GC.requestOperationPost( this.mdata.rid, this.mdata.srv_id, GPT.Member, ( _ret, _data ) => {
|
|
|
|
if( !_ret ) {
|
|
nx.tbox( _data );
|
|
return;
|
|
}
|
|
} );
|
|
},
|
|
|
|
// 踢出联盟
|
|
onTouchKick: function() {
|
|
|
|
let GC = GuildController.getInstance();
|
|
let msg = nx.text.format( "GuildKickMemberAsk", this.mdata.name );
|
|
nx.mbox( msg, [ 'cancel', 'confirm' ], ( _key, _box ) => {
|
|
_box.close();
|
|
if( _key == 'confirm' ) {
|
|
GC.requestKickoutMember( this.mdata.rid, this.mdata.srv_id, ( _ret, _data ) => {
|
|
if( !_ret ) {
|
|
nx.tbox( _data );
|
|
return;
|
|
}
|
|
} );
|
|
}
|
|
} );
|
|
},
|
|
|
|
} );
|