68 lines
2.1 KiB
JavaScript
68 lines
2.1 KiB
JavaScript
|
|
"use strict";
|
||
|
|
cc._RF.push(module, '2786eT5bOJKLaSjcXbtUfZH', 'cmp.act.weeklygift.item');
|
||
|
|
// Scripts/mod/payment/cmp/cmp.act.weeklygift.item.js
|
||
|
|
|
||
|
|
"use strict";
|
||
|
|
|
||
|
|
var SVCItem = require("nx.fx.sv.expand.item");
|
||
|
|
var ItemLst = require("cmp.common.itemlayout");
|
||
|
|
var Payment = require("payment.mod");
|
||
|
|
cc.Class({
|
||
|
|
"extends": SVCItem,
|
||
|
|
properties: {
|
||
|
|
nodRewards: {
|
||
|
|
"default": null,
|
||
|
|
type: ItemLst
|
||
|
|
},
|
||
|
|
nodName: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
},
|
||
|
|
nodBuy: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
},
|
||
|
|
nodLeft: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// 数据重置
|
||
|
|
rebind: function rebind(_idx, _data, _key) {
|
||
|
|
this._super(_idx, _data, _key);
|
||
|
|
this.setData();
|
||
|
|
},
|
||
|
|
setData: function setData() {
|
||
|
|
if (!this.mdata) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
this.cb = this.mdata.cb;
|
||
|
|
nx.gui.setString(this.nodName, "", this.mdata.gift.gift_name);
|
||
|
|
this.nodRewards.rebuild(this.mdata.rewards.reward);
|
||
|
|
nx.gui.setString(this.nodBuy, "num", this.mdata.gift.val == 0 ? nx.text.getKey("Get") : Payment.getInstance().fmtPrice(this.mdata.gift.val));
|
||
|
|
// nx.gui.setActive( this.nodBuy, "tip", this.mdata.gift.val == 0 );
|
||
|
|
this.freshLeft(this.mdata.count);
|
||
|
|
},
|
||
|
|
freshLeft: function freshLeft(_num) {
|
||
|
|
this.canBuy = this.mdata.gift.limit_count - _num > 0;
|
||
|
|
nx.gui.setActive(this.nodBuy, "tip", this.canBuy && this.mdata.gift.val == 0);
|
||
|
|
nx.gui.setString(this.nodLeft, "num", this.mdata.gift.limit_count - _num);
|
||
|
|
var btn = nx.gui.getComponent(this.nodBuy, "", cc.Button);
|
||
|
|
if (btn) {
|
||
|
|
btn.interactable = this.mdata.gift.limit_count - _num > 0;
|
||
|
|
if (this.mdata.gift.val == 0) {
|
||
|
|
this.mdata.gift.limit_count - _num > 0 ? nx.gui.setString(this.nodBuy, "num", nx.text.getKey("Get")) : nx.gui.setString(this.nodBuy, "num", nx.text.getKey("Got"));
|
||
|
|
}
|
||
|
|
nx.gui.setOutlineColor(this.nodBuy, "num", this.mdata.gift.limit_count - _num > 0 ? new cc.color("#b85833") : cc.Color.BLACK);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
onTouchBuy: function onTouchBuy() {
|
||
|
|
if (!this.canBuy) {
|
||
|
|
nx.tbox("tip_eleBuyNumOver");
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
nx.dt.fnInvoke(this.cb, true);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
cc._RF.pop();
|