141 lines
3.4 KiB
JavaScript
141 lines
3.4 KiB
JavaScript
|
|
/******************************************************************
|
||
|
|
*
|
||
|
|
* 活动: StepUP签到
|
||
|
|
*
|
||
|
|
******************************************************************/
|
||
|
|
|
||
|
|
const ActBase = require( "act.base" );
|
||
|
|
const SummonDefine = require( "summon.define" );
|
||
|
|
|
||
|
|
// 桥接替换的界面
|
||
|
|
|
||
|
|
const STStage = SummonDefine.StepUpStage;
|
||
|
|
|
||
|
|
const ActStepupSign = cc.Class( {
|
||
|
|
|
||
|
|
extends: ActBase,
|
||
|
|
|
||
|
|
// 初始化配置数据
|
||
|
|
initConfig: function() {
|
||
|
|
|
||
|
|
// 视图附着
|
||
|
|
nx.plugin.add( this, ["view"] );
|
||
|
|
this.vattach( "Acts" );
|
||
|
|
},
|
||
|
|
|
||
|
|
// 注册协议接受事件
|
||
|
|
registerProtocals: function() {
|
||
|
|
this.RegisterProtocal( 23245, this.handle23245.bind( this ) );
|
||
|
|
this.RegisterProtocal( 23246, this.handle23246.bind( this ) );
|
||
|
|
},
|
||
|
|
|
||
|
|
// 从服务器初始化数据
|
||
|
|
reqBaseFromServer: function( _cb ) {
|
||
|
|
|
||
|
|
let cfgs = [
|
||
|
|
"holiday_checkin_data",
|
||
|
|
];
|
||
|
|
this.loadConfigs( cfgs, ( _ret, _data ) => {
|
||
|
|
nx.dt.fnInvoke( _cb, true );
|
||
|
|
this.reqSignData();
|
||
|
|
} );
|
||
|
|
},
|
||
|
|
|
||
|
|
// 当前配置
|
||
|
|
getConfig: function() {
|
||
|
|
|
||
|
|
// 已经存在
|
||
|
|
if( nx.dt.objNEmpty( this.configs ) ) {
|
||
|
|
return this.configs;
|
||
|
|
}
|
||
|
|
|
||
|
|
// 活动无效
|
||
|
|
if( nx.dt.objEmpty( this.data ) ||
|
||
|
|
!nx.dt.numPositive( this.data.camp_id, false ) ) {
|
||
|
|
this.configs = null;
|
||
|
|
nx.error( "STEP-UP签到当前配置无效!" );
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
|
||
|
|
// 配置无效
|
||
|
|
let DATA = game.configs.holiday_checkin_data;
|
||
|
|
let campId = this.data.camp_id;
|
||
|
|
if( nx.dt.objEmpty( DATA.data_sign_in[campId] ) ) {
|
||
|
|
this.configs = null;
|
||
|
|
nx.error( "STEP-UP签到当前配置无效:", campId );
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
|
||
|
|
this.configs = DATA.data_sign_in[campId];
|
||
|
|
return this.configs;
|
||
|
|
},
|
||
|
|
|
||
|
|
// 签到数据请求
|
||
|
|
reqSignData: function( _cb ) {
|
||
|
|
this.SendProtocal( 23245, {}, _cb );
|
||
|
|
},
|
||
|
|
|
||
|
|
// 签到数据更新
|
||
|
|
handle23245: function( _data ) {
|
||
|
|
|
||
|
|
if( !this.isGoodData( _data ) ) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
this.vset( "stepSign7", _data.gift_buy_info || [] );
|
||
|
|
this.freshTips();
|
||
|
|
},
|
||
|
|
|
||
|
|
// 签到领取请求
|
||
|
|
reqSignGet: function( _day, _cb ) {
|
||
|
|
this.SendProtocal( 23246, {
|
||
|
|
day: _day,
|
||
|
|
}, _cb );
|
||
|
|
},
|
||
|
|
|
||
|
|
// 签到领取更新
|
||
|
|
handle23246: function( _data ) {
|
||
|
|
|
||
|
|
if( !this.isGoodData( _data, false ) ) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
let list = this.vget( "stepSign7" ) || [];
|
||
|
|
for( let i in list ) {
|
||
|
|
if( list[i].day == _data.day ) {
|
||
|
|
list[i].status = _data.status;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
this.vset( "stepSign7", list );
|
||
|
|
|
||
|
|
this.freshTips();
|
||
|
|
},
|
||
|
|
|
||
|
|
// ============================================================
|
||
|
|
// 活动红点提示
|
||
|
|
// ============================================================
|
||
|
|
|
||
|
|
// 活动用到的提示KEY
|
||
|
|
tipKeys: function() {
|
||
|
|
return ["reward"];
|
||
|
|
},
|
||
|
|
|
||
|
|
// 红点提示更新
|
||
|
|
// 0不可领取 1可领取 2已领取
|
||
|
|
freshTips: function() {
|
||
|
|
|
||
|
|
let have = false;
|
||
|
|
let list = this.vget( "stepSign7" ) || [];
|
||
|
|
for( let i in list ) {
|
||
|
|
if( list[i].status == 1 ) {
|
||
|
|
have = true;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
this.openTip( "reward", have );
|
||
|
|
},
|
||
|
|
|
||
|
|
} );
|
||
|
|
|
||
|
|
module.exports = ActStepupSign;
|