Files
2026-05-23 22:10:14 +08:00

71 lines
1.7 KiB
JavaScript

/*******************************************************************************
*
* 一键领取模块
*
* 2023.09.27
******************************************************************************/
const BridgeController = require( "bridge.controller" );
const OnceRewardsMod = cc.Class( {
extends: BridgeController,
// 注册协议接受事件
registerProtocals: function() {
this.RegisterProtocal( 29800, this.onPushData.bind( this ) );
this.RegisterProtocal( 29801, this.onReward.bind( this ) );
},
// 从服务器初始化数据
reqBaseFromServer: function( _cb ) {
nx.bridge.vset( "OnceRewards", [] );
nx.dt.fnInvoke( _cb, true );
this.reqBaseData();
},
// ============================================================
// 基本数据
// ============================================================
// 请求基本数据
reqBaseData: function( _cb ) {
this.SendProtocal( 29800, {}, _cb );
},
// 基本数据
onPushData: function( _data ) {
if( !this.isGoodData( _data ) ) {
return;
}
let list = _data.reward_list || [];
nx.bridge.vset( "OnceRewards", list );
nx.mTip.openTip( "bar.once", nx.dt.arrNEmpty( list ) );
},
// ============================================================
// 领取相关
// ============================================================
// 请求领取
reqReward: function( _cb ) {
this.SendProtocal( 29801, {}, _cb );
},
// 领取返回
onReward: function( _data ) {
if( !this.isGoodData( _data ) ) {
return;
}
},
} );
// 模块导出
module.exports = OnceRewardsMod;