114 lines
3.6 KiB
JavaScript
114 lines
3.6 KiB
JavaScript
"use strict";
|
|
cc._RF.push(module, 'de58cmqA/tAe7sKrNIiJ45c', 'pop.coin.buy.wnd');
|
|
// Scripts/mod/tips/popup/pop.coin.buy.wnd.js
|
|
|
|
"use strict";
|
|
|
|
var BridgeWindow = require("bridge.window");
|
|
var ExchangeEvent = require("exchange_event");
|
|
var ExchangeController = require("exchange_controller");
|
|
var BackpackController = require("backpack_controller");
|
|
var TipsController = require("tips_controller");
|
|
cc.Class({
|
|
"extends": BridgeWindow,
|
|
properties: {
|
|
nodInfo: {
|
|
type: cc.Node,
|
|
"default": null
|
|
},
|
|
nodTime: {
|
|
type: cc.Node,
|
|
"default": null
|
|
}
|
|
},
|
|
onLoad: function onLoad() {
|
|
this.bindGEvent(ExchangeEvent.Extra_Reward, this.onFreshCoin.bind(this));
|
|
this.onFreshCoin();
|
|
},
|
|
// 重载:参数打开
|
|
onOpenConfigs: function onOpenConfigs(_params) {},
|
|
onFreshCoin: function onFreshCoin(_data) {
|
|
var EC = ExchangeController.getInstance();
|
|
var model = EC.getModel();
|
|
var chd = this.nodInfo.children;
|
|
if (model) {
|
|
var info = model.getExchangeData() || _data;
|
|
this.costData = info.list;
|
|
var lst = info.list;
|
|
for (var i = 0; i < lst.length; i++) {
|
|
var node = chd[i];
|
|
var data = lst[i];
|
|
if (node) {
|
|
nx.gui.setString(node, "num", data.gain);
|
|
// nx.gui.setString( node, "op/cost", data.price > 0 ? data.price : nx.text.getKey( "Free" ) );
|
|
nx.gui.setString(node, "remain/txt", data.max - data.num);
|
|
// if( data.price > 0 ){
|
|
nx.bridge.setIconS(node, "mat_bg/icon", 3);
|
|
nx.gui.setString(node, "mat_bg/cost", data.price);
|
|
// }
|
|
|
|
nx.gui.setActive(node, "max", data.max - data.num <= 0);
|
|
nx.gui.setActive(node, "op/cann", data.max - data.num <= 0);
|
|
nx.gui.setActive(node, "op/buy", data.max - data.num > 0);
|
|
}
|
|
}
|
|
this.setFreeCD(info.ref_time);
|
|
}
|
|
},
|
|
// 免费倒计时
|
|
setFreeCD: function setFreeCD(_dtFree) {
|
|
this.unscheduleAllCallbacks();
|
|
if (!nx.dt.numPositive(_dtFree, false)) {
|
|
return;
|
|
}
|
|
var self = this;
|
|
// let rate = game.configs.sprite_data.data_const.hatch_rate.val;
|
|
var tick = function tick() {
|
|
var interval = Utils.getTimeInterval(_dtFree);
|
|
// console.log( "当前的倒计时" + interval );
|
|
if (interval <= 0) {
|
|
self.unscheduleAllCallbacks();
|
|
nx.gui.setString(self.nodTime, "txt", "");
|
|
return;
|
|
}
|
|
var time = Utils.changeIntevalToDate(interval);
|
|
var txt = time.H + ":" + time.M + ":" + time.S;
|
|
nx.gui.setString(self.nodTime, "txt", txt);
|
|
};
|
|
this.schedule(tick, 1, cc.macro.REPEAT_FOREVER);
|
|
tick();
|
|
},
|
|
onTouchGetCoin: function onTouchGetCoin(_index) {
|
|
var BC = BackpackController.getInstance();
|
|
var number = parseInt(_index);
|
|
if (!this.costData[number]) {
|
|
nx.tbox(nx.text.getKey("msg_bagsMax"));
|
|
return;
|
|
}
|
|
var num = this.costData[number].price;
|
|
var max = this.costData[number].max;
|
|
var dia = BC.getModel().getItemNumByBid(3);
|
|
if (dia - num <= 0 && num != 0) {
|
|
nx.tbox(nx.text.getKey("lab_role_controller_tip_1"));
|
|
return;
|
|
}
|
|
var EC = ExchangeController.getInstance();
|
|
if (EC) {
|
|
EC.send23607(number + 1);
|
|
}
|
|
},
|
|
onTouchHelp: function onTouchHelp() {
|
|
var txt = game.configs.misc_data.data_const.touch_gold_tips.desc;
|
|
var TC = TipsController.getInstance();
|
|
if (TC) {
|
|
TC.showTextPanel("tip", txt);
|
|
}
|
|
}
|
|
});
|
|
|
|
/**
|
|
* [server]#[recv] <<<[13:08:04][23606]:{"ref_time":1683680400,"camp_type":0,
|
|
* "list":[{"id":3,"price":50,"gain":50000,"num":6,"max":10},{"id":2,"price":20,"gain":20000,"num":4,"max":10},{"id":1,"price":0,"gain":10000,"num":3,"max":3}]}
|
|
*/
|
|
|
|
cc._RF.pop(); |