using Newtonsoft.Json; using System.Collections; using System.Collections.Generic; using System.Threading.Tasks; using UnityEngine; //10.1,查询可购买的挖矿合约 public class queryMiningContractList101 : MonoBehaviour { public async Task QueryMiningContract() { // 准备请求的头部信息,包含授权令牌 Dictionary head = new Dictionary { { "Authorization", Global.global.serverResponse.data.token } }; // 异步发送请求以获取最新的蜗牛骑士信息 string response0101 = await web.SendRequest(web.URL + "/snail/mining/queryMiningContractList", "POST", "{}", head); // 调试输出接收到的响应 Debug.Log("10.1,查询可购买的挖矿合约" + response0101); // 将响应反序列化为对象 MiningContractList miningContractList = JsonConvert.DeserializeObject(response0101); // 遍历 miningContractList.data 列表中的每个 MiningContract 对象 foreach (var contract in miningContractList.data) { Debug.Log($"合约ID: {contract.id}"); Debug.Log($"合约名称: {contract.name}"); Debug.Log($"状态: {contract.status}"); Debug.Log($"上架状态: {contract.onShelves}"); Debug.Log($"购买所需 VoluteCoin: {contract.voluteCoinBuy}"); Debug.Log($"挖矿天数: {contract.miningDays}"); Debug.Log($"挖矿奖励 VoluteCoin: {contract.voluteCoinReward}"); Debug.Log($"每秒奖励: {contract.eachSecondsReward}"); Debug.Log($"创建时间: {contract.createTime}"); Debug.Log($"更新时间: {contract.updateTime}"); } // 返回解析后的对象 return miningContractList; } } //=====返回================================================================ public class MiningContractList:Response { public List data { get; set; } } public class MiningContract { public long id { get; set; } public string name { get; set; } public int status { get; set; } public int onShelves { get; set; } public double voluteCoinBuy { get; set; } public int miningDays { get; set; } public double voluteCoinReward { get; set; } public double eachSecondsReward { get; set; } public string createTime { get; set; } public string updateTime { get; set; } }