diff --git a/assets/Scripts/Sub/UI/PreloadUI.ts b/assets/Scripts/Sub/UI/PreloadUI.ts index 6b79e882..b1d8be8e 100644 --- a/assets/Scripts/Sub/UI/PreloadUI.ts +++ b/assets/Scripts/Sub/UI/PreloadUI.ts @@ -260,12 +260,12 @@ export class PreloadUI extends Component { // 游客登录 const deviceId = DeviceIdService.I.id; - const machineIdentifier = MachineInfoService.I.getMachineIdentifier(); + const os = MachineInfoService.I.getMachineOs(); const reqData = { platType: 'guset', userId: deviceId, device: deviceId, - os: 3, + os, }; console.log("登录请求数据:", reqData); let res = await AuthService.I.login(reqData); @@ -285,8 +285,8 @@ export class PreloadUI extends Component { envData.cdn = resData.cdn; this.loginFinish = true; - - // this.reqMyInfo(); + // 请求个人信息 + this.reqMyInfo(); }; } @@ -295,7 +295,6 @@ export class PreloadUI extends Component { const reqData = { }; - console.log("个人信息请求数据:", reqData); let res = await PlayerDataService.I.reqMyInfo(reqData); console.log("个人信息响应数据:", res); if (res && res.code === proto.cs.EnmRetCode.SUCCESS) { diff --git a/assets/Scripts/chat18x/data/WalletData.ts b/assets/Scripts/chat18x/data/WalletData.ts index 85867c29..6aa46cd9 100644 --- a/assets/Scripts/chat18x/data/WalletData.ts +++ b/assets/Scripts/chat18x/data/WalletData.ts @@ -5,9 +5,9 @@ import { BaseData } from "./BaseData"; export class WalletData extends BaseData { // 余额 - private _balance = 0; + private _balance: number = 0; // vip失效时间戳 - private _vipExpire = 0; + private _vipExpire: number = 0; public reset(): void { this._balance = 0; diff --git a/assets/Scripts/chat18x/foundation/identity/MachineInfoService.ts b/assets/Scripts/chat18x/foundation/identity/MachineInfoService.ts index 8d65abdb..423e7d45 100644 --- a/assets/Scripts/chat18x/foundation/identity/MachineInfoService.ts +++ b/assets/Scripts/chat18x/foundation/identity/MachineInfoService.ts @@ -108,6 +108,24 @@ export class MachineInfoService { if (s.length > 64) s = s.slice(0, 64); return s || "Unknown"; } + + /** 获取机器系统标识 1: android 2:ios; 3: windows */ + public getMachineOs(): number { + if (EDITOR) { + return 3; // 在 Cocos Creator 编辑器里运行 + } + + if (sys.platform === sys.Platform.ANDROID) { + return 1; + } + if (sys.platform === sys.Platform.IOS) { + return 2; + } + if (sys.platform === sys.Platform.WIN32) { + return 3; + } + return 3; + } } export default MachineInfoService; diff --git a/assets/Scripts/chat18x/network/client/ApiClient.ts b/assets/Scripts/chat18x/network/client/ApiClient.ts index b23a2346..d4f9a5f4 100644 --- a/assets/Scripts/chat18x/network/client/ApiClient.ts +++ b/assets/Scripts/chat18x/network/client/ApiClient.ts @@ -25,9 +25,8 @@ export class ApiClient { let jsonData: any; if (ep.needsAuth && this.token) { - headers["Authorization"] = `Bearer ${this.token}`; + headers["Authorization"] = `${this.token}`; } - // 编码 if (ep.codec === "json") { jsonData = (ep.method === "GET") ? req : JsonCodec.encode(req);