const BaseItem = require("nx.fx.sv.expand.item"); const ItemLay = require("cmp.common.itemlayout"); const RoleCtr = require("role_controller"); const TIP_RED = { [1]:"reward1", [2]:"reward2", } cc.Class({ extends: BaseItem, properties: { lay:{ default:null, type:ItemLay } }, // LIFE-CYCLE CALLBACKS: rebind(_index,_data,_mod){ this.mod = _mod; this.setData(_data); }, setData(data){ if(nx.dt.objEmpty(data)){ this.lay.rebuild([]); return; } this.data = data; let idx = nx.gui.find(this.node,String(data.cfg.day)); idx.active = true; //判斷是否處於已滿足充值額度的狀態 let is_enough = false; if(data.status == 3 || data.status == 4){//明天後天領取 is_enough = true; let str_key = data.status == 3?"lab_WillTom":"lab_WillAf"; nx.gui.setString(this.node,"will/txt", nx.text.getKey( str_key ) ); } let path = "prefab/acts/firstcharge/ui/bg_charge_13"; if( is_enough ){ path = "prefab/acts/firstcharge/ui/bg_charge_13_01" } nx.gui.setSpriteFrame( this.node, "", path ); nx.gui.setActive(this.node,"normal",data.status == 0); nx.gui.setActive(this.node,"got",data.status == 2); nx.gui.setActive(this.node,"get",data.status == 1); nx.gui.setActive(this.node,"will",is_enough); this.lay.rebuild(data.cfg.item_list); //添加红点 if(data.status == 1){ this.mod.openTip(TIP_RED[data.cfg.fid],true); } }, onDisable(){ this.lay.rebuild([]) }, onClickBuy(){ nx.bridge.closePanel("WndFirstCharge"); //跳转至商店 nx.bridge.createPanel( "WndPayment", { key: 1 } ); }, //领奖 onClickClaim(){ if(this.mod && this.data){ this.mod.reqChargeReward(this.data.cfg.id); } } // update (dt) {}, });