_TheStrongestSnail/TheStrongestSnail/Assets/Scripts/kuangChang10/queryMyPureContract106.cs
2024-12-05 21:23:44 +08:00

75 lines
2.7 KiB
C#
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
//10.6查询寻未激活的条约
public class queryMyPureContract106 : MonoBehaviour
{
public async Task QueryMyPureContract()
{
// 准备请求的头部信息,包含授权令牌
Dictionary<string, string> head = new Dictionary<string, string>
{
{ "Authorization", Global.global.serverResponse.data.token }
};
// 异步发送请求以获取未激活的合约信息
string response0106 = await web.SendRequest(web.URL + "/snail/mining/queryMyPureContract", "POST", "{}", head);
// 调试输出接收到的响应
Debug.Log("10.6 查询未激活的合约: " + response0106);
// 将响应反序列化为对象
MyPureContractResponse contractResponse = JsonConvert.DeserializeObject<MyPureContractResponse>(response0106);
// 检查返回的数据
if (contractResponse != null && contractResponse.data != null)
{
foreach (var contract in contractResponse.data)
{
// 访问合约字段
//Debug.Log($"合约 ID: {contract.id}");
//Debug.Log($"合约名称: {contract.contractName}");
//Debug.Log($"每秒奖励: {contract.eachSecondsReward}");
//Debug.Log($"合约创建时间: {contract.createTime}");
//Debug.Log($"合约更新时间: {contract.updateTime}");
// 这里可以根据需要进行其他处理
}
}
else
{
Debug.LogError("未能获取到合约数据!");
}
}
}
//==============返回值===================================
public class MyPureContractResponse:Response
{
public List<MyPureContract> data { get; set; }
}
public class MyPureContract
{
public long id { get; set; }
public long userId { get; set; }
public long contractId { get; set; }
public string contractName { get; set; }
public long slotId { get; set; }
public string miningBegin { get; set; }
public string miningEnd { get; set; }
public string miningNow { get; set; }
public double eachSecondsReward { get; set; }
public int status { get; set; }
public string createTime { get; set; }
public string updateTime { get; set; }
}
//code200成功
//        message成功提示语
//        data合约列表
//            idLong, 用户合约id
//            userIdLong, 用户id
//            contractIdLong合约id
//            contractNameString合约名称