213 lines
6.4 KiB
JavaScript
213 lines
6.4 KiB
JavaScript
/******************************************************************
|
|
*
|
|
* 日常福利 钻石周卡
|
|
*
|
|
******************************************************************/
|
|
|
|
const ActPage = require( "act.page.base" );
|
|
const NxSpine = require( "nx.fx.spine" );
|
|
const Payment = require( "payment.mod" );
|
|
const Mod = require( "act.diamondcard.mod" );
|
|
const themeMod = require( "acts.mod" );
|
|
const FID = require( "bridge.function.ids" );
|
|
|
|
cc.Class( {
|
|
|
|
extends: ActPage,
|
|
|
|
properties: {
|
|
nodItems : { type: cc.Node, default: null },
|
|
spRole: { default: null, type: NxSpine },
|
|
nodEndTime : { default: null, type: cc.Node },
|
|
nodOp : { type: cc.Node, default: null },
|
|
nodSpecial : { type: cc.Node, default: null },
|
|
nodGetCount: { type: cc.Node, default: null },
|
|
nodFree: { type: cc.Node, default: null },
|
|
},
|
|
|
|
// 初始化
|
|
build: function( _data ) {
|
|
|
|
|
|
this._super( _data );
|
|
|
|
this.spRole.load( "resDB/models/H30040/show", ( _e ) => {
|
|
if( !_e ) {
|
|
this.spRole.action( "action1", true );
|
|
} else {
|
|
this.spRole.stop();
|
|
}
|
|
} );
|
|
|
|
this.tweens = [];
|
|
this.canbuy = true;
|
|
this.cfg = gdata( this.data.config, "data_week_card_data_new" )[this.data.camp_id];
|
|
let items = this.cfg.reward;
|
|
|
|
nx.gui.gocChildren( this.nodSpecial, "", items.length );
|
|
for (let c = 0; c < this.nodSpecial.children.length; c++) {
|
|
|
|
let nod = this.nodSpecial.children[c];
|
|
let info = items[c];
|
|
let item = nx.gui.getComponent( nod, "", "cmp.item.base" );
|
|
if( item ){
|
|
item.setData( info );
|
|
}
|
|
nx.gui.setActive( nod, "got", false );
|
|
|
|
}
|
|
|
|
let cmp = nx.gui.getComponent( this.nodFree, "item", "cmp.item.base" );
|
|
if( cmp ){
|
|
cmp.setData( this.cfg.daily_reward[0] );
|
|
}
|
|
// nx.gui.setActive( this.nodFree, "get", false );
|
|
|
|
|
|
let count = this.cfg.mail_day;
|
|
let datat = this.cfg.mail_reward;
|
|
nx.gui.gocChildren( this.nodItems, "", count );
|
|
|
|
let chd = this.nodItems.children;
|
|
for (let i = 0; i < chd.length; i++) {
|
|
let nod = chd[i];
|
|
let item = nx.gui.getComponent( nod, "item", "cmp.item.base" );
|
|
if( item ){
|
|
item.setData( datat[0] );
|
|
}
|
|
nx.gui.setActive( nod, "got", false );
|
|
nx.gui.setActive( nod, "focus", false );
|
|
nx.gui.setActive( nod, "gotbg", false );
|
|
nx.gui.setString( nod, "day", "0" + ( i + 1 ) )
|
|
}
|
|
let costfg = game.configs.charge_data.data_charge_data[this.cfg.id];
|
|
if( costfg ){
|
|
nx.gui.setString( this.nodOp, "txt", nx.text.format( "NeedPayUnlock", Payment.getInstance().fmtPrice( costfg.val ) ) );
|
|
}
|
|
nx.gui.setString( this.nodGetCount, "num/num", this.cfg.all_num[1] );
|
|
nx.bridge.setIconS( this.nodGetCount, "num/icon", this.cfg.all_num[0] );
|
|
nx.gui.setActive( this.nodEndTime, "", false );
|
|
|
|
// 活动监听
|
|
this.mod.vbind( this, [
|
|
[ "DiamondCard", this.freshAssemblyInfo.bind( this ) ],
|
|
] );
|
|
|
|
// this.mod.reqDiamondCardData();
|
|
},
|
|
|
|
onEnable: function(){
|
|
|
|
// 请求信息
|
|
this.mod.reqDiamondCardData();
|
|
|
|
},
|
|
|
|
freshAssemblyInfo: function( _data ){
|
|
|
|
this.mod = !this.mod ? Mod.getInstance() : this.mod;
|
|
// console.log( "當前的周卡相關" + JSON.stringify( _data ) );
|
|
let cfg = gdata( this.mod.getConfig(), "data_week_card_data_new" )[this.mod.data.camp_id];
|
|
if( !_data || nx.dt.objEmpty( _data ) || !cfg || !this.nodItems ){
|
|
return;
|
|
}
|
|
|
|
// [17:11:13:023][recv] <<<[16720]:{"list":[],"list1":[{"week_id":11016,"status":0}]}
|
|
let free = _data.list1;
|
|
this.freeid = free[0] ? free[0].week_id : 0;
|
|
nx.gui.setActive( this.nodFree, "get", free[0].status == 0 );
|
|
nx.gui.setActive( this.nodFree, "", free[0].status == 0 );
|
|
|
|
let list = _data.list;
|
|
if( nx.dt.arrEmpty( list ) ){
|
|
this.canbuy = true;
|
|
return;
|
|
}
|
|
|
|
this.canbuy = false;
|
|
let now = {};
|
|
for (let i = 0; i < list.length; i++) {
|
|
let info = list[i];
|
|
if( info.week_id == cfg.id ){
|
|
now = info;
|
|
}
|
|
}
|
|
this.now = now;
|
|
let nowDay = now.gain_num;
|
|
let chd = this.nodItems.children;
|
|
let status = now.status;
|
|
for (let i = 0; i < chd.length; i++) {
|
|
let nod = chd[i];
|
|
if( status == 2 ){
|
|
nx.gui.setActive( nod, "got", i < nowDay );
|
|
nx.gui.setActive( nod, "gotbg", i < nowDay );
|
|
if( nowDay > i ){
|
|
nx.gui.setActive( nod, "focus", false );
|
|
}
|
|
|
|
}else{
|
|
nx.gui.setActive( nod, "focus", nowDay == i );
|
|
}
|
|
|
|
}
|
|
// [{"week_id":11016,"status":1,"gain_num":0,"endtime":1707667200}]
|
|
for (let c = 0; c < this.nodSpecial.children.length; c++) {
|
|
|
|
let nod = this.nodSpecial.children[c];
|
|
|
|
nx.gui.setActive( nod, "got", true );
|
|
|
|
}
|
|
|
|
let nod = this.nodItems.children[nowDay];
|
|
|
|
let time = new Date();
|
|
let showtime = now.endtime - ( time / 1000 );
|
|
nx.gui.setCdTxt( this.nodEndTime, "txt", showtime );
|
|
|
|
|
|
nx.gui.setActive( this.nodEndTime, "", true );
|
|
let color = new cc.color( "#592E06" );
|
|
let colord = new cc.color( "#784611" );
|
|
nx.gui.setColor( nod, "desc", colord );
|
|
nx.gui.setColor( nod, "day", color );
|
|
|
|
let cmp = nx.gui.getComponent( this.nodOp, "", cc.Button );
|
|
if( cmp ){
|
|
nx.gui.setString( this.nodOp, "txt", nx.text.getKey( "Charged" ) );
|
|
cmp.interactable = false;
|
|
}
|
|
|
|
|
|
|
|
// free.forEach( _item =>{
|
|
// if( _item.status == 0 ){
|
|
// nx.gui.setActive( )
|
|
// }
|
|
// } )
|
|
|
|
},
|
|
|
|
// 领取奖励 与 购买礼包
|
|
onTouchGet: function(){
|
|
|
|
|
|
Payment.getInstance().reqPayment( this.cfg.id );
|
|
|
|
|
|
},
|
|
|
|
onTouchGetFree: function(){
|
|
|
|
this.mod.reqGetAward( this.now.week_id );
|
|
|
|
},
|
|
|
|
onTouchGetRealFree: function(){
|
|
|
|
this.mod.reqGetFreeAward( this.freeid );
|
|
|
|
},
|
|
|
|
} );
|