协议调试

This commit is contained in:
chen wei bo
2025-09-09 00:33:29 +08:00
parent 2545aadcab
commit 8fbbca0e41
4 changed files with 25 additions and 9 deletions
+4 -5
View File
@@ -260,12 +260,12 @@ export class PreloadUI extends Component {
// 游客登录 // 游客登录
const deviceId = DeviceIdService.I.id; const deviceId = DeviceIdService.I.id;
const machineIdentifier = MachineInfoService.I.getMachineIdentifier(); const os = MachineInfoService.I.getMachineOs();
const reqData = { const reqData = {
platType: 'guset', platType: 'guset',
userId: deviceId, userId: deviceId,
device: deviceId, device: deviceId,
os: 3, os,
}; };
console.log("登录请求数据:", reqData); console.log("登录请求数据:", reqData);
let res = await AuthService.I.login(reqData); let res = await AuthService.I.login(reqData);
@@ -285,8 +285,8 @@ export class PreloadUI extends Component {
envData.cdn = resData.cdn; envData.cdn = resData.cdn;
this.loginFinish = true; this.loginFinish = true;
// 请求个人信息
// this.reqMyInfo(); this.reqMyInfo();
}; };
} }
@@ -295,7 +295,6 @@ export class PreloadUI extends Component {
const reqData = { const reqData = {
}; };
console.log("个人信息请求数据:", reqData);
let res = await PlayerDataService.I.reqMyInfo(reqData); let res = await PlayerDataService.I.reqMyInfo(reqData);
console.log("个人信息响应数据:", res); console.log("个人信息响应数据:", res);
if (res && res.code === proto.cs.EnmRetCode.SUCCESS) { if (res && res.code === proto.cs.EnmRetCode.SUCCESS) {
+2 -2
View File
@@ -5,9 +5,9 @@ import { BaseData } from "./BaseData";
export class WalletData extends BaseData { export class WalletData extends BaseData {
// 余额 // 余额
private _balance = 0; private _balance: number = 0;
// vip失效时间戳 // vip失效时间戳
private _vipExpire = 0; private _vipExpire: number = 0;
public reset(): void { public reset(): void {
this._balance = 0; this._balance = 0;
@@ -108,6 +108,24 @@ export class MachineInfoService {
if (s.length > 64) s = s.slice(0, 64); if (s.length > 64) s = s.slice(0, 64);
return s || "Unknown"; 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; export default MachineInfoService;
@@ -25,9 +25,8 @@ export class ApiClient {
let jsonData: any; let jsonData: any;
if (ep.needsAuth && this.token) { if (ep.needsAuth && this.token) {
headers["Authorization"] = `Bearer ${this.token}`; headers["Authorization"] = `${this.token}`;
} }
// 编码 // 编码
if (ep.codec === "json") { if (ep.codec === "json") {
jsonData = (ep.method === "GET") ? req : JsonCodec.encode(req); jsonData = (ep.method === "GET") ? req : JsonCodec.encode(req);