|
|
@@ -65,7 +65,7 @@ export class LoginData {
|
|
|
* @description initApp-->initAd-->connect-->wxLogin-->checkLogin-->getAccountInfo
|
|
|
*/
|
|
|
public async login() {
|
|
|
-
|
|
|
+ mk.console.logSingle("login...", this.sessionKey + "..." + this.uin);
|
|
|
//有登录记录直接跳转到登录流程最后一步
|
|
|
if (this.sessionKey != '' && this.uin != '') {
|
|
|
console.log("=== login 有登录记录直接跳转到登录流程最后一步");
|
|
|
@@ -97,7 +97,7 @@ export class LoginData {
|
|
|
return;
|
|
|
}
|
|
|
data = mk.encrypt.decrypt(response.encrypt, this.randomKey, gData.appData.appId);
|
|
|
- console.log("[FC]connectTest decryptData", data);
|
|
|
+ mk.console.logSingle("[FC]connectTest decryptData", data);
|
|
|
this.tempUin = JSON.parse(data).tmp_uin;
|
|
|
mk.storage.setStorage(StorageKey.uin, this.tempUin);
|
|
|
this.wxLogin();
|
|
|
@@ -139,7 +139,7 @@ export class LoginData {
|
|
|
}
|
|
|
data = JSON.parse(data);
|
|
|
this.loginTicket = data.login_ticket;
|
|
|
- console.log("[FC]wxLoginTest decrypt", data);
|
|
|
+ mk.console.logSingle("[FC]wxLogin decrypt", data);
|
|
|
mk.storage.setStorage(StorageKey.loginTicket, this.loginTicket);
|
|
|
|
|
|
let isFirstIn = mk.storage.getStorage(StorageKey.isFirstIn);
|
|
|
@@ -193,13 +193,13 @@ export class LoginData {
|
|
|
|
|
|
let parseData = JSON.parse(decryptData);
|
|
|
this.sessionKey = parseData.session_key;
|
|
|
- console.log("[FC]checkLogin decrypt", parseData);
|
|
|
+ mk.console.logSingle("[FC]checkLogin decrypt", parseData);
|
|
|
mk.storage.setStorage(StorageKey.sessionKey, this.sessionKey);
|
|
|
this.getUserInfo();
|
|
|
}
|
|
|
|
|
|
private async getUserInfo() {
|
|
|
-
|
|
|
+
|
|
|
// if (gData.wechatData.code != null) {
|
|
|
// if (this.isNew) {//玩过此游戏并且本地数据是本机的
|
|
|
// this.getAccountInfo();
|
|
|
@@ -223,37 +223,37 @@ export class LoginData {
|
|
|
// gData.wechatData.nickName = nickname;
|
|
|
// }
|
|
|
// else {
|
|
|
- let aa = {
|
|
|
- "uin": this.uin,
|
|
|
- "login_ticket": this.loginTicket
|
|
|
- };
|
|
|
+ let aa = {
|
|
|
+ "uin": this.uin,
|
|
|
+ "login_ticket": this.loginTicket
|
|
|
+ };
|
|
|
|
|
|
- let data: any = {
|
|
|
- "uin": this.uin,
|
|
|
- "encrypt": mk.encrypt.encrypt(JSON.stringify(aa), this.sessionKey, gData.appData.appId)
|
|
|
- };
|
|
|
+ let data: any = {
|
|
|
+ "uin": this.uin,
|
|
|
+ "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);
|
|
|
- if (response.errcode != 0) {
|
|
|
- if (response.errcode == -10003 || response.errcode == -20003) {
|
|
|
- //清除缓存
|
|
|
- this.reload();
|
|
|
- }
|
|
|
- return;
|
|
|
- }
|
|
|
- response = mk.http.checkData(response, true);
|
|
|
- data = response.data;
|
|
|
- mk.console.logSingle("[FC] getAccountInfo decrypt", data);
|
|
|
- this.isAuth = data.is_auth;
|
|
|
- if (this.isAuth) {
|
|
|
- gData.wechatData.nickName = data.nickname;
|
|
|
- gData.wechatData.avatar = data.headimgurl;
|
|
|
- gData.wechatData.unionid = this.uin;
|
|
|
- gData.gameData.init_head = true;
|
|
|
- mk.storage.setStorage(StorageKey.isAuth, 1);
|
|
|
- mk.storage.setStorage(StorageKey.nickname, gData.wechatData.nickName, false);
|
|
|
- mk.storage.setStorage(StorageKey.avatar, gData.wechatData.avatar, false);
|
|
|
+ let response = await mk.http.sendRequest('user', 'POST', JSON.stringify(data), false, false);
|
|
|
+ if (response.errcode != 0) {
|
|
|
+ if (response.errcode == -10003 || response.errcode == -20003) {
|
|
|
+ //清除缓存
|
|
|
+ this.reload();
|
|
|
}
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ response = mk.http.checkData(response, true);
|
|
|
+ data = response.data;
|
|
|
+ mk.console.logSingle("[FC] getAccountInfo decrypt", data);
|
|
|
+ this.isAuth = data.is_auth;
|
|
|
+ if (this.isAuth) {
|
|
|
+ gData.wechatData.nickName = data.nickname;
|
|
|
+ gData.wechatData.avatar = data.headimgurl;
|
|
|
+ gData.wechatData.unionid = this.uin;
|
|
|
+ gData.gameData.init_head = true;
|
|
|
+ mk.storage.setStorage(StorageKey.isAuth, 1);
|
|
|
+ mk.storage.setStorage(StorageKey.nickname, gData.wechatData.nickName, false);
|
|
|
+ mk.storage.setStorage(StorageKey.avatar, gData.wechatData.avatar, false);
|
|
|
+ }
|
|
|
|
|
|
// }
|
|
|
|