2023-11-08 02:32:54 +08:00
|
|
|
import { app } from "../App";
|
|
|
|
import { GUI } from "../ui/UIConfig";
|
|
|
|
|
|
|
|
const http = app.api;
|
|
|
|
|
|
|
|
const RData = (data:any) => {
|
|
|
|
if(data.data.state == 200){
|
|
|
|
return data.data.data;
|
|
|
|
}else{
|
|
|
|
//弹出提示
|
|
|
|
app.layer.Open(GUI.Tips,{text:data.data.msg});
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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, //玩家信息
|
|
|
|
}
|
|
|
|
|
|
|
|
export const API = {
|
|
|
|
|
2023-11-09 04:22:04 +08:00
|
|
|
UserRegister : async () => RData(await http.post(`/user/register`)) as UserVO, //玩家注册
|
|
|
|
UserLogin : async (account:string,password:string) => RData(await http.post(`/user/login`,{userId:account,userPass:password})) as UserLoginVO, //玩家登录
|
|
|
|
GetPlayerInfo : async () => (await http.get(`/game/player/info`)).data as NewsContext, //获取玩家信息
|
2023-11-08 02:32:54 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|