Files
fc/dev/project/library/imports/d3/d3721174-35cf-428f-a94a-5ff8db58d789.js
T

118 lines
2.9 KiB
JavaScript
Raw Normal View History

2026-05-24 10:21:26 +08:00
"use strict";
cc._RF.push(module, 'd3721F0Nc9Cj6lKX/jbWNeJ', 'cmp.main.theme.entry');
// Scripts/mod/mainui/cmp/cmp.main.theme.entry.js
"use strict";
/******************************************************************
* Copyright(C) 2019 - 2020 Nx Studio
*
* 主界面 --- 主题入口图标
*
*
******************************************************************/
var Trigger = require("cmp.plot.trigger");
var NxVisible = require("nx.vb.visible");
var CLocker = require("bridge.condition.locker");
var NxSpine = require("nx.fx.spine");
cc.Class({
"extends": cc.Component,
properties: {
trigger: {
"default": null,
type: Trigger
},
locker: {
"default": null,
type: CLocker
},
tip: {
"default": null,
type: NxVisible
},
spEffect: {
"default": null,
type: NxSpine
}
},
// 设置
setTheme: function setTheme(_data) {
this.theme = _data || {};
// 置空
if (nx.dt.objEmpty(this.theme)) {
nx.gui.setActive(this, "on", false);
nx.gui.setActive(this, "off", false);
return;
}
// 主题图标
var path = cc.path.join("resDB/acts/icons", this.theme.icon);
nx.gui.setSpriteFrame(this, "on/img", path);
nx.gui.setSpriteFrame(this, "off/img", path);
// 主题名
nx.gui.setString(this, "on/txt", nx.text.getKey(this.theme.name));
// 提示
var key = nx.bridge.acts.getThemeTipKey(this.theme.theme_id);
if (this.tip && nx.dt.strNEmpty(key)) {
this.tip.setTarget(nx.mTip, key);
}
// 特效提示
if (nx.dt.strEmpty(this.theme.effect)) {
this.spEffect.stop();
} else {
path = cc.path.join("resDB/effects", this.theme.effect, "action");
this.spEffect.play(path, "action", function () {}, true);
}
// 条件锁
if (this.locker) {
this.locker.setCondition(this.theme.source || 0);
}
},
// 时间刷新
tick: function tick() {
if (!this.theme || nx.gui.isActive(this, "off")) {
return;
}
// 无限时
if (!nx.dt.numPositive(this.theme.end_time, false)) {
nx.gui.setActive(this, 'on/cd', false);
return;
}
// 已过期
var tm = nx.bridge.time.cdSimple(this.theme.end_time);
if (nx.dt.strEmpty(tm)) {
nx.gui.setActive(this, 'on/cd', false);
return;
}
// 正常
nx.gui.setActive(this, 'on/cd', true);
nx.gui.setString(this, "on/cd/txt", tm);
},
// 点击
onTouch: function onTouch() {
// 无效主题
if (nx.dt.objEmpty(this.theme) || nx.dt.arrEmpty(this.theme.theme_holiday_list)) {
return;
}
// 如果只有一个活动,直接打开
if (this.theme.theme_holiday_list.length == 1) {
var ainfo = this.theme.theme_holiday_list[0];
nx.bridge.jumper.jump2ActPage(ainfo.camp_id);
} else {
// 跳转主题页
nx.bridge.jumper.jump2ActTheme(this.theme.theme_id);
}
}
});
cc._RF.pop();