// //////////////////////////////////////////////////////////////////// // @author: xxx@syg.com(必填, 创建模块的人员) // @description: // 任务,日常,成就 //
Create: 2019-01-09 11:26:10 // //////////////////////////////////////////////////////////////////// const BridgeController = require( "bridge.controller" ); // 桥接替换的界面 var TaskController = cc.Class( { extends: BridgeController, ctor: function() { }, // 初始化配置数据 initConfig: function() { var TaskModel = require( "task_model" ); this.model = new TaskModel( this ); this.model.initConfig(); let cfgs = [ "activity_advertisement_data", ]; this.loadConfigs( cfgs ); }, // 返回当前的model getModel: function() { return this.model; }, // 注册监听事件 registerEvents: function() { }, requestBaseQuestData: function( _cb ) { this.SendProtocal( 10400, {} ); //请求当前所有的成就列表 this.requestActivityInfo( _cb ); //请求活跃度 }, // 注册协议接受事件 registerProtocals: function() { this.RegisterProtocal( 10400, this.on10400 ) //全部成就列表 this.RegisterProtocal( 10406, this.on10406 ); //提交任务返回,客户端自己更新内存缓存数据 this.RegisterProtocal( 10409, this.on10409 ); //更新已接任务进度 this.RegisterProtocal( 20300, this.on20300 ) //已领取的活跃宝箱 this.RegisterProtocal( 20301, this.on20301 ) //请求领取活跃宝箱 //新主线 this.RegisterProtocal( 30001, this.on30001 ) //进度更新时返回 this.RegisterProtocal( 30002, this.on30002 ) //提交任务返回 }, reqBaseFromServer: function( _cb ) { let cfgs = [ "activity_data", ]; this.loadConfigs( cfgs, ( _ret, _data ) => { this.requestBaseQuestData( _cb ); } ) }, send10400 : function(){ this.SendProtocal( 10400, {} ); //请求当前所有的成就列表 }, on10400: function( data ) { this.model.addTaskList( data.quest_list, false, true ); }, on10406: function( data ) { // nx.tbox( data.msg ); if( data.flag == 1 ) this.model.setTaskCompleted( data.id ); }, on10409: function( data ) { this.model.addTaskList( data.quest_list, true ); }, // @desc:打开日常任务主界面 // author:{author} // time:2018-05-22 11:32:35 // //@status:打开或者关闭 // //@index:自动跳转到 // return openTaskMainWindow: function( status, index ) { if( status == false ) { if( this.task_main_window != null ) { this.task_main_window.close(); this.task_main_window = null; } } else { if( this.task_main_window == null ) { var TaskMainWindow = require( "task_main_window" ); this.task_main_window = new TaskMainWindow(); } this.task_main_window.open( index ); } }, // @desc:点击任务前往 // author:{author} // time:2018-05-22 21:00:26 // //@data: // //@index: // //@open_type: // return handleTaskProgress: function( data, index, open_type ) { index = index || 1; if( data.config.progress == null || Utils.next( data.config.progress ) == null ) { if( data.id != null ) cc.log( "=================> 处理任务进度时出错,任务id为 " + data.id + " 的没有配置任务进度" ); return } var progressConfig = data.config.progress[ index ]; if( progressConfig == null ) { if( data.id != null ) cc.log( "=================> 处理任务id为 " + data.id + " 的第 " + index + " 个进度要求时出错" ); return } //拓展参数用于跳转 var extra = data.config.extra; this.gotoTagertFun( progressConfig, extra, open_type ); }, //desc:任务和成就的跳转 //time:2018-07-07 03:57:59 //@progressConfig: //@extra: //@open_type: //@return gotoTagertFun: function( progressConfig, extra, open_type ) { }, //------------------------活跃度相关 start requestActivityInfo: function( _cb ) { this.SendProtocal( 20300, {}, _cb ); nx.mTip.openTip( "daily.show", true ); // nx.mTip.openTip( "openServerActs.show", true ); }, on20300: function( data ) { this.model.updateActivityData( data.activity_box ); }, requestGetActivityAwards: function( activity ) { var proto = {} proto.activity = activity this.SendProtocal( 20301, proto ); }, on20301: function( data ) { nx.tbox( data.msg ); if( data.code == 1 ) this.model.updateSingleActivityData( data.activity ); }, //------------------------活跃度相关 end //-----------------------新主线 // 打开主/支线界面 openMainTaskWindow: function( _open, _params ) { if( _open == false ) { nx.bridge.closePanel( "WndTaskMain" ); } else { nx.bridge.createPanel( "WndTaskMain" ); } }, send30001: function() { // this.SendProtocal(30001, {}); nx.warn( "消息暂时屏蔽: ", 30001 ); }, on30001: function( data ) { cc.log( "30001", data ); this.model.setMainTaskData( data ); }, send30002: function( task_id ) { let proto = {}; proto.id = task_id; // this.SendProtocal(30002, proto); nx.warn( "消息暂时屏蔽: ", 30002 ); }, on30002: function( data ) { cc.log( "3002", data ); nx.tbox( data.msg ); if( data.code == 1 ) { } }, } ); module.exports = TaskController;