Cute_demon_attacks/meng_yao/Assets/script/serveTestScript/treeModule/treeTeamData.cs

82 lines
2.8 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Newtonsoft.Json;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
//生态树团队信息
public class treeTeamData : MonoBehaviour
{
public Dictionary<string, string> CreateHeaders()
{
if (string.IsNullOrEmpty(MyGlobal.global.loginResponse.Data.access_token))
{
Debug.LogWarning("尝试创建请求头时token 未设置。");
return new Dictionary<string, string>();
}
return new Dictionary<string, string>
{
{ "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<TreeTeam> TreeTeamData()
{
string response = await myWeb.SendRequest(myWeb.URL + "/api/tree/team_data", "GET", "{}", CreateHeaders());
Debug.Log("生态树团队信息" + response);
// 反序列化 JSON
TreeTeam TreeTeamResponse = JsonConvert.DeserializeObject<TreeTeam>(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<TreeTeamItem> Items { get; set; }
}
public class TreeTeamInfo
{
public string Uid { get; set; }
public string Account { get; set; }
public string Nickname { get; set; }
public string avatar_url { get; set; }
public string invite_code { get; set; }
public int certify_status { get; set; }//实名状态 0:未实名 1:已实名
public string create_time { get; set; }
public string last_login_time { get; set; }
public int team_count { get; set; }
public int directly_count { get; set; }
public int team_active_count { get; set; }
public int directly_active_count { get; set; }
public int Level { get; set; }
public string level_name { get; set; }
public string level_icon { get; set; }
}
public class TreeTeamItem
{
public string Title { get; set; }
public string Desc { get; set; }
public int now_val { get; set; }
public int req_val { get; set; }
public float Percentage { get; set; }//百分比进度 1 = 100%
}