|
@@ -1,4 +1,4 @@
|
|
|
-import { sys, tween, Tween, _decorator, Label, EditBox,Node } from 'cc';
|
|
|
+import { sys, tween, Tween, _decorator, Label, EditBox, Node } from 'cc';
|
|
|
import { UIHelper } from '../../../framework/common/UIHelper';
|
|
|
import { AudioID } from '../../../framework/config/AudioConf';
|
|
|
import { FrameworkConf } from '../../../framework/config/FrameworkConf';
|
|
@@ -9,6 +9,8 @@ import { AsyncQueue, NextFunction } from '../../../framework/queue/AsyncQueue';
|
|
|
import { BulletlPool, DecoratePool, FloatTextPool, GoodsPool, IconPool, MaterialPool, PopPool, RewardPool, RolePool, TipsPool } from '../../common/Pool';
|
|
|
import { UserData } from '../../data/UserData';
|
|
|
import { LoginMgr } from '../../common/LoginManager';
|
|
|
+import { StringUtil } from '../../../framework/util/StringUtil';
|
|
|
+import { GameEvent } from '../../data/GameEvent';
|
|
|
|
|
|
const { ccclass, property } = _decorator;
|
|
|
|
|
@@ -16,15 +18,15 @@ const { ccclass, property } = _decorator;
|
|
|
|
|
|
|
|
|
export function getParameterByName(name) {
|
|
|
- let url = window.location.href;
|
|
|
- name = name.replace(/[\[\]]/g, "\\$&");
|
|
|
- const regex = new RegExp(`[?&]${name}(=([^&#]*)|&|#|$)`);
|
|
|
- const results = regex.exec(url);
|
|
|
- if (!results) return null;
|
|
|
- if (!results[2]) return '';
|
|
|
-
|
|
|
- return decodeURIComponent(results[2].replace(/\+/g, ' '));
|
|
|
- //return results[2].replace(/\+/g, ' ')
|
|
|
+ let url = window.location.href;
|
|
|
+ name = name.replace(/[\[\]]/g, "\\$&");
|
|
|
+ const regex = new RegExp(`[?&]${name}(=([^&#]*)|&|#|$)`);
|
|
|
+ const results = regex.exec(url);
|
|
|
+ if (!results) return null;
|
|
|
+ if (!results[2]) return '';
|
|
|
+
|
|
|
+ return decodeURIComponent(results[2].replace(/\+/g, ' '));
|
|
|
+ //return results[2].replace(/\+/g, ' ')
|
|
|
}
|
|
|
|
|
|
@ccclass('LoginUI')
|
|
@@ -33,26 +35,26 @@ export class LoginUI extends BaseView {
|
|
|
@property(Node)
|
|
|
loginRoot: Node = null;
|
|
|
|
|
|
- @property({type:Label,tooltip:"版本"})
|
|
|
+ @property({ type: Label, tooltip: "版本" })
|
|
|
version: Label = null;
|
|
|
|
|
|
@property(Node)
|
|
|
selectServer: Node = null;
|
|
|
- @property({type:Label,tooltip:"ServerName"})
|
|
|
+ @property({ type: Label, tooltip: "ServerName" })
|
|
|
serverName: Label = null;
|
|
|
- @property({type:Label,tooltip:"服务器状态"})
|
|
|
- serverState:Label = null;
|
|
|
+ @property({ type: Label, tooltip: "服务器状态" })
|
|
|
+ serverState: Label = null;
|
|
|
|
|
|
|
|
|
- @property({type:EditBox,tooltip:"账号"})
|
|
|
+ @property({ type: EditBox, tooltip: "账号" })
|
|
|
userName: EditBox = null;
|
|
|
|
|
|
private scene_back = null;
|
|
|
|
|
|
//登录数据
|
|
|
- private loginData:any = null
|
|
|
+ private loginData: any = null
|
|
|
+ accountData: any;
|
|
|
serverData: any;
|
|
|
- server_list: any;
|
|
|
protected onLoad() {
|
|
|
super.onLoad();
|
|
|
this._initPool();
|
|
@@ -78,20 +80,24 @@ export class LoginUI extends BaseView {
|
|
|
// }
|
|
|
// }
|
|
|
}, this);
|
|
|
+ Framework.event.addEvent(GameEvent.SelectServer, () => {
|
|
|
+ this.updateCurServer(true);
|
|
|
+ }, this);
|
|
|
+
|
|
|
Framework.audio.playMusic(AudioID.Game);
|
|
|
-
|
|
|
+
|
|
|
let uid = UserData.save_locally('UserID')
|
|
|
let choose_server = UserData.save_locally('choose_server', null, {})
|
|
|
|
|
|
this.loginData = {
|
|
|
- url:getParameterByName("url") ||"http://118.178.135.110/sdk/debug/login.php",
|
|
|
- uid:getParameterByName("uid") || uid ||"ttq3",
|
|
|
- token:getParameterByName("token"),
|
|
|
+ url: getParameterByName("url") || "http://118.178.135.110/sdk/debug/login.php",
|
|
|
+ uid: getParameterByName("uid") || uid || "ttq3",
|
|
|
+ token: getParameterByName("token"),
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
// this.server_list.push(choose_server)
|
|
|
-
|
|
|
+
|
|
|
this.userName.string = this.loginData.uid
|
|
|
// this.serverName.string = "997"
|
|
|
}
|
|
@@ -144,22 +150,21 @@ export class LoginUI extends BaseView {
|
|
|
this.loginData.uid = this.userName.string
|
|
|
UserData.save_locally('UserID', this.loginData.uid)
|
|
|
this.getServerList()
|
|
|
-
|
|
|
}
|
|
|
- onEnter(){
|
|
|
+ onEnter() {
|
|
|
let _gateway_data = {
|
|
|
- openid: this.serverData.openid, //上面获取到的openid
|
|
|
- openkey: this.serverData.openkey, //上面获取到的openkey
|
|
|
- sid: this.server_list.id, // 选择的服务器列表信息中的id
|
|
|
+ openid: this.accountData.openId, //上面获取到的openid
|
|
|
+ openkey: this.accountData.openKey, //上面获取到的openkey
|
|
|
+ sid: this.serverData.sid, // 选择的服务器列表信息中的id
|
|
|
}
|
|
|
|
|
|
- LoginMgr.getGateway(_gateway_data, this.server_list.host, () => {
|
|
|
+ LoginMgr.getGateway(_gateway_data, this.serverData.host, () => {
|
|
|
if (UserData['mark'].first_login && UserData['mark'].first_login == 1) {
|
|
|
|
|
|
- Framework.layer.open(ViewID.MainUI, () => {
|
|
|
- Framework.layer.close(ViewID.LoginUI);
|
|
|
- Framework.layer.close(ViewID.SelectServer);
|
|
|
- });
|
|
|
+ Framework.layer.open(ViewID.MainUI, () => {
|
|
|
+ Framework.layer.close(ViewID.LoginUI);
|
|
|
+ Framework.layer.close(ViewID.SelectServer);
|
|
|
+ });
|
|
|
|
|
|
} else {
|
|
|
Framework.layer.open(ViewID.MainUI, () => {
|
|
@@ -168,7 +173,7 @@ export class LoginUI extends BaseView {
|
|
|
});
|
|
|
}
|
|
|
})
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
//
|
|
@@ -180,7 +185,7 @@ export class LoginUI extends BaseView {
|
|
|
// Framework.tips.setTips(`${match}是敏感词`);
|
|
|
// return;
|
|
|
// }
|
|
|
-
|
|
|
+
|
|
|
// } else {
|
|
|
// Framework.tips.setTips('账号只能输入英文和数字并且不可为空!');
|
|
|
// }
|
|
@@ -192,12 +197,9 @@ export class LoginUI extends BaseView {
|
|
|
private onTouchButton(event: Event) {
|
|
|
|
|
|
let target: any = event.target;
|
|
|
-
|
|
|
- // LoginMgr.getServerList(1, (data) => {
|
|
|
- // // Framework.layer.close(this);
|
|
|
- // Framework.layer.open(ViewID.ServerList,null,data)
|
|
|
- // })
|
|
|
- return;
|
|
|
+ if (target.name == 'select_server') {
|
|
|
+ Framework.layer.open(ViewID.SelectServer)
|
|
|
+ }
|
|
|
}
|
|
|
private _enterGame(state: number) {
|
|
|
// if (UserData.player.uuid == "") {
|
|
@@ -299,7 +301,7 @@ export class LoginUI extends BaseView {
|
|
|
|
|
|
// queue.complete = () => {
|
|
|
// };
|
|
|
-
|
|
|
+
|
|
|
// queue.play();
|
|
|
this._loginEx();
|
|
|
}
|
|
@@ -308,26 +310,62 @@ export class LoginUI extends BaseView {
|
|
|
private getServerList() {
|
|
|
LoginMgr.getServerList((data) => {
|
|
|
if (data) {
|
|
|
- this.serverData = data;
|
|
|
- let num = 0;
|
|
|
- let idx = 1;
|
|
|
- this.server_list = data.server_list[998]
|
|
|
-
|
|
|
- this.loginRoot.active = false
|
|
|
- this.selectServer.active = true
|
|
|
-
|
|
|
- // if (Object.keys(this.server_list[0]).length < 1) {
|
|
|
- // let idx = this.server_list.length - 1
|
|
|
- // let choosePic = this.Node.serverTab.getChildByName(this.tabulation).getComponent(Sprite).spriteFrame;
|
|
|
- // this.Node.serverTab.getChildByName(this.tabulation).getComponent(Sprite).spriteFrame = this.Node.serverTab.getChildByName(String(idx * 10)).getComponent(Sprite).spriteFrame;
|
|
|
- // this.Node.serverTab.getChildByName(String(idx * 10)).getComponent(Sprite).spriteFrame = choosePic;
|
|
|
- // this.tabulation = String(idx * 10);
|
|
|
- // this.List.server.numItems = this.server_list[idx].length
|
|
|
- // } else {
|
|
|
- // this.List.server.numItems = 0;
|
|
|
- // }
|
|
|
+ UserData.parseLoginData(data);
|
|
|
+ this.accountData = UserData.getAccountData()
|
|
|
+ this.updateCurServer()
|
|
|
}
|
|
|
}, this.loginData)
|
|
|
}
|
|
|
+
|
|
|
+ updateCurServer(isRefresh?:boolean) {
|
|
|
+ let sid = -1;
|
|
|
+ if (isRefresh){
|
|
|
+ sid = UserData.getSid();
|
|
|
+ }
|
|
|
+ if (sid == -1) {
|
|
|
+ const roles = UserData.getRoleServers();
|
|
|
+ if (roles.length === 0) {
|
|
|
+ // 无角色,寻找推荐服务器
|
|
|
+ const recmds = UserData.getRecmdServers();
|
|
|
+ for (const v of recmds) {
|
|
|
+ if (v && v.sid) {
|
|
|
+ sid = v.sid;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 找最近登录的服务器,roles 已排序,第一个是最近的
|
|
|
+ for (const v of roles) {
|
|
|
+ if (v && v.sid) {
|
|
|
+ sid = v.sid;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ let serverData = UserData.getServerBySid(sid)
|
|
|
+ if (!serverData) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ this.serverData = serverData;
|
|
|
+ UserData.setSid(serverData['sid'], false);
|
|
|
+
|
|
|
+ this.serverName.string = serverData.name;
|
|
|
+
|
|
|
+ if (serverData.status == 0) {
|
|
|
+ this.serverState.string = StringUtil.getLanguageData('维护');
|
|
|
+ }else if(serverData.status == 1){
|
|
|
+ this.serverState.string = StringUtil.getLanguageData('爆满');
|
|
|
+ }else if(serverData.status == 2){
|
|
|
+ this.serverState.string = StringUtil.getLanguageData('推荐');
|
|
|
+ }
|
|
|
+
|
|
|
+ this.loginRoot.active = false
|
|
|
+ this.selectServer.active = true
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|