Files
fc/dev/project/library/imports/f7/f744a21f-38cc-4030-b77f-8684914fb0a1.js
2026-05-24 10:21:26 +08:00

223 lines
7.2 KiB
JavaScript

"use strict";
cc._RF.push(module, 'f744aIfOMxAMLd/hoSRT7Ch', 'cmp.act.doublered');
// Scripts/mod/acts/doubleredpacket/cmp/cmp.act.doublered.js
"use strict";
var BridgeWindow = require("bridge.window");
var NxSpine = require("nx.fx.spine");
var ItemLayout = require("cmp.common.itemlayout");
var mod = require("act.doublered.mod");
var FID = require("bridge.function.ids");
var themeMod = require("acts.mod");
/***
*
* 翻倍红包相关
*/
cc.Class({
"extends": BridgeWindow,
properties: {
spRole: {
"default": null,
type: NxSpine
},
nodRates: {
"default": null,
type: cc.Node
},
nodLeft: {
"default": null,
type: cc.Node
},
nodLeftReward: {
"default": null,
type: ItemLayout
},
nodRight: {
"default": null,
type: cc.Node
},
nodLeftTitle: {
"default": null,
type: cc.Node
},
nodOp: {
"default": null,
type: cc.Node
},
nodScroller: {
"default": null,
type: cc.ScrollView
}
},
// 初始化
onLoad: function onLoad() {
var _this = this;
this.mod = mod.getInstance();
if (!this.mod) {
return;
}
this.spRole.load("resDB/models/H30103/show", function (_e) {
if (!_e) {
_this.spRole.action("drama1", true);
} else {
_this.spRole.stop();
}
});
var rfgs = gdata(this.mod.data.config, "data_drama_reward");
this.rcfgs = rfgs;
this.help = gdata(this.mod.data.config, "data_desc")[1];
var len = Object.keys(rfgs).length;
var cfgcon = gdata(this.mod.data.config, "data_drama_const");
this.base_diamond = cfgcon.initial_diamond.val;
this.reward = cfgcon.grand_prize.val;
var data = {
bid: this.reward[0],
num: this.reward[1]
};
this.nodLeftReward.rebuild([data]);
nx.gui.setActive(this.nodLeftReward.node.parent, "", false);
nx.gui.gocChildren(this.nodRates, "", len);
var chd = this.nodRates.children;
for (var i in rfgs) {
var info = rfgs[i];
var nod = chd[info.id - 1];
nx.gui.setString(nod, "normal/num", info.num);
nx.gui.setString(nod, "focus/num", info.num);
nx.bridge.setIconS(nod, "normal/icon", 3);
nx.bridge.setIconS(nod, "focus/icon", 3);
nx.gui.setString(nod, "normal/count", nx.text.format("ActRate", info.rate));
nx.gui.setString(nod, "focus/count", nx.text.format("ActRate", info.rate));
nx.gui.setActive(nod, "focus", false);
nx.gui.setActive(nod, "normal", true);
}
this.mod.vbind(this, [["doublered", this.freshDoubleRedInfo.bind(this)]]);
},
onEnable: function onEnable() {
this.mod.reqDoubleRedData();
},
// 销毁
onDestroy: function onDestroy() {
// 活动监听解除
if (this.mod) {
this.mod.vunbind(this);
}
delete this.mod;
this._super();
},
freshDoubleRedInfo: function freshDoubleRedInfo(_data) {
// if( )
// {"status":1,"end_time":1696175999,"is_activate":0,"num":0,"role_ids":[]}
if (!this.nodRates) {
return;
}
var btn = nx.gui.getComponent(this.nodOp, "charge", cc.Button);
if (btn) {
btn.interactable = _data.is_activate == 0 && _data.status == 1;
nx.gui.setOutlineColor(this.nodOp, "charge/txt", _data.is_activate == 0 && _data.status == 1 ? new cc.color("#945234") : cc.Color.BLACK);
}
var rate = 0;
var lucklist = "";
var pos = 0;
if (this.rcfgs) {
var len = Object.keys(this.rcfgs).length;
for (var i in this.rcfgs) {
var rfg = this.rcfgs[i];
var lucky_item = _data.role_ids[i - 1];
if (lucky_item) {
lucklist += i + "." + lucky_item.name + "\n";
}
var next = this.rcfgs[rfg.id + 1];
nx.gui.setActive(this.nodRates.children[rfg.id - 1], "focus", false);
nx.gui.setActive(this.nodRates.children[rfg.id - 1], "normal", true);
if (next) {
if (_data.num >= rfg.num && _data.num > 100 || _data.num >= rfg.num && _data.num < next.num) {
rate = rfg.rate;
pos = rfg.id;
// break;
} else {
if (_data.num > rfg.num && _data.num <= next.num) {
rate = next.rate;
pos = next.id;
}
}
} else {
next = this.rcfgs[len];
if (_data.num >= rfg.num && _data.num > 100 || _data.num >= rfg.num && _data.num < next.num) {
rate = rfg.rate;
pos = rfg.id;
// break;
} else {
if (_data.num > rfg.num && _data.num <= next.num) {
rate = next.rate;
pos = next.id;
}
}
}
}
}
// let nod = this.nodRates.parent.parent;
if (this.nodScroller) {
if (pos - 1 <= 4) {
this.nodScroller.scrollToTop(0.01); // scrollTo
} else {
if (pos - 1 > 4 && pos - 1 < 11) {
var posp = cc.v2(0, (pos - 1) * 74);
this.nodScroller.setContentPosition(posp); // scrollTo
} else {
this.nodScroller.scrollToBottom(0.01); // scrollTo
}
}
}
nx.gui.setActive(this.nodRates.children[pos - 1], "focus", true);
nx.gui.setActive(this.nodRates.children[pos - 1], "normal", false);
if (_data.status == 1) {
nx.gui.setString(this.nodOp, "charge/txt", _data.is_activate == 0 ? nx.text.getKey("GotoCharge") : nx.text.getKey("ActBtnTip"));
nx.gui.setString(this.nodLeftTitle, "", nx.text.getKey("ActHelpTitle"));
nx.gui.setStringRich(this.nodLeft, "", this.help.desc);
} else {
if (_data.end_time != 0) {
nx.gui.setString(this.nodLeftTitle, "", nx.text.getKey("ActHelpTitle"));
nx.gui.setStringRich(this.nodLeft, "", this.help.desc);
} else {
nx.gui.setString(this.nodLeftTitle, "", nx.text.getKey("ActLuckyList"));
nx.gui.setStringRich(this.nodLeft, "", lucklist);
}
nx.gui.setString(this.nodOp, "charge/txt", nx.text.getKey("lab_planesafk_main_have_over"));
}
nx.bridge.setIconS(this.nodOp, "rbg/icon", 3);
nx.gui.setString(this.nodOp, "rbg/num", rate > 0 ? rate * this.base_diamond : this.base_diamond);
nx.gui.setString(this.nodOp, "rate_bg/count", nx.text.format("ActRate", rate));
nx.gui.setActive(this.nodOp, "rbg", true);
nx.gui.setActive(this.nodOp, "rate_bg", true);
nx.gui.setActive(this.nodOp, "status", _data.is_activate != 0);
var cd = _data.end_time - Math.floor(cc.sys.now() / 1000) > 0 ? _data.end_time - Math.floor(cc.sys.now() / 1000) : 0;
if (cd > 0) {
nx.gui.setCdTxt(this.nodRight, "tbg/time", _data.end_time - Math.floor(cc.sys.now() / 1000));
} else {
nx.gui.setString(this.nodRight, "tbg/time", nx.text.getKey("lab_recruit_hero_window_tip_6"));
}
nx.gui.setString(this.nodRight, "result/num", _data.num);
},
onTouchCharge: function onTouchCharge() {
nx.bridge.createPanel("WndPayment", {
key: "recharge"
});
this.close();
},
onTouchReward: function onTouchReward() {
nx.gui.setActive(this.nodLeftReward.node.parent, "", !this.nodLeftReward.node.parent.active);
},
onTouchClose: function onTouchClose() {
this.close();
var theme = themeMod.getInstance().queryTheme(this.mod.data.theme_id);
nx.bridge.jumper.jump2Window(FID.ActOpenServer, theme);
}
});
cc._RF.pop();