49 lines
1.5 KiB
TypeScript
Raw Normal View History

2023-11-08 02:32:54 +08:00
import { app } from "../App";
import { GUI } from "../ui/UIConfig";
2023-11-10 03:56:07 +08:00
const RData = (data:any,isTips:boolean = true) => {
2023-11-08 02:32:54 +08:00
if(data.data.state == 200){
return data.data.data;
}else{
//弹出提示
2023-11-10 03:56:07 +08:00
if(isTips){
app.layer.Open(GUI.Tips,{text:data.data.msg});
}
return data.data.data;
2023-11-08 02:32:54 +08:00
}
}
2023-11-09 04:22:04 +08:00
export interface NewsContext{
state:number,
msg:string,
data:any,
}
2023-11-08 02:32:54 +08:00
export interface UserVO{
userId:number, //玩家Id
userName:string, //玩家名称
userPass:string, //玩家密码
}
export interface UserLoginVO{
token:string, //token
user:UserVO, //玩家信息
}
2023-11-10 03:56:07 +08:00
export interface PlayerInfoOV{
playerId:number, //玩家Id
userId: number, //用户Id
playerName:string, //玩家名
playerCreateTime:number, //玩家创建时间
novice: false, //是否过引导
}
2023-11-08 02:32:54 +08:00
export const API = {
2023-11-10 03:56:07 +08:00
UserRegister : async () => RData(await app.api.post(`/user/register`)) as UserVO, //玩家注册
UserLogin : async (account:string,password:string) => RData(await app.api.post(`/user/login`,{userId:account,userPass:password})) as UserLoginVO, //玩家登录
GetPlayerInfo : async () => RData(await app.api.get(`/game/player/info`),false) as NewsContext, //获取玩家信息
/********** 新手引导接口 *****************/
SavePlayerInfo : async (playerName:string,novice:boolean = true) => (await app.api.post(`/game/player/info/save`,{playerName,novice})).data as NewsContext, //保存玩家信息
2023-11-08 02:32:54 +08:00
}