141 lines
4.0 KiB
JavaScript
141 lines
4.0 KiB
JavaScript
|
|
"use strict";
|
||
|
|
cc._RF.push(module, '82b4bwC4jBKK7DvECp9Po6w', 'cmp.act.upstar.item');
|
||
|
|
// Scripts/mod/acts/upstar/cmp/cmp.act.upstar.item.js
|
||
|
|
|
||
|
|
"use strict";
|
||
|
|
|
||
|
|
var ItemBase = require("nx.fx.sv.expand.item");
|
||
|
|
var ItemLay = require("cmp.common.itemlayout");
|
||
|
|
var ActUpstarMod = require("act.upstar.mod");
|
||
|
|
var HeroUpstarMod = require("act.heroupstar.mod");
|
||
|
|
var LimitupstarMod = require("act.limitupstar.mod");
|
||
|
|
var 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: function rebind(_index, _data, _key) {
|
||
|
|
this._super(_index, _data, _key);
|
||
|
|
this.setData(_data, _key);
|
||
|
|
},
|
||
|
|
setData: function 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));
|
||
|
|
var own_award_list = data.own_award_list;
|
||
|
|
var price_list = [];
|
||
|
|
for (var i in own_award_list) {
|
||
|
|
var 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;
|
||
|
|
}
|
||
|
|
var 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;
|
||
|
|
var 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: function 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: function onClickBuy() {
|
||
|
|
if (this.mdata.buy_times < this.mdata.limit_buy) {
|
||
|
|
//花钱买
|
||
|
|
Payment.getInstance().reqPayment(this.mdata.chagerid);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
cc._RF.pop();
|