139 lines
3.3 KiB
JavaScript
139 lines
3.3 KiB
JavaScript
"use strict";
|
|
cc._RF.push(module, 'bb22817OqdOUKhJW3w0P28k', 'cmp.acts.wnd');
|
|
// Scripts/mod/acts/cmps/cmp.acts.wnd.js
|
|
|
|
"use strict";
|
|
|
|
/******************************************************************
|
|
*
|
|
* 常规活动列表
|
|
*
|
|
******************************************************************/
|
|
|
|
var BridgeWindow = require("bridge.window");
|
|
var ActDefine = require("acts.define");
|
|
var FxSVC = require("nx.fx.sv.expand");
|
|
cc.Class({
|
|
"extends": BridgeWindow,
|
|
properties: {
|
|
nodHead: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
nodContent: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
lstMenu: {
|
|
"default": null,
|
|
type: FxSVC
|
|
}
|
|
},
|
|
// 重载:参数打开
|
|
onOpenConfigs: function onOpenConfigs(_params) {
|
|
var _this = this;
|
|
// 无效参数
|
|
if (nx.dt.objEmpty(_params) || !nx.dt.numPositive(_params.theme_id, false)) {
|
|
this.delayClose();
|
|
return;
|
|
}
|
|
this.configs = _params;
|
|
|
|
// 标题
|
|
nx.gui.setString(this.nodHead, "txt", nx.text.getKey(_params.name));
|
|
|
|
// 列表构建
|
|
this.menus = _params.theme_holiday_list || [];
|
|
this.menus.sort(function (a, b) {
|
|
return a.sort - b.sort;
|
|
});
|
|
this.lstMenu.rebuild(this.menus);
|
|
|
|
// 延迟跳转
|
|
this.scheduleOnce(function () {
|
|
_this.jumpToMenu(_params.focus);
|
|
}, 0.1);
|
|
},
|
|
// 重载:关闭前
|
|
onPreClosed: function onPreClosed() {
|
|
// nx.bridge.acts.reqActsRewards();
|
|
},
|
|
close: function close() {
|
|
this._super();
|
|
|
|
//判断下是不是要回到openserver
|
|
var needShow = cc.sys.localStorage.getItem("needBackOpenServerAct");
|
|
if (needShow == 1) {
|
|
//cc.sys.localStorage.removeItem("needBackOpenServerAct")
|
|
nx.bridge.createPanel("WndOpenServer");
|
|
}
|
|
},
|
|
// 关闭
|
|
onDisable: function onDisable() {},
|
|
// 跳转指定标签
|
|
jumpToMenu: function jumpToMenu(_camp_id) {
|
|
if (_camp_id === void 0) {
|
|
_camp_id = 0;
|
|
}
|
|
// 默认页
|
|
var order = 0;
|
|
for (var i = 0; i < this.menus.length; ++i) {
|
|
var t = this.menus[i];
|
|
if (t && t.camp_id == _camp_id) {
|
|
order = i;
|
|
break;
|
|
}
|
|
}
|
|
this.onSelectMenu({
|
|
index: order,
|
|
mdata: this.menus[order]
|
|
});
|
|
},
|
|
// 菜单切换
|
|
onSelectMenu: function onSelectMenu(_item) {
|
|
var _this2 = this;
|
|
if (!_item.mdata) {
|
|
return;
|
|
}
|
|
// 聚焦
|
|
this.lstMenu.cleanFocus();
|
|
this.lstMenu.addFocus(_item.index);
|
|
var self = this;
|
|
var focus = function focus(_name) {
|
|
var chds = self.nodContent.children;
|
|
chds.forEach(function (_page) {
|
|
_page.active = _page.name == _name;
|
|
});
|
|
};
|
|
var key = "P" + _item.mdata.camp_id;
|
|
var page = nx.gui.find(this.nodContent, key);
|
|
if (page) {
|
|
focus(key);
|
|
return;
|
|
}
|
|
|
|
// 加载
|
|
var mod = ActDefine.ActsMods[_item.mdata.source];
|
|
if (!mod) {
|
|
nx.error("$Acts:无效活动页:", _item.mdata.source);
|
|
return;
|
|
}
|
|
var path = cc.path.join("prefab/acts", mod.prefab);
|
|
nx.res.loadPrefab(path, function (_err, _data) {
|
|
if (_err) {
|
|
return;
|
|
}
|
|
var node = cc.instantiate(_data);
|
|
var cmp = node.getComponent("act.page.base");
|
|
if (cmp) {
|
|
cmp.actRoot = _this2;
|
|
cmp.build(_item.mdata);
|
|
}
|
|
node.name = key;
|
|
node.parent = _this2.nodContent;
|
|
focus(key);
|
|
});
|
|
}
|
|
});
|
|
|
|
cc._RF.pop(); |