55 lines
2.0 KiB
C#
55 lines
2.0 KiB
C#
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using UnityEngine;
|
|
//查询马匹最新下注情况5.2.2
|
|
public class queryKnightRoomList522 : MonoBehaviour
|
|
{
|
|
//返回的(解析后)
|
|
public KnightRoomBetList knightRoomBetList;
|
|
|
|
|
|
|
|
public async Task<KnightRoomBetList> queryKnightRoomLis(int KnightId) // 5.2.2//需传入KightId
|
|
{
|
|
// 准备请求的头部信息,包含授权令牌
|
|
Dictionary<string, string> head522 = new Dictionary<string, string>
|
|
{
|
|
{ "Authorization", Global.global.serverResponse.data.token }
|
|
};
|
|
|
|
// 请求体
|
|
QueryKnightRoomListBody queryKnightRoomListBody = new QueryKnightRoomListBody
|
|
{
|
|
knightId = KnightId,
|
|
userId = Global.global.serverResponse.data.userId
|
|
};
|
|
// 异步发送请求
|
|
string response522 = await web.SendRequest(web.URL + "/snail/gameKnight/queryKnightRoomList", "POST", JsonConvert.SerializeObject(queryKnightRoomListBody), head522);
|
|
|
|
// 调试输出接收到的响应
|
|
Debug.Log("5.2.2马匹最新下注情况: " + response522);
|
|
|
|
// 将服务器返回的 JSON 字符串反序列化为 KnightRoomBetList 对象
|
|
KnightRoomBetList knightRoomBetList = JsonConvert.DeserializeObject<KnightRoomBetList>(response522);
|
|
|
|
//if (knightRoomBetList != null && knightRoomBetList.Data != null)
|
|
//{
|
|
// Debug.Log("解析成功,响应代码: " + knightRoomBetList.Code);
|
|
// Debug.Log("携带的秒数: " + knightRoomBetList.Data.CarrySeconds);
|
|
|
|
// foreach (var room in knightRoomBetList.Data.GameKnightRoomResponseVoList)
|
|
// {
|
|
// Debug.Log("骑士ID: " + room.KnightId);
|
|
// Debug.Log("马匹编号: " + room.HorseNo);
|
|
// Debug.Log("马匹用户编号: " + room.HorseUserNo);
|
|
// Debug.Log("马匹豆币: " + room.HorseBeansCoin);
|
|
// }
|
|
//}
|
|
|
|
// 返回解析后的 KnightRoomBetList 对象
|
|
return knightRoomBetList;
|
|
}
|
|
} |