登录响应数据
This commit is contained in:
@@ -25,7 +25,11 @@ import Utils from "../../Main/Common/Utils";
|
||||
import { InnerMsgCode } from "../../Main/Config/InnerMsgCode";
|
||||
import { promptItem } from "../Item/promptItem";
|
||||
import LanguageUtils, { LanguageType } from "../../Main/Common/LanguageUtils";
|
||||
import { DataManager } from "../../chat18x/data/DataManager";
|
||||
import { DataManager, DataId } from "../../chat18x/data/DataManager";
|
||||
import { LoginData } from "../../chat18x/data/LoginData";
|
||||
import { AccountData } from "../../chat18x/data/AccountData";
|
||||
import { MetaData } from "../../chat18x/data/MetaData";
|
||||
import { NetTimeData } from "../../chat18x/data/NetTimeData";
|
||||
import ConfigManager from "../../chat18x/manager/ConfigManager";
|
||||
import { AppConfig } from "db://assets/Scripts/chat18x/config/env/appConfig";
|
||||
import DeviceIdService from "db://assets/Scripts/chat18x/foundation/identity/DeviceIdService";
|
||||
@@ -259,6 +263,27 @@ export class PreloadUI extends Component {
|
||||
let res = await AuthService.I.login(reqData);
|
||||
console.log("登录响应数据:", res);
|
||||
if (res && res.code === ApiCode.OK) {
|
||||
const resData = res.data;
|
||||
// 保存数据
|
||||
const loginData = DataManager.I.getDataById<LoginData>(DataId.Login);
|
||||
loginData.operateType = resData.OperateType;
|
||||
loginData.token = resData.Token;
|
||||
loginData.ip = resData.Ip;
|
||||
loginData.machineIdentifier = resData.MachineIdentifier;
|
||||
loginData.sdkUid = resData.SdkUid;
|
||||
loginData.lastLoginTime = resData.LastLoginTime;
|
||||
const accountData = DataManager.I.getDataById<AccountData>(DataId.Account);
|
||||
accountData.identifier = resData.Identifier;
|
||||
accountData.identityType = resData.IdentityType;
|
||||
accountData.uid = resData.Uid;
|
||||
accountData.isNewGuide = resData.IsNewGuide;
|
||||
accountData.isNewRegist = resData.IsNewRegist;
|
||||
const metaData = DataManager.I.getDataById<MetaData>(DataId.Meta);
|
||||
metaData.gameName = resData.GameName;
|
||||
const netTimeData = DataManager.I.getDataById<NetTimeData>(DataId.NetTime);
|
||||
netTimeData.serverTime = resData.ServerTime;
|
||||
netTimeData.timezoneOffset = resData.TimezoneOffset;
|
||||
|
||||
this.loginFinish = true;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
/**
|
||||
* 账号数据
|
||||
*/
|
||||
import { BaseData } from "./BaseData";
|
||||
|
||||
export class AccountData extends BaseData {
|
||||
// 身份识别码,游客的话是设备号,googleplay用户的话是gp平台uid
|
||||
private _identifier = "";
|
||||
// 身份类型,1:游客;2:微信;3:googleplay
|
||||
private _identityType = 1;
|
||||
// 玩家Uid
|
||||
private _uid = "";
|
||||
// 是否新手
|
||||
private _isNewGuide = true;
|
||||
// 是否刚注册
|
||||
private _isNewRegist = true;
|
||||
|
||||
/** 设置身份识别码 */
|
||||
public set identifier(value: string) {
|
||||
this._identifier = value;
|
||||
}
|
||||
|
||||
/** 获取身份识别码 */
|
||||
public get identifier(): string {
|
||||
return this._identifier;
|
||||
}
|
||||
|
||||
/** 设置身份类型 */
|
||||
public set identityType(value: number) {
|
||||
this._identityType = value;
|
||||
}
|
||||
|
||||
/** 获取身份类型 */
|
||||
public get identityType(): number {
|
||||
return this._identityType;
|
||||
}
|
||||
|
||||
/** 设置玩家Uid */
|
||||
public set uid(value: string) {
|
||||
this._uid = value;
|
||||
}
|
||||
|
||||
/** 获取玩家Uid */
|
||||
public get uid(): string {
|
||||
return this._uid;
|
||||
}
|
||||
|
||||
/** 设置是否新手 */
|
||||
public set isNewGuide(value: boolean) {
|
||||
this._isNewGuide = value;
|
||||
}
|
||||
|
||||
/** 获取是否新手 */
|
||||
public get isNewGuide(): boolean {
|
||||
return this._isNewGuide;
|
||||
}
|
||||
|
||||
/** 设置是否刚注册 */
|
||||
public set isNewRegist(value: boolean) {
|
||||
this._isNewRegist = value;
|
||||
}
|
||||
|
||||
/** 获取是否刚注册 */
|
||||
public get isNewRegist(): boolean {
|
||||
return this._isNewRegist;
|
||||
}
|
||||
|
||||
public reset(): void {
|
||||
this._identifier = "";
|
||||
this._identityType = 1;
|
||||
this._uid = "";
|
||||
this._isNewGuide = true;
|
||||
this._isNewRegist = true;
|
||||
}
|
||||
|
||||
public clear(): void {
|
||||
this._identifier = "";
|
||||
this._identityType = 1;
|
||||
this._uid = "";
|
||||
this._isNewGuide = true;
|
||||
this._isNewRegist = true;
|
||||
}
|
||||
|
||||
public destroy(): void {
|
||||
super.destroy();
|
||||
this._identifier = null;
|
||||
this._identityType = null;
|
||||
this._uid = null;
|
||||
this._isNewGuide = null;
|
||||
this._isNewRegist = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "5cb88a47-644d-4592-a830-538b25d00e11",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -5,6 +5,9 @@
|
||||
import { BaseData } from "./BaseData";
|
||||
import { LoginData } from "./LoginData";
|
||||
import { PlayerData } from "./PlayerData";
|
||||
import { AccountData } from "./AccountData";
|
||||
import { MetaData } from "./MetaData";
|
||||
import { NetTimeData } from "./NetTimeData";
|
||||
|
||||
/**
|
||||
* 集中定义数据ID,避免写错字符串
|
||||
@@ -12,6 +15,9 @@ import { PlayerData } from "./PlayerData";
|
||||
export enum DataId {
|
||||
Login = "login",
|
||||
Player = "player",
|
||||
Account = "account",
|
||||
Meta = "meta",
|
||||
NetTime = "netTime",
|
||||
}
|
||||
|
||||
/** 构造器类型 */
|
||||
@@ -40,6 +46,9 @@ export class DataManager {
|
||||
|
||||
this.register(DataId.Login, LoginData);
|
||||
this.register(DataId.Player, PlayerData);
|
||||
this.register(DataId.Account, AccountData);
|
||||
this.register(DataId.Meta, MetaData);
|
||||
this.register(DataId.NetTime, NetTimeData);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,16 @@ export class LoginData extends BaseData {
|
||||
private _loginState = 0;
|
||||
// token
|
||||
private _token = "";
|
||||
// 操作类型,1:登录界面;2:断线重连;3:其他
|
||||
private _operateType = 1;
|
||||
// 公网IP
|
||||
private _ip = "";
|
||||
// 机器设备名
|
||||
private _machineIdentifier = "";
|
||||
// sdk体系的UID
|
||||
private _sdkUid = "";
|
||||
// 上次登陆时间
|
||||
private _lastLoginTime = "";
|
||||
|
||||
/**是否已登录成功 */
|
||||
public isLogin(): boolean {
|
||||
@@ -15,34 +25,103 @@ export class LoginData extends BaseData {
|
||||
}
|
||||
|
||||
/** 设置登录状态 */
|
||||
public setLoginState(state: number): void {
|
||||
this._loginState = state;
|
||||
public set loginState(value: number) {
|
||||
this._loginState = value;
|
||||
}
|
||||
|
||||
/** 获取登录状态 */
|
||||
public getLoginState(): number {
|
||||
public get loginState(): number {
|
||||
return this._loginState;
|
||||
}
|
||||
|
||||
/** 设置登录token */
|
||||
public setToken(token: string): void {
|
||||
this._token = token;
|
||||
public set token(value: string) {
|
||||
this._token = value;
|
||||
}
|
||||
|
||||
/** 获取登录token */
|
||||
public getToken(): string {
|
||||
public get token(): string {
|
||||
return this._token;
|
||||
}
|
||||
|
||||
/** 设置操作类型 */
|
||||
public set operateType(value: number) {
|
||||
this._operateType = value;
|
||||
}
|
||||
|
||||
/** 获取操作类型 */
|
||||
public get operateType(): number {
|
||||
return this._operateType;
|
||||
}
|
||||
|
||||
/** 设置ip */
|
||||
public set ip(value: string) {
|
||||
this._ip = value;
|
||||
}
|
||||
|
||||
/** 获取ip */
|
||||
public get ip(): string {
|
||||
return this._ip;
|
||||
}
|
||||
|
||||
/** 设置机器设备名 */
|
||||
public set machineIdentifier(value: string) {
|
||||
this._machineIdentifier = value;
|
||||
}
|
||||
|
||||
/** 获取机器设备名 */
|
||||
public get machineIdentifier(): string {
|
||||
return this._machineIdentifier;
|
||||
}
|
||||
|
||||
/** 设置sdk体系的UID */
|
||||
public set sdkUid(value: string) {
|
||||
this._sdkUid = value;
|
||||
}
|
||||
|
||||
/** 获取sdk体系的UID */
|
||||
public get sdkUid(): string {
|
||||
return this._sdkUid;
|
||||
}
|
||||
|
||||
/** 设置上次登陆时间 */
|
||||
public set lastLoginTime(value: string) {
|
||||
this._lastLoginTime = value;
|
||||
}
|
||||
|
||||
/** 获取上次登陆时间 */
|
||||
public get lastLoginTime(): string {
|
||||
return this._lastLoginTime;
|
||||
}
|
||||
|
||||
public reset(): void {
|
||||
|
||||
this._loginState = 0;
|
||||
this._token = "";
|
||||
this._operateType = 1;
|
||||
this._ip = "";
|
||||
this._machineIdentifier = "";
|
||||
this._sdkUid = "";
|
||||
this._lastLoginTime = "";
|
||||
}
|
||||
|
||||
public clear(): void {
|
||||
|
||||
this._loginState = 0;
|
||||
this._token = "";
|
||||
this._operateType = 1;
|
||||
this._ip = "";
|
||||
this._machineIdentifier = "";
|
||||
this._sdkUid = "";
|
||||
this._lastLoginTime = "";
|
||||
}
|
||||
|
||||
public destroy(): void {
|
||||
super.destroy();
|
||||
this._loginState = null;
|
||||
this._token = null;
|
||||
this._operateType = null;
|
||||
this._ip = null;
|
||||
this._machineIdentifier = null;
|
||||
this._sdkUid = null;
|
||||
this._lastLoginTime = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* 元数据
|
||||
*/
|
||||
import { BaseData } from "./BaseData";
|
||||
|
||||
export class MetaData extends BaseData {
|
||||
// 游戏名字
|
||||
private _gameName = "";
|
||||
|
||||
/** 设置游戏名字 */
|
||||
public set gameName(value: string) {
|
||||
this._gameName = value;
|
||||
}
|
||||
|
||||
/** 获取游戏名字 */
|
||||
public get gameName(): string {
|
||||
return this._gameName;
|
||||
}
|
||||
|
||||
public reset(): void {
|
||||
this._gameName = "";
|
||||
}
|
||||
|
||||
public clear(): void {
|
||||
this._gameName = "";
|
||||
}
|
||||
|
||||
public destroy(): void {
|
||||
super.destroy();
|
||||
this._gameName = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "d8c3e93c-53d7-4b1a-b962-08d47e478d91",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* 网络时间数据
|
||||
*/
|
||||
import { BaseData } from "./BaseData";
|
||||
|
||||
export class NetTimeData extends BaseData {
|
||||
// 服务端时间戳
|
||||
private _serverTime = "";
|
||||
// 服务器时区
|
||||
private _timezoneOffset = 0;
|
||||
|
||||
/** 设置服务端时间戳 */
|
||||
public set serverTime(value: string) {
|
||||
this._serverTime = value;
|
||||
}
|
||||
|
||||
/** 获取服务端时间戳 */
|
||||
public get serverTime(): string {
|
||||
return this._serverTime;
|
||||
}
|
||||
|
||||
/** 设置服务器时区 */
|
||||
public set timezoneOffset(value: number) {
|
||||
this._timezoneOffset = value;
|
||||
}
|
||||
|
||||
/** 获取服务器时区 */
|
||||
public get timezoneOffset(): number {
|
||||
return this._timezoneOffset;
|
||||
}
|
||||
|
||||
public reset(): void {
|
||||
this._serverTime = "";
|
||||
this._timezoneOffset = 0;
|
||||
}
|
||||
|
||||
public clear(): void {
|
||||
this._serverTime = "";
|
||||
this._timezoneOffset = 0;
|
||||
}
|
||||
|
||||
public destroy(): void {
|
||||
super.destroy();
|
||||
this._serverTime = null;
|
||||
this._timezoneOffset = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "24dd64d3-bcfe-45f4-865d-ef4fff1a60b2",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
Reference in New Issue
Block a user