Files
fc/dev/project/library/imports/18/183f1160-ef88-416e-8469-a5fe277d391a.js
2026-05-24 10:21:26 +08:00

188 lines
5.8 KiB
JavaScript

"use strict";
cc._RF.push(module, '183f1Fg74hBboRppf4nfTka', 'act.hundreddraw.wnd');
// Scripts/mod/acts/hundreddraw/cmp/act.hundreddraw.wnd.js
"use strict";
/******************************************************************
*
* 開服百抽
*
******************************************************************/
var ActPage = require("act.page.base");
var NxSpine = require("nx.fx.spine");
var Payment = require("payment.mod");
cc.Class({
"extends": ActPage,
properties: {
nodRewards: {
type: cc.Node,
"default": null
},
spRole: {
type: NxSpine,
"default": null
},
nodOp: {
type: cc.Node,
"default": null
}
},
// 初始化
build: function build(_data) {
var _this = this;
this._super(_data);
// 无效
if (!this.mod) {
return;
}
// nx.gui.setActive( this.spRole, "", false );
this.spRole.load("resDB/models/H30083/show", function (_e) {
if (!_e) {
_this.spRole.action("drama1", true);
} else {
_this.spRole.stop();
}
});
// 獲取相關的配置
var cfg = gdata(this.mod.data.config, "data_news_draws_data");
var count = Object.keys(cfg).length;
nx.gui.gocChildren(this.nodRewards, "", count);
for (var i in cfg) {
var info = cfg[i];
var nod = this.nodRewards.children[info.id - 1];
var free = nx.gui.find(nod, "free/buy");
nx.gui.setActive(nod, "free/focus", false);
nx.gui.setActive(nod, "free/got", false);
nx.gui.setActive(nod, "cost/got", false);
nx.gui.setActive(nod, "cost/focus", false);
nx.gui.setString(nod, "day/txt", info.id < 10 ? "0" + info.id : info.id);
var cmp = nx.gui.getComponent(free, "", "cmp.common.itemlayout");
if (cmp) {
cmp.rebuild(info.reward);
}
var buy = nx.gui.find(nod, "cost/buy");
var bcmp = nx.gui.getComponent(buy, "", "cmp.common.itemlayout");
if (bcmp) {
bcmp.rebuild(info.unlock_reward);
}
}
var charge = gdata(this.mod.data.config, "data_const").charge_id;
this.charge_id = charge.val;
var cinfo = game.configs.charge_data.data_charge_data[charge.val];
nx.gui.setString(this.nodOp, "charge/txt", nx.text.format("NeedPayUnlock", Payment.getInstance().fmtPrice(cinfo.val)));
this.needpay = cinfo.val;
nx.gui.setActive(this.nodOp, "free/tip", false);
nx.gui.setActive(this.nodOp, "charge/tip", false);
// // 活动监听
this.mod.vbind(this, [["HundredDraw", this.freshInfo.bind(this)]]);
/*******
* {"status_list":[
* {"day":10,"status1":0,"status2":0},
* {"day":9,"status1":0,"status2":0},
* {"day":8,"status1":0,"status2":0},
* {"day":7,"status1":0,"status2":0},
* {"day":6,"status1":0,"status2":0},
* {"day":5,"status1":0,"status2":0},
* {"day":4,"status1":0,"status2":0},
* {"day":3,"status1":1,"status2":0},
* {"day":2,"status1":1,"status2":0},
* {"day":1,"status1":1,"status2":0}
* ],"is_charge":0}
*/
},
onEnable: function onEnable() {
this.mod.reqBaseData();
},
// 刷新相關的數據顯示 主要包含當前的領取數據
freshInfo: function freshInfo(_data) {
if (!_data || !this.nodRewards) {
return;
}
var chd = this.nodRewards.children;
this.buyInfo = _data;
var list = _data.status_list;
this.canGetFree = [];
this.canGetPay = [];
for (var i = 0; i < list.length; i++) {
var info = list[i];
var nod = chd[i];
if (info.day == i + 1) {
var free = nx.gui.find(nod, "free");
var cost = nx.gui.find(nod, "cost");
nx.gui.setActive(free, "focus", info.status1 == 1);
nx.gui.setActive(cost, "focus", info.status2 == 1);
nx.gui.setActive(free, "got", info.status1 == 2);
nx.gui.setActive(cost, "got", info.status2 == 2);
nx.gui.setActive(cost, "lock", _data.is_charge == 0);
}
if (info.status1 == 1) {
this.canGetFree.push(info.day);
}
if (info.status2 == 1) {
this.canGetPay.push(info.day);
}
}
nx.gui.setActive(this.nodOp, "free/tip", nx.dt.arrNEmpty(this.canGetFree));
nx.gui.setActive(this.nodOp, "charge/tip", nx.dt.arrNEmpty(this.canGetPay));
nx.gui.setString(this.nodOp, "charge/txt", this.buyInfo.is_charge == 0 ? nx.text.format("NeedPayUnlock", Payment.getInstance().fmtPrice(this.needpay)) : nx.text.getKey("ActPayGet"));
var cmp = nx.gui.getComponent(this.nodOp, "free", cc.Button);
var pcmp = nx.gui.getComponent(this.nodOp, "charge", cc.Button);
if (cmp) {
cmp.interactable = nx.dt.arrNEmpty(this.canGetFree);
}
if (pcmp && this.buyInfo.is_charge == 1) {
pcmp.interactable = nx.dt.arrNEmpty(this.canGetPay);
}
},
// 點擊免費 打卡領取
onTouchGet: function onTouchGet() {
if (nx.dt.arrEmpty(this.canGetFree)) {
nx.tbox("ActHundredGetTip");
return;
}
if (!this.buyInfo) {
return;
}
var day = this.canGetFree.shift();
var info = {
day: day,
type: 0
};
this.mod.reqGetDailyReward(info);
},
// 點擊購買
onTouchBuy: function onTouchBuy() {
if (!this.buyInfo) {
return;
}
// 判斷當前的禮包購買狀態,若未購買則提示
var self = this;
var ischarge = this.buyInfo.is_charge;
if (ischarge == 0) {
var tip = nx.text.format("ActHundredBuyTip", Payment.getInstance().fmtPrice(this.needpay));
nx.mbox(tip, ['cancel', 'confirm'], function (_key, _box) {
_box.close();
if (_key == "confirm") {
// this.reqSummon( _args.type, _times, _args );
Payment.getInstance().reqPayment(self.charge_id);
}
});
} else {
var day = this.canGetPay.shift();
var info = {
day: day,
type: 1
};
this.mod.reqGetDailyReward(info);
}
}
});
cc._RF.pop();