136 lines
4.2 KiB
JavaScript
136 lines
4.2 KiB
JavaScript
const ItemBase = require("nx.fx.sv.expand.item");
|
|
const ItemLay = require("cmp.common.itemlayout");
|
|
const ActUpstarMod = require("act.upstar.mod");
|
|
const HeroUpstarMod = require("act.heroupstar.mod");
|
|
const LimitupstarMod = require("act.limitupstar.mod");
|
|
const Payment = require( "payment.mod" );
|
|
|
|
cc.Class({
|
|
extends: ItemBase,
|
|
|
|
properties: {
|
|
starNum:{
|
|
default:null,
|
|
type:cc.Node
|
|
},
|
|
tag:{
|
|
default:null,
|
|
type:cc.Node
|
|
},
|
|
fabItem:{
|
|
default:null,
|
|
type:cc.Prefab
|
|
},
|
|
itemMask:{
|
|
default:null,
|
|
type:cc.Node
|
|
},
|
|
got:{
|
|
default:null,
|
|
type:cc.Node
|
|
},
|
|
lay:{
|
|
default:null,
|
|
type:ItemLay
|
|
},
|
|
btnBuy:{
|
|
default:null,
|
|
type:cc.Node
|
|
},
|
|
},
|
|
|
|
// LIFE-CYCLE CALLBACKS:
|
|
|
|
rebind(_index,_data,_key){
|
|
this._super(_index,_data,_key);
|
|
this.setData(_data,_key);
|
|
},
|
|
|
|
setData(data,key){
|
|
if(nx.dt.objEmpty(data)){
|
|
// this.lay.rebuild([]);
|
|
return;
|
|
}
|
|
|
|
|
|
this.charge_data = game.configs.charge_data.data_charge_data[data.chagerid];
|
|
nx.gui.setString(this.starNum,"",cc.js.formatStr(nx.text.getKey("UpstarNum"),data.star));
|
|
let own_award_list = data.own_award_list;
|
|
let price_list = [];
|
|
for(let i in own_award_list){
|
|
let price_data = own_award_list[i];
|
|
price_list.push({bid:price_data.own_itemid,num:price_data.own_num});
|
|
}
|
|
this.lay.rebuild(price_list);
|
|
if(!this.tagItem){
|
|
this.tagItem = cc.instantiate(this.fabItem);
|
|
this.tagItem.parent = this.tag;
|
|
}
|
|
let cmp = nx.gui.getComponent(this.tagItem,"","cmp.item.base");
|
|
if(cmp){
|
|
cmp.rebind(0,{bid:data.free_itemid,num:data.free_num});
|
|
}
|
|
nx.gui.setString(this.btnBuy,"txt",Payment.getInstance().fmtPrice(this.charge_data.val));
|
|
|
|
//设置状态
|
|
if(key == 381){//升星計劃
|
|
this.act_type = 1;
|
|
//判断是否能买付费礼物
|
|
if(data.buy_state != 1){
|
|
if(data.buy_state == 2){
|
|
nx.gui.setString(this.btnBuy,"txt",nx.text.getKey("Charged"));
|
|
}
|
|
nx.gui.setLocked(this.btnBuy,"",true);
|
|
}else{
|
|
nx.gui.setLocked(this.btnBuy,"",false);
|
|
}
|
|
}else{
|
|
this.act_type = key;
|
|
let lock_status = 1;
|
|
if(key == 351){
|
|
lock_status = ActUpstarMod.getInstance().getIsLock();
|
|
}else if(key == 475){
|
|
lock_status = LimitupstarMod.getInstance().getIsLock();
|
|
}
|
|
|
|
if(lock_status == 1){//已锁定才能进行操作
|
|
//判断是否能买付费礼物
|
|
if(data.buy_state != 1){
|
|
if(data.buy_state == 2){
|
|
nx.gui.setString(this.btnBuy,"txt",nx.text.getKey("Charged"));
|
|
}
|
|
nx.gui.setLocked(this.btnBuy,"",true);
|
|
}else{
|
|
nx.gui.setLocked(this.btnBuy,"",false);
|
|
}
|
|
}else{
|
|
nx.gui.setLocked(this.btnBuy,"",true);
|
|
}
|
|
}
|
|
|
|
//判断免费礼物
|
|
nx.gui.setActive(this.itemMask,"",data.free_state != 2);
|
|
nx.gui.setActive(this.itemMask,"lock",data.free_state == 0);
|
|
nx.gui.setActive(this.got,"",data.free_state == 2);
|
|
},
|
|
|
|
onClickAward(){
|
|
if(this.mdata.free_state == 1){
|
|
if(this.act_type == 1){
|
|
HeroUpstarMod.getInstance().send29212(this.mdata.star, HeroUpstarMod.getInstance().data.camp_id );
|
|
}else if(this.act_type == 351){
|
|
ActUpstarMod.getInstance().send29204(this.mdata.star);
|
|
}else if(this.act_type == 475){
|
|
LimitupstarMod.getInstance().send29224(this.mdata.star);
|
|
}
|
|
}
|
|
},
|
|
|
|
onClickBuy(){
|
|
if(this.mdata.buy_times < this.mdata.limit_buy){
|
|
//花钱买
|
|
Payment.getInstance().reqPayment(this.mdata.chagerid );
|
|
}
|
|
}
|
|
});
|