_TheStrongestSnail/TheStrongestSnail/Assets/Scripts/queryPlayerInfo.cs

33 lines
1003 B
C#

using Newtonsoft.Json;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Threading.Tasks;
public class queryPlayerInfo : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// 查询玩家信息
public async Task<RealPlayerInfo> QueryPlayerInfoPro() // 1.4
{
// 准备请求的头部信息,包含授权令牌
Dictionary<string, string> head14 = new Dictionary<string, string>
{
{ "Authorization", Global.global.serverResponse.data.token }
};
// 异步查询玩家信息
string response14 = await web.SendRequest(web.URL + "/snail/user/queryUserInfo", "POST", "{}", head14);
Debug.Log("1.4查询玩家信息==================" + response14);
//解析服务器传入的数据
RealPlayerInfo realPlayerInfo = new RealPlayerInfo();
realPlayerInfo = JsonConvert.DeserializeObject<RealPlayerInfo>(response14);
return realPlayerInfo;
}
}