105 lines
2.8 KiB
JavaScript
105 lines
2.8 KiB
JavaScript
|
|
/******************************************************************
|
||
|
|
*
|
||
|
|
* 八日约定
|
||
|
|
*
|
||
|
|
******************************************************************/
|
||
|
|
const ActPopup = require( "act.popup.base" );
|
||
|
|
const Mod = require( "act.appoint8.mod" );
|
||
|
|
const FID = require( "bridge.function.ids" );
|
||
|
|
const themeMod = require( "acts.mod" );
|
||
|
|
|
||
|
|
cc.Class( {
|
||
|
|
|
||
|
|
extends: ActPopup,
|
||
|
|
|
||
|
|
properties: {
|
||
|
|
nodReward : { type: cc.Node, default: null },
|
||
|
|
},
|
||
|
|
|
||
|
|
// 初始化
|
||
|
|
onOpenConfigs: function( _params ) {
|
||
|
|
|
||
|
|
this._super( _params );
|
||
|
|
|
||
|
|
this.mod = Mod.getInstance();
|
||
|
|
if( !this.mod ){
|
||
|
|
this.delayClose();
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
// console.log( JSON.stringify( this.data ) + "当前的活动" + JSON.stringify( this.mod ) );
|
||
|
|
// 视图监听
|
||
|
|
this.mod.vbind( this, [
|
||
|
|
[ "appoint8", this.freshDayReward.bind( this ) ],
|
||
|
|
] );
|
||
|
|
|
||
|
|
// 请求信息
|
||
|
|
this.mod.reqBaseData();
|
||
|
|
},
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// 销毁
|
||
|
|
onDestroy: function() {
|
||
|
|
|
||
|
|
// 活动监听解除
|
||
|
|
if( this.mod ) {
|
||
|
|
this.mod.vunbind( this );
|
||
|
|
}
|
||
|
|
delete this.mod;
|
||
|
|
this._super();
|
||
|
|
},
|
||
|
|
|
||
|
|
close: function() {
|
||
|
|
this._super();
|
||
|
|
|
||
|
|
//判断下是不是要回到openserver
|
||
|
|
let needShow = cc.sys.localStorage.getItem("needBackOpenServerAct");
|
||
|
|
if(needShow == 1)
|
||
|
|
{
|
||
|
|
//cc.sys.localStorage.removeItem("needBackOpenServerAct")
|
||
|
|
nx.bridge.createPanel("WndOpenServer");
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
|
||
|
|
freshDayReward: function( _data ){
|
||
|
|
|
||
|
|
let self = this;
|
||
|
|
let chd = this.nodReward.children;
|
||
|
|
let cfgs = gdata( this.mod.data.config, "data_day" );
|
||
|
|
if( cfgs ){
|
||
|
|
this.state = _data ? _data : this.mod.vget( "appoint8" );
|
||
|
|
// console.log( "当前的领取状态" + JSON.stringify( this.state ) );
|
||
|
|
for (let i in cfgs ) {
|
||
|
|
let cfg = cfgs[i];
|
||
|
|
let nod = chd[i-1];
|
||
|
|
let state_cp = nx.dt.objClone( this.state );
|
||
|
|
state_cp.day = i;
|
||
|
|
state_cp.status = 1;
|
||
|
|
let cmp = nx.gui.getComponent( nod, "", "cmp.act.appoint8.item" );
|
||
|
|
if( cmp ){
|
||
|
|
cmp.setData( {
|
||
|
|
index: i,
|
||
|
|
award: cfg.rewards[0],
|
||
|
|
state: this.state[i-1] ? this.state[i-1] : state_cp,
|
||
|
|
cb: ( ()=>{
|
||
|
|
self.mod.reqGetDayAward( i );
|
||
|
|
} )
|
||
|
|
} );
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
onTouchClose: function(){
|
||
|
|
|
||
|
|
this.close();
|
||
|
|
// let theme = themeMod.getInstance().queryTheme( this.mod.data.theme_id );
|
||
|
|
|
||
|
|
// nx.bridge.jumper.jump2Window( FID.ActOpenServer, theme );
|
||
|
|
},
|
||
|
|
|
||
|
|
} );
|