Files
fc/dev/project/library/imports/54/541be91d-646e-4b72-b797-beddb15a0f05.js
2026-05-24 10:21:26 +08:00

266 lines
6.7 KiB
JavaScript

"use strict";
cc._RF.push(module, '541bekdZG5LcreXvt2xWg8F', 'cmp.team.summon');
// Scripts/mod/acts/teamSummon/cmp/cmp.team.summon.js
"use strict";
/******************************************************************
*
* 限定招募
*
******************************************************************/
var ActPage = require("act.page.base");
var NxSpine = require("nx.fx.spine");
var ItemLayout = require("cmp.item.layout");
var BridgeItemBinder = require("bridge.binder.item.icon.count");
var TipsController = require("tips_controller");
var FID = require("bridge.function.ids");
cc.Class({
"extends": ActPage,
properties: {
spLogo: {
"default": null,
type: NxSpine
},
nodDate: {
"default": null,
type: cc.Node
},
nodTip: {
"default": null,
type: cc.Node
},
nodCoin: {
"default": null,
type: BridgeItemBinder
},
nodScore: {
"default": null,
type: BridgeItemBinder
},
nodOps: {
"default": null,
type: cc.Node
},
nodClose: {
"default": null,
type: cc.Node
},
tipReward: {
"default": null,
type: ItemLayout
}
},
// 初始化
build: function build(_data) {
this._super(_data);
// 置空
if (!this.mod || nx.dt.objEmpty(this.data)) {
this.setEmpty();
return;
}
// 配置查询
this.configs = this.mod.queryConfigs();
if (!this.configs) {
this.setEmpty();
return;
}
// 活动监听
// this.mod.vbind( this, [
// ["LimitPrayFreshed", this.onFreshData.bind( this )],
// ] );
// 基本信息
this.buildBasic();
this.nodOps.active = false;
this.nodClose.active = false;
},
// 显示
onEnable: function onEnable() {
var _this = this;
this.mod.reqState(function (_ret, _data) {
if (!_ret || !_data) {
return;
}
// 0-未开启,1-开放阶段
_this.nodOps.active = _data.status == 1;
_this.nodClose.active = _data.status == 0;
});
},
// 销毁
onDestroy: function onDestroy() {
this._super();
},
// 置空
setEmpty: function setEmpty() {
nx.gui.setActive(this, "right", false);
},
// 基本信息
buildBasic: function buildBasic() {
var _this2 = this;
// 置空
if (!this.mod || !this.configs || nx.dt.objEmpty(this.data)) {
this.setEmpty();
return;
}
// 背景刷新
var spfile = cc.path.join("locals/{lang}/spines", this.configs.anim, "action");
this.spLogo.play(spfile, "action", null, true);
// 道具绑定
this.nodCoin.setID(this.configs.item_id, function () {
_this2.freshOps();
});
// 积分绑定
if (this.nodScore) {
var _txt = nx.text.format('积分解锁', this.configs.score_vip);
nx.gui.setString(this.nodScore, "vip", _txt);
var tip = nx.gui.getComponent(this.nodScore, "tip", "nx.vb.visible");
tip.setTarget(nx.mTip, this.mod.getTipKey("score"));
this.nodScore.setID(this.configs.score_id, function (_id, _count) {
_this2.freshScore(_count);
});
}
// 红点绑定
var tip1 = nx.gui.getComponent(this.nodOps, "once/tip", "nx.vb.visible");
if (tip1) {
tip1.setTarget(nx.mTip, this.mod.getTipKey("once"));
}
var tip2 = nx.gui.getComponent(this.nodOps, "ten/tip", "nx.vb.visible");
if (tip2) {
tip2.setTarget(nx.mTip, this.mod.getTipKey("ten"));
}
var txt = nx.text.getKey(this.configs.open_desc);
nx.gui.setString(this.nodClose, "txt", txt);
nx.gui.setString(this.nodTip, "txt", txt);
this.tipReward.rebuild(this.configs.reward_show);
this.freshDate();
},
// 刷新活动日期
freshDate: function freshDate() {
var time = nx.bridge.time.toNeedTime(this.data.end_time);
nx.gui.setString(this.nodDate, "txt", time);
},
// 刷新奖励
freshRewards: function freshRewards(_list) {
var rewards = [];
if (nx.dt.arrNEmpty(_list)) {
for (var i = 0; i < _list.length; ++i) {
rewards.push([_list[i].bid, 1]);
}
}
this.tipReward.rebuild(rewards);
},
// 变化信息
freshOps: function freshOps() {
// 置空
if (!this.mod || !this.configs || nx.dt.objEmpty(this.data)) {
return;
}
// 按钮设置
var autoOp = function autoOp(_node, _draw, _pt) {
var tinfo = gitemdata(_draw[0]);
if (tinfo) {
nx.bridge.setIcon(_node, "btn/list/icon", tinfo.icon);
nx.gui.setString(_node, "btn/list/num", _draw[1]);
}
};
// 操作刷新
autoOp(nx.gui.find(this.nodOps, "once"), this.configs.item_once[0]);
autoOp(nx.gui.find(this.nodOps, "ten"), this.configs.item_ten[0]);
},
// 点击单抽
onTouchOnce: function onTouchOnce() {
var _this3 = this;
if (!this.configs || !this.mod) {
return;
}
this.mod.reqSummon(true, function (_ret, _msg, _code) {
if (!_ret) {
nx.tbox(_msg);
// 道具不足
if (_code == 101) {
_this3.onTouchCoin();
}
}
});
},
// 点击十抽
onTouchTen: function onTouchTen() {
var _this4 = this;
if (!this.configs || !this.mod) {
return;
}
this.mod.reqSummon(false, function (_ret, _msg, _code) {
if (!_ret) {
nx.tbox(_msg);
// 道具不足
if (_code == 101) {
_this4.onTouchCoin();
}
}
});
},
// 点击规则
onTouchRule: function onTouchRule() {
var rule = this.configs ? this.configs.rule : "";
if (nx.dt.strNEmpty(rule)) {
var TC = TipsController.getInstance();
TC.showTextPanel("tip", rule);
}
},
// 点击道具
onTouchCoin: function onTouchCoin() {
if (this.actRoot && this.configs) {
this.actRoot.jumpToMenu(this.configs.jump);
}
},
// 点击奖池
onTouchChi: function onTouchChi() {
nx.bridge.createPanel("WndSummonRule", {
key: "recruit_gather_data"
});
},
// ============================================================
// 积分相关
// ============================================================
// 积分更新
freshScore: function freshScore(_count) {
var limit = this.configs.score_limit;
var prog = nx.gui.getComponent(this.nodScore, "prog", cc.ProgressBar);
if (prog) {
prog.progress = _count / limit;
}
var txt = _count + "/" + limit;
nx.gui.setString(this.nodScore, "score/txt", txt);
this.mod.freshTips();
},
// 点击积分
onTouchScore: function onTouchScore() {
var _this5 = this;
var can = nx.gui.isActive(this.nodScore, "tip");
if (!can) {
nx.tbox("积分不够提示");
return;
}
this.mod.reqScore(function (_ret, _msg, _code) {
// 道具不足
if (!_ret && _code == 101) {
nx.tbox(_msg);
_this5.onTouchCoin();
}
});
}
});
cc._RF.pop();