玩家数据
This commit is contained in:
@@ -33,11 +33,10 @@ import { NetTimeData } from "../../chat18x/data/NetTimeData";
|
|||||||
import ConfigManager from "../../chat18x/manager/ConfigManager";
|
import ConfigManager from "../../chat18x/manager/ConfigManager";
|
||||||
import { AppConfig } from "db://assets/Scripts/chat18x/config/env/appConfig";
|
import { AppConfig } from "db://assets/Scripts/chat18x/config/env/appConfig";
|
||||||
import DeviceIdService from "db://assets/Scripts/chat18x/foundation/identity/DeviceIdService";
|
import DeviceIdService from "db://assets/Scripts/chat18x/foundation/identity/DeviceIdService";
|
||||||
import { AuthService } from "db://assets/Scripts/chat18x/network/services/AuthService";
|
|
||||||
import { ApiCode } from "db://assets/Scripts/chat18x/network/client/types";
|
|
||||||
|
|
||||||
import MachineInfoService from "db://assets/Scripts/chat18x/foundation/identity/MachineInfoService";
|
import MachineInfoService from "db://assets/Scripts/chat18x/foundation/identity/MachineInfoService";
|
||||||
|
import { AuthService } from "db://assets/Scripts/chat18x/network/services/AuthService";
|
||||||
|
import { PlayerDataService } from "db://assets/Scripts/chat18x/network/services/PlayerDataService";
|
||||||
|
import { ApiCode } from "db://assets/Scripts/chat18x/network/client/types";
|
||||||
|
|
||||||
const { ccclass, property } = _decorator;
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
@@ -295,9 +294,26 @@ export class PreloadUI extends Component {
|
|||||||
netTimeData.timezoneOffset = resData.TimezoneOffset;
|
netTimeData.timezoneOffset = resData.TimezoneOffset;
|
||||||
|
|
||||||
this.loginFinish = true;
|
this.loginFinish = true;
|
||||||
|
|
||||||
|
// this.reqPlayerData();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 请求玩家数据
|
||||||
|
private async reqPlayerData() {
|
||||||
|
const reqData = {
|
||||||
|
GameName: ConfigManager.tables.TbGlobalConfig.GameName,
|
||||||
|
IsAll: true,
|
||||||
|
DataFlagList: [],
|
||||||
|
};
|
||||||
|
console.log("玩家数据请求数据:", reqData);
|
||||||
|
let res = await PlayerDataService.I.reqQueryPlayerData(reqData);
|
||||||
|
console.log("玩家数据响应数据:", res);
|
||||||
|
if (res && res.code === ApiCode.OK) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
enterGame() {
|
enterGame() {
|
||||||
//let islogin = HttpUnit.IsLogin();
|
//let islogin = HttpUnit.IsLogin();
|
||||||
//console.log("进入游戏,登录状态:", islogin);
|
//console.log("进入游戏,登录状态:", islogin);
|
||||||
|
|||||||
@@ -13,12 +13,12 @@ export class AuthService {
|
|||||||
|
|
||||||
// 登录
|
// 登录
|
||||||
public async login(req: proto.ProtoMsg.ILoginReq): Promise<ApiResponse<proto.ProtoMsg.ILoginRsp>> {
|
public async login(req: proto.ProtoMsg.ILoginReq): Promise<ApiResponse<proto.ProtoMsg.ILoginRsp>> {
|
||||||
let EP_LOGIN: Endpoint<proto.ProtoMsg.ILoginReq, proto.ProtoMsg.ILoginRsp> = {
|
let epData: Endpoint<proto.ProtoMsg.ILoginReq, proto.ProtoMsg.ILoginRsp> = {
|
||||||
path: "login",
|
path: "login",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
codec: "json",
|
codec: "json",
|
||||||
needsAuth: false
|
needsAuth: false
|
||||||
};
|
};
|
||||||
return this.api.call(EP_LOGIN, req);
|
return this.api.call(epData, req);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
import { ApiClient } from "../client/ApiClient";
|
||||||
|
import type { Endpoint } from "../client/endpoints";
|
||||||
|
import type { ApiResponse } from "../client/types";
|
||||||
|
import proto from 'db://assets/Scripts/proto/proto.pb.js';
|
||||||
|
|
||||||
|
export class PlayerDataService {
|
||||||
|
private static _I: PlayerDataService | null = null;
|
||||||
|
public static get I(): PlayerDataService {
|
||||||
|
if (!PlayerDataService._I) PlayerDataService._I = new PlayerDataService();
|
||||||
|
return PlayerDataService._I;
|
||||||
|
}
|
||||||
|
private constructor(private api = ApiClient.I) {}
|
||||||
|
|
||||||
|
// 拉取玩家数据
|
||||||
|
public async reqQueryPlayerData(req: proto.ProtoMsg.IQueryPlayerDataReq): Promise<ApiResponse<proto.ProtoMsg.IQueryPlayerDataRsp>> {
|
||||||
|
let epData: Endpoint<proto.ProtoMsg.IQueryPlayerDataReq, proto.ProtoMsg.IQueryPlayerDataRsp> = {
|
||||||
|
path: "playerdata/query_player_data",
|
||||||
|
method: "POST",
|
||||||
|
codec: "json",
|
||||||
|
needsAuth: true
|
||||||
|
};
|
||||||
|
return this.api.call(epData, req);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 保存玩家数据
|
||||||
|
public async reqSavePlayerData(req: proto.ProtoMsg.ISavePlayerDataReq): Promise<ApiResponse<proto.ProtoMsg.ISavePlayerDataRsp>> {
|
||||||
|
let epData: Endpoint<proto.ProtoMsg.ISavePlayerDataReq, proto.ProtoMsg.ISavePlayerDataRsp> = {
|
||||||
|
path: "playerdata/save_player_data",
|
||||||
|
method: "POST",
|
||||||
|
codec: "json",
|
||||||
|
needsAuth: true
|
||||||
|
};
|
||||||
|
return this.api.call(epData, req);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ver": "4.0.24",
|
||||||
|
"importer": "typescript",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "e651acda-1f16-4ceb-88e4-be892c13a248",
|
||||||
|
"files": [],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user