67 lines
1.9 KiB
JavaScript
67 lines
1.9 KiB
JavaScript
|
|
"use strict";
|
||
|
|
cc._RF.push(module, 'aaa62rgnBtBgaWpOzS5Bcvr', 'cmp.act.training7.buy');
|
||
|
|
// Scripts/mod/acts/training7/cmp.act.training7.buy.js
|
||
|
|
|
||
|
|
"use strict";
|
||
|
|
|
||
|
|
var Act7Mod = require("act.training7.mod");
|
||
|
|
var PathTool = require("pathtool");
|
||
|
|
cc.Class({
|
||
|
|
"extends": cc.Component,
|
||
|
|
properties: {
|
||
|
|
itemNd: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
},
|
||
|
|
dname: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
},
|
||
|
|
fabItem: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Prefab
|
||
|
|
},
|
||
|
|
btn: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// LIFE-CYCLE CALLBACKS:
|
||
|
|
setData: function setData(data) {
|
||
|
|
if (nx.dt.objEmpty(data)) return;
|
||
|
|
this.data = data;
|
||
|
|
nx.gui.setString(this.dname, "", data.desc);
|
||
|
|
if (!this.award) {
|
||
|
|
this.award = cc.instantiate(this.fabItem);
|
||
|
|
this.award.parent = this.itemNd;
|
||
|
|
}
|
||
|
|
var cmp = nx.gui.getComponent(this.award, "", "cmp.item.base");
|
||
|
|
cmp.setData(data.award1[0]);
|
||
|
|
var halfStatusList = Act7Mod.getInstance().getHalfGiftList(data.day);
|
||
|
|
for (var i in halfStatusList) {
|
||
|
|
if (data.id == halfStatusList[i].day) {
|
||
|
|
this.data.status = halfStatusList[i].status;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
var bcp = nx.gui.getComponent(this.btn, "", cc.Button);
|
||
|
|
nx.gui.setActive(this.node, "cost", this.data.price2 != 0);
|
||
|
|
if (this.data.status == 1) {
|
||
|
|
bcp.interactable = false;
|
||
|
|
nx.gui.setActive(this.btn, "ico", false);
|
||
|
|
nx.gui.setString(this.btn, "num", nx.text.getKey("lab_rfm_personal_gift_window_tip2"));
|
||
|
|
} else {
|
||
|
|
bcp.interactable = true;
|
||
|
|
nx.gui.setActive(this.btn, "ico", true);
|
||
|
|
nx.gui.setString(this.btn, "num", this.data.price2);
|
||
|
|
var res = PathTool.queryIconPath(3);
|
||
|
|
nx.gui.setSpriteFrame(this.btn, "ico", res);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
onTouchBuy: function onTouchBuy() {
|
||
|
|
if (nx.dt.objEmpty(this.data)) return;
|
||
|
|
Act7Mod.getInstance().sender13602(4, this.data.day, this.data.id, 0);
|
||
|
|
} // update (dt) {},
|
||
|
|
});
|
||
|
|
|
||
|
|
cc._RF.pop();
|