144 lines
3.4 KiB
JavaScript
144 lines
3.4 KiB
JavaScript
"use strict";
|
|
cc._RF.push(module, '9ff80s1A5JNyJCQH2jFANZu', 'scene.login');
|
|
// Scripts/mod/login/scene/scene.login.js
|
|
|
|
"use strict";
|
|
|
|
/******************************************************************
|
|
*
|
|
* 登录界面
|
|
*
|
|
******************************************************************/
|
|
|
|
var BridgeWindow = require("bridge.window");
|
|
var LoginMod = require("login.mod");
|
|
var CFG = require("config");
|
|
|
|
// 登录阶段
|
|
var PStage = cc.Enum({
|
|
None: 0,
|
|
User: 1,
|
|
// 输入界面
|
|
Start: 2,
|
|
// 开始游戏
|
|
Loading: 3 // 资产加载
|
|
});
|
|
|
|
cc.Class({
|
|
"extends": BridgeWindow,
|
|
properties: {
|
|
nodTheme: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
nodStart: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
nodUser: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
nodLoading: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
nodVideo: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
nodVideoH: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
spLoading: {
|
|
"default": null,
|
|
type: cc.Node
|
|
}
|
|
},
|
|
// 载入时按主题载入背景
|
|
onLoad: function onLoad() {
|
|
var _this = this;
|
|
this.spLoading.active = false;
|
|
var chnn = nx.bridge.vget("channelName");
|
|
var theme = CFG.Themes[chnn] || CFG.Themes["DEF"];
|
|
var path = cc.path.join("prefab/login/themes", theme, "fab_panel");
|
|
nx.res.loadPrefab(path, function (_err, _data) {
|
|
if (_err) {
|
|
return;
|
|
}
|
|
var node = cc.instantiate(_data);
|
|
node.parent = _this.nodTheme;
|
|
node.position = cc.v2(0, 0);
|
|
});
|
|
nx.storage.set("foreshow", null);
|
|
nx.storage.set("WndCampfightFinal", null);
|
|
nx.storage.set("CChampionPro", null);
|
|
nx.storage.set("battleArena", null);
|
|
},
|
|
// 显示
|
|
onEnable: function onEnable() {
|
|
// 全隐藏
|
|
this.changeSubPanel(PStage.None);
|
|
|
|
// 加载完成才隐藏初始界面和进度条
|
|
var splash = document.getElementById('splash');
|
|
if (splash) {
|
|
splash.style.display = 'none';
|
|
}
|
|
|
|
// 清理界面
|
|
nx.bridge.cleanPanels();
|
|
|
|
// 临时句柄(暂时)
|
|
nx.temp_login_wnd = this;
|
|
},
|
|
// 关闭
|
|
onDisable: function onDisable() {
|
|
// 临时句柄(暂时)
|
|
nx.temp_login_wnd = null;
|
|
},
|
|
// 重载:参数打开
|
|
onOpenConfigs: function onOpenConfigs(_params) {
|
|
this.changeSubPanel(PStage.User);
|
|
},
|
|
// 切换面板类型
|
|
changeSubPanel: function changeSubPanel(_st, _params) {
|
|
if (_st == PStage.User) {
|
|
this.nodUser.params = _params || {};
|
|
}
|
|
this.nodUser.active = _st == PStage.User;
|
|
this.nodStart.active = _st == PStage.Start;
|
|
|
|
// 载入进度条
|
|
if (_st == PStage.Loading) {
|
|
this.nodVideo.active = false;
|
|
this.nodVideoH.active = false;
|
|
this.spLoading.active = true;
|
|
this.nodLoading.opacity = 255;
|
|
var cmp = nx.gui.getComponent(this.nodLoading, "", "cmp.login.loading");
|
|
cmp.checkReady(true);
|
|
} else {
|
|
this.nodLoading.opacity = 0;
|
|
this.spLoading.active = false;
|
|
}
|
|
},
|
|
// 模拟账号验证通过(本地操作,尚未验证)
|
|
simAccountDone: function simAccountDone() {
|
|
// 获取服务器列表以及所有角色信息
|
|
var LC = LoginMod.getInstance();
|
|
var fetch = function fetch() {
|
|
LC.fetchServerRoles(function (_ret, _data) {
|
|
if (!_ret) {
|
|
nx.mbox(_data, ['retry'], function (_key, _box) {
|
|
_box.close();
|
|
fetch();
|
|
});
|
|
}
|
|
});
|
|
};
|
|
fetch();
|
|
}
|
|
});
|
|
|
|
cc._RF.pop(); |