153 lines
3.5 KiB
JavaScript
153 lines
3.5 KiB
JavaScript
|
|
/*******************************************************************************
|
||
|
|
*
|
||
|
|
* 伙伴秘书组管理
|
||
|
|
*
|
||
|
|
*
|
||
|
|
*
|
||
|
|
* 2023.04.10
|
||
|
|
******************************************************************************/
|
||
|
|
|
||
|
|
const BridgeController = require( "bridge.controller" );
|
||
|
|
const RoleController = require( "role_controller" );
|
||
|
|
|
||
|
|
const PartnerClerkMod = cc.Class( {
|
||
|
|
|
||
|
|
extends: BridgeController,
|
||
|
|
|
||
|
|
// 初始化配置数据
|
||
|
|
initConfig: function() {
|
||
|
|
|
||
|
|
// 视图清理
|
||
|
|
this.reset();
|
||
|
|
|
||
|
|
// 全局支持
|
||
|
|
nx.bridge.clerks = this;
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
// 注册监听事件
|
||
|
|
registerEvents: function() {
|
||
|
|
},
|
||
|
|
|
||
|
|
// 注册协议接受事件
|
||
|
|
registerProtocals: function() {
|
||
|
|
|
||
|
|
// 获取秘书组信息
|
||
|
|
this.RegisterProtocal( 10361, this.onFetchData.bind( this ) );
|
||
|
|
|
||
|
|
// 修改秘书组信息
|
||
|
|
this.RegisterProtocal( 10362, this.onModifyData.bind( this ) );
|
||
|
|
|
||
|
|
// 修改当前展示的秘书
|
||
|
|
this.RegisterProtocal( 10363, this.onShowChanged.bind( this ) );
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
// 从服务器初始化数据
|
||
|
|
reqBaseFromServer: function( _cb ) {
|
||
|
|
|
||
|
|
// 配置加载
|
||
|
|
let cfgs = [
|
||
|
|
"secretary_data", // 秘书组
|
||
|
|
];
|
||
|
|
this.loadConfigs( cfgs, ( _ret, _data ) => {
|
||
|
|
this.reqFetch( _cb );
|
||
|
|
} );
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
// 重置
|
||
|
|
reset: function( _list, _cur ) {
|
||
|
|
|
||
|
|
nx.bridge.vset( "clerkList", _list || [] );
|
||
|
|
nx.bridge.vset( "clerkShowId", _cur || "" );
|
||
|
|
},
|
||
|
|
|
||
|
|
// 获取秘书组信息
|
||
|
|
reqFetch: function( _cb ) {
|
||
|
|
this.SendProtocal( 10361, {}, _cb );
|
||
|
|
},
|
||
|
|
|
||
|
|
// REC: 获取秘书组信息
|
||
|
|
onFetchData: function( _data ) {
|
||
|
|
this.reset( _data.secretary_group, _data.current_resource_id );
|
||
|
|
},
|
||
|
|
|
||
|
|
// 修改秘书组信息
|
||
|
|
reqModify: function( _data, _cb ) {
|
||
|
|
|
||
|
|
this.cbModify = _cb;
|
||
|
|
this.SendProtocal( 10362, {
|
||
|
|
secretary_group: _data
|
||
|
|
} );
|
||
|
|
},
|
||
|
|
|
||
|
|
// REC: 修改秘书组信息
|
||
|
|
onModifyData: function( _data ) {
|
||
|
|
|
||
|
|
console.log( _data );
|
||
|
|
|
||
|
|
// 失败
|
||
|
|
if( _data.code != 1 ) {
|
||
|
|
nx.tbox( _data.msg );
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
this.reset( _data.secretary_group, _data.current_resource_id );
|
||
|
|
nx.dt.fnInvoke( this.cbModify, _data );
|
||
|
|
this.cbModify = null;
|
||
|
|
},
|
||
|
|
|
||
|
|
// 修改当前展示的秘书
|
||
|
|
reqActiveShow: function( _cb ) {
|
||
|
|
|
||
|
|
// 判空
|
||
|
|
let lst = nx.bridge.vget( "clerkList" );
|
||
|
|
if( nx.dt.arrEmpty( lst ) ) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
// 唯一
|
||
|
|
let cur = nx.bridge.vget( "clerkShowId" );
|
||
|
|
if( lst.length == 1 && lst[0].resource_id == cur ) {
|
||
|
|
nx.tbox( "NeedSet" );
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
// 下一个
|
||
|
|
let idx = 0;
|
||
|
|
for( let i = 0; i < lst.length; ++i ) {
|
||
|
|
if( lst[i].resource_id == cur ) {
|
||
|
|
idx = i + 1;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
idx = ( idx + lst.length ) % lst.length;
|
||
|
|
|
||
|
|
this.cbActive = _cb;
|
||
|
|
this.SendProtocal( 10363, {
|
||
|
|
resource_id: lst[idx].resource_id
|
||
|
|
} );
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
// REC: 修改当前展示的秘书
|
||
|
|
onShowChanged: function( _data ) {
|
||
|
|
|
||
|
|
console.log( _data );
|
||
|
|
|
||
|
|
// 失败
|
||
|
|
if( _data.code != 1 ) {
|
||
|
|
nx.tbox( _data.msg );
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
nx.bridge.vset( "clerkShowId", _data.current_resource_id );
|
||
|
|
nx.dt.fnInvoke( this.cbActive, _data );
|
||
|
|
this.cbActive = null;
|
||
|
|
},
|
||
|
|
|
||
|
|
} );
|
||
|
|
|
||
|
|
module.exports = PartnerClerkMod;
|