_TheStrongestSnail/TheStrongestSnail/Assets/Scripts/kuangChang10/queryMiningContracDetail102.cs
2024-12-06 16:14:45 +08:00

59 lines
2.0 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.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
//10.2查询合约详情
public class queryMiningContracDetail102 : MonoBehaviour
{
public async Task<MiningContracDetail> QueryMiningContracDetail(long contractId)
{
// 准备请求的头部信息,包含授权令牌
Dictionary<string, string> head = new Dictionary<string, string>
{
{ "Authorization", Global.global.serverResponse.data.token }
};
Debug.Log(contractId);
// 异步发送请求以获取最新的蜗牛骑士信息
string response0102 = await web.SendRequest(web.URL + "/snail/mining/queryMiningContractInfo?contractId=" + contractId, "GET","{}", head);
// 调试输出接收到的响应
Debug.Log("10.2,查询合约详情" + response0102);
// 将响应反序列化为对象
MiningContracDetail miningContracDetail = JsonConvert.DeserializeObject<MiningContracDetail>(response0102);
Debug.Log(miningContracDetail.data.id);
// 返回解析后的对象
return miningContracDetail;
}
}
//================返回==============================
public class MiningContracDetail : Response
{
public MiningDetailData data;
}
public class MiningDetailData
{
public long id;
public string name;
public int status;
public double voluteCoinBuy;
public int miningDays;
public double voluteCoinReward;
public double eachSecondsReward;
public string createTime;
public string updateTime;
}
//返回参数code200成功
//        message成功提示语
//        data合约详情
//             idLong合约id
//             nameString合约名称
//             voluteCoinBuyDecimal购买合约的蜗壳
//             voluteCoinRewardDecimal合约的回报蜗壳
//             miningDaysInteger挖矿天数