|
@@ -2,7 +2,7 @@ import { CHANGE_SECRETARY, COIN_CHANGE, DIAMOND_CHANGE, POWER_CHANGE, keyForLogi
|
|
|
import { xGame } from "../xGame";
|
|
|
import { GameData, ItemData, UserData, Diy2025GameData } from "./Data"
|
|
|
import { LocalStorageManager } from "../utils/LocalStorageManager";
|
|
|
-
|
|
|
+import UIMsg from "../ui/UIMsg";
|
|
|
//import { LocalStorageManager } from "../utils/LocalStorageManager";
|
|
|
|
|
|
export default class DataMgr {
|
|
@@ -347,7 +347,7 @@ export default class DataMgr {
|
|
|
}
|
|
|
this.userData.coin = val;
|
|
|
this.saveUserData();
|
|
|
- console.log('zh:通知更新金币变化'+val);
|
|
|
+ console.log('zh:通知更新金币变化' + val);
|
|
|
xGame.eventMgr.event(COIN_CHANGE);
|
|
|
}
|
|
|
|
|
@@ -399,7 +399,7 @@ export default class DataMgr {
|
|
|
}
|
|
|
this.userData.diamond = val;
|
|
|
this.saveUserData();
|
|
|
- console.log('zh:通知更新钻石变化'+val);
|
|
|
+ console.log('zh:通知更新钻石变化' + val);
|
|
|
xGame.eventMgr.event(DIAMOND_CHANGE);
|
|
|
}
|
|
|
|
|
@@ -808,7 +808,7 @@ export default class DataMgr {
|
|
|
let code = res.code;
|
|
|
let data = res.data;
|
|
|
if (code == 401) {
|
|
|
- Laya.LocalStorage.setItem(keyForLoginInfo, null);
|
|
|
+ Laya.LocalStorage.removeItem(keyForLoginInfo);
|
|
|
console.log('zh:保存资产信息失败,请重新登录 ')
|
|
|
//alert(TIP_MSG_key.pleaseLoginIn);
|
|
|
//import UIMsg from "./UIMsg";
|
|
@@ -833,13 +833,18 @@ export default class DataMgr {
|
|
|
|
|
|
/**
|
|
|
* 获取用户资产信息,此次应该会被经常调用,所以后期需要挪走到模块中
|
|
|
+ * @param winTip 如果发生错误或者异常是否显示提示信息
|
|
|
*
|
|
|
*/
|
|
|
- public static getUserZiChanInfo() {
|
|
|
- console.log('zh:开始获取用户资产信息');
|
|
|
+ public static getUserZiChanInfo(winTip: boolean = false) {
|
|
|
+ console.log('zh:getUserZCI');
|
|
|
const userInfoData = Laya.LocalStorage.getItem(keyForLoginInfo);
|
|
|
- if (userInfoData == null) {
|
|
|
- //alert('Please log in.');
|
|
|
+ console.log('zh:userInfoData=' + userInfoData)
|
|
|
+ if (userInfoData == null || userInfoData == "" || userInfoData === "null") {
|
|
|
+ if (winTip) {
|
|
|
+ xGame.uiMgr.Show(UIMsg, TIP_MSG_key.pleaseLoginIn);
|
|
|
+ }
|
|
|
+ Laya.LocalStorage.removeItem(keyForLoginInfo);
|
|
|
return;
|
|
|
}
|
|
|
let reqData = xGame.httpMgr.getReqData();
|
|
@@ -849,10 +854,10 @@ export default class DataMgr {
|
|
|
let code = res.code;
|
|
|
let msg = res.msg;
|
|
|
if (code == 401) {
|
|
|
- Laya.LocalStorage.setItem(keyForLoginInfo, null);
|
|
|
- alert(TIP_MSG_key.pleaseLoginIn);
|
|
|
- //import UIMsg from "./UIMsg";
|
|
|
- //xGame.uiMgr.Show(UIMsg, msg)
|
|
|
+ Laya.LocalStorage.removeItem(keyForLoginInfo);
|
|
|
+ if (winTip) {
|
|
|
+ xGame.uiMgr.Show(UIMsg, TIP_MSG_key.pleaseLoginIn);
|
|
|
+ }
|
|
|
return;
|
|
|
}
|
|
|
if (code == 200) {
|
|
@@ -873,15 +878,20 @@ export default class DataMgr {
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
- console.log("zh:更新用户资产信息error"+msg);
|
|
|
- alert(msg);
|
|
|
+ console.log("zh:更新用户资产信息error" + msg);
|
|
|
+ if (winTip) {
|
|
|
+ xGame.uiMgr.Show(UIMsg, msg);
|
|
|
+ }
|
|
|
}
|
|
|
// if (Laya.Browser.onAndroid) {
|
|
|
// JSBridgeUtils.instance.showToast2(msg);
|
|
|
// }
|
|
|
} catch (error) {
|
|
|
console.log('error=' + error);
|
|
|
- alert(error);
|
|
|
+ if (winTip) {
|
|
|
+ alert(error);
|
|
|
+ }
|
|
|
+
|
|
|
} finally {
|
|
|
console.log("zh:更新用户资产信息结束");
|
|
|
}
|
|
@@ -929,7 +939,7 @@ export default class DataMgr {
|
|
|
let code = res.code;
|
|
|
let msg = res.msg;
|
|
|
if (code == 401) {
|
|
|
- Laya.LocalStorage.setItem(keyForLoginInfo, null);
|
|
|
+ Laya.LocalStorage.removeItem(keyForLoginInfo);
|
|
|
// xGame.uiMgr.Show(UIMsg, TIP_MSG_key.pleaseLoginIn)
|
|
|
return;
|
|
|
}
|