|
|
@@ -44,8 +44,8 @@ export class LoginData {
|
|
|
*/
|
|
|
public async login() {
|
|
|
this.isLogin = true;
|
|
|
- g.appData.init();
|
|
|
- g.adData.init();
|
|
|
+ gData.appData.init();
|
|
|
+ gData.adData.init();
|
|
|
|
|
|
//有登录记录直接跳转到登录流程最后一步
|
|
|
if (this.sessionKey != '' && this.uin != '') {
|
|
|
@@ -55,9 +55,9 @@ export class LoginData {
|
|
|
|
|
|
let ranKey = mk.encrypt.randomString();
|
|
|
let data: any = {
|
|
|
- "mac": g.appData.mac,
|
|
|
+ "mac": gData.appData.mac,
|
|
|
"psk": ranKey,
|
|
|
- "appId": g.appData.appId
|
|
|
+ "appId": gData.appData.appId
|
|
|
}
|
|
|
|
|
|
//connect
|
|
|
@@ -65,20 +65,20 @@ export class LoginData {
|
|
|
if (response.errcode != 0) {
|
|
|
return;
|
|
|
}
|
|
|
- data = mk.encrypt.decrypt(response.encrypt, ranKey, g.appData.appId);
|
|
|
+ data = mk.encrypt.decrypt(response.encrypt, ranKey, gData.appData.appId);
|
|
|
this.tempUin = JSON.parse(data).tmp_uin;
|
|
|
|
|
|
//wxLogin
|
|
|
let encode;
|
|
|
- if (g.wechatData.code != null) {//微信登录
|
|
|
- encode = mk.encrypt.encrypt(JSON.stringify({ "code": g.wechatData.code }), this.sessionKey, g.appData.appId);
|
|
|
+ if (gData.wechatData.code != null) {//微信登录
|
|
|
+ encode = mk.encrypt.encrypt(JSON.stringify({ "code": gData.wechatData.code }), this.sessionKey, gData.appData.appId);
|
|
|
data = {
|
|
|
"uin": this.uin,
|
|
|
"encrypt": encode
|
|
|
};
|
|
|
}
|
|
|
else {//游客登录
|
|
|
- encode = mk.encrypt.encrypt(JSON.stringify({ "code": g.wechatData.code }), ranKey, g.appData.appId);
|
|
|
+ encode = mk.encrypt.encrypt(JSON.stringify({ "code": gData.wechatData.code }), ranKey, gData.appData.appId);
|
|
|
data = {
|
|
|
"uin": this.tempUin,
|
|
|
"encrypt": encode
|
|
|
@@ -88,11 +88,11 @@ export class LoginData {
|
|
|
if (response.errcode != 0) {
|
|
|
return;
|
|
|
}
|
|
|
- if (g.wechatData.code != null) {
|
|
|
- data = mk.encrypt.decrypt(response.encrypt, this.sessionKey, g.appData.appId);
|
|
|
+ if (gData.wechatData.code != null) {
|
|
|
+ data = mk.encrypt.decrypt(response.encrypt, this.sessionKey, gData.appData.appId);
|
|
|
}
|
|
|
else {
|
|
|
- data = mk.encrypt.decrypt(response.encrypt, ranKey, g.appData.appId);
|
|
|
+ data = mk.encrypt.decrypt(response.encrypt, ranKey, gData.appData.appId);
|
|
|
}
|
|
|
data = JSON.parse(data);
|
|
|
this.loginTicket = data.login_ticket;
|
|
|
@@ -115,7 +115,7 @@ export class LoginData {
|
|
|
|
|
|
//checkLogin
|
|
|
let tmp_key = '';
|
|
|
- if (g.wechatData.code != null) {
|
|
|
+ if (gData.wechatData.code != null) {
|
|
|
tmp_key = this.sessionKey;
|
|
|
}
|
|
|
else {
|
|
|
@@ -126,17 +126,17 @@ export class LoginData {
|
|
|
"tmp_key": tmp_key,
|
|
|
"uin": this.uin,
|
|
|
"login_ticket": this.loginTicket,
|
|
|
- "appId": g.appData.appId
|
|
|
+ "appId": gData.appData.appId
|
|
|
}
|
|
|
response = await mk.http.sendRequest('checklogin', 'POST', JSON.stringify(data));
|
|
|
if (response.errcode != 0) {
|
|
|
return;
|
|
|
}
|
|
|
- if (g.wechatData.code != null) {
|
|
|
- data = mk.encrypt.decrypt(response.encrypt, this.sessionKey, g.appData.appId);
|
|
|
+ if (gData.wechatData.code != null) {
|
|
|
+ data = mk.encrypt.decrypt(response.encrypt, this.sessionKey, gData.appData.appId);
|
|
|
}
|
|
|
else {
|
|
|
- data = mk.encrypt.decrypt(response.encrypt, tmp_key, g.appData.appId);
|
|
|
+ data = mk.encrypt.decrypt(response.encrypt, tmp_key, gData.appData.appId);
|
|
|
}
|
|
|
|
|
|
data = JSON.parse(data);
|
|
|
@@ -144,13 +144,13 @@ export class LoginData {
|
|
|
|
|
|
mk.storage.setStorage('sessionKey', this.sessionKey);
|
|
|
|
|
|
- if (g.wechatData.code != null) {
|
|
|
+ if (gData.wechatData.code != null) {
|
|
|
if (this.isNew) {//玩过此游戏并且本地数据是本机的
|
|
|
this.getAccountInfo();
|
|
|
}
|
|
|
else {//玩过此游戏 但 本地数据不是本账户的 清空数据 重新登录游戏
|
|
|
this.isNew = false;
|
|
|
- g.wechatData.code = null;
|
|
|
+ gData.wechatData.code = null;
|
|
|
this.reload();
|
|
|
}
|
|
|
}
|
|
|
@@ -162,7 +162,7 @@ export class LoginData {
|
|
|
private async getAccountInfo() {
|
|
|
let nickname = mk.storage.getStorage(StorageKey.nickname);
|
|
|
if (nickname) {
|
|
|
- g.wechatData.nickName = nickname;
|
|
|
+ gData.wechatData.nickName = nickname;
|
|
|
}
|
|
|
else {
|
|
|
let aa = {
|
|
|
@@ -172,7 +172,7 @@ export class LoginData {
|
|
|
|
|
|
let data: any = {
|
|
|
"uin": this.uin,
|
|
|
- "encrypt": mk.encrypt.encrypt(JSON.stringify(aa), this.sessionKey, g.appData.appId)
|
|
|
+ "encrypt": mk.encrypt.encrypt(JSON.stringify(aa), this.sessionKey, gData.appData.appId)
|
|
|
};
|
|
|
|
|
|
let response = await mk.http.sendRequest('user', 'POST', JSON.stringify(data), false, false);
|
|
|
@@ -183,16 +183,16 @@ export class LoginData {
|
|
|
data = response.data;
|
|
|
this.isAuth = data.is_auth;
|
|
|
if (this.isAuth) {
|
|
|
- g.wechatData.nickName = data.nickname;
|
|
|
- g.wechatData.avatar = data.headimgurl;
|
|
|
+ gData.wechatData.nickName = data.nickname;
|
|
|
+ gData.wechatData.avatar = data.headimgurl;
|
|
|
mk.storage.setStorage(StorageKey.isAuth, 1);
|
|
|
- mk.storage.setStorage(StorageKey.nickname, g.wechatData.nickName, false);
|
|
|
- mk.storage.setStorage(StorageKey.avatar, g.wechatData.avatar, false);
|
|
|
+ mk.storage.setStorage(StorageKey.nickname, gData.wechatData.nickName, false);
|
|
|
+ mk.storage.setStorage(StorageKey.avatar, gData.wechatData.avatar, false);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//获取游戏数据
|
|
|
- g.gameData.init();
|
|
|
+ gData.gameData.init();
|
|
|
}
|
|
|
|
|
|
|