_TheStrongestSnail/TheStrongestSnail/Assets/Scripts/SnailKnight52/queryKnightBetResult525.cs

55 lines
2.0 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;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
//5.2.4查询结算
public class queryKnightBetResult525 : MonoBehaviour
{
//返回的(解析后)
public KnightBetResult knightBetResult;//===========================================================================================
public async Task<KnightBetResult> queryKnightBetResult(int KnightId) // 5.2.2//需传入KightId
{
// 准备请求的头部信息,包含授权令牌
Dictionary<string, string> head525 = new Dictionary<string, string>
{
{ "Authorization", Global.global.serverResponse.data.token }
};
// 请求体
QueryKnightRoomListBody queryKnightRoomListBody = new QueryKnightRoomListBody
{
userId = Global.global.serverResponse.data.userId,
knightId = KnightId
};
Debug.Log("524接收的=========================" + KnightId);
// 异步发送请求
//string response525 = await web.SendRequest(web.URL + "/snail/gameKnight/queryUserBetResult", "POST", JsonUtility.ToJson(queryKnightRoomListBody), head525);
string response525 = await web.SendRequest(web.URL + "/snail/gameKnight/queryKill", "POST", JsonConvert.SerializeObject(queryKnightRoomListBody), head525);
// 调试输出接收到的响应
Debug.Log("5.2.5查询骑士结算:======== " + response525);
// 将响应反序列化为 KnightRoomList 对象
try
{
knightBetResult = JsonConvert.DeserializeObject<KnightBetResult>(response525);
if (knightBetResult != null && knightBetResult.data != null)//==================================================访问之前先判空未到或已过时间data[]为空
{
Debug.Log(knightBetResult.data.beansCoinFee + "=525========");
}
}
catch (Exception ex)
{
Debug.LogError("反序列化响应失败: " + ex.Message);
}
// 返回解析后的 对象
return knightBetResult;
}
}