using Newtonsoft.Json; using System.Collections; using System.Collections.Generic; using System.Threading.Tasks; using UnityEngine; //生态树团队信息 public class treeTeamData : MonoBehaviour { public Dictionary CreateHeaders() { if (string.IsNullOrEmpty(MyGlobal.global.loginResponse.Data.access_token)) { Debug.LogWarning("尝试创建请求头时,token 未设置。"); return new Dictionary(); } return new Dictionary { { "Authorization","Bearer "+MyGlobal.global.loginResponse.Data.access_token }, { "client-info", "{\"platform\":\"ios\",\"phone_product\":\"apple\",\"phone_model\":\"iPhone_8\",\"system_version\":\"12.0\",\"screen_size\":\"750*1334\",\"device_no\":\"e3e277810fff9d955ebdd7037eff51a8\",\"version\":\"1.0.0\"}" } }; } public async Task TreeTeamData() { string response = await myWeb.SendRequest(myWeb.URL + "/api/tree/team_data", "GET", "{}", CreateHeaders()); Debug.Log("生态树团队信息" + response); // 反序列化 JSON TreeTeam TreeTeamResponse = JsonConvert.DeserializeObject(response); //// 检查反序列化后的数据 //if (TreeTeamResponse != null && TreeTeamResponse.Data != null && TreeTeamResponse.Data.Info != null) //{ // Debug.Log("用户昵称: " + TreeTeamResponse.Data.Info.Nickname); //} //else //{ // Debug.LogError("解析的数据为空,请检查返回的 JSON 格式或内容。"); //} return TreeTeamResponse; } } //=================================================================== public class TreeTeam:myResponse { public TreeTeamData Data { get; set; } } public class TreeTeamData { public TreeTeamInfo Info { get; set; } public List Items { get; set; } } public class TreeTeamInfo { public string Uid { get; set; } public string Account { get; set; } public string Nickname { get; set; } public string AvatarUrl { get; set; } public string InviteCode { get; set; } public int CertifyStatus { get; set; }//实名状态 0:未实名 1:已实名 public string CreateTime { get; set; } public string LastLoginTime { get; set; } public int TeamCount { get; set; } public int DirectlyCount { get; set; } public int TeamActiveCount { get; set; } public int DirectlyActiveCount { get; set; } public int Level { get; set; } public string LevelName { get; set; } public string LevelIcon { get; set; } } public class TreeTeamItem { public string Title { get; set; } public string Desc { get; set; } public int NowVal { get; set; } public int ReqVal { get; set; } public string Percentage { get; set; }//百分比进度 1 = 100% }