using Newtonsoft.Json; using System; using System.Collections; using System.Collections.Generic; using System.Threading.Tasks; using UnityEngine; //5.2.3下注 public class SnailKnightBet523 : MonoBehaviour { //返回的(解析后)==================== //public KnightRoomBetList knightRoomBetList; //async void Start() //{ // await SnailKnightBet(39592, 1, 3); // =============================== 示例,仅供测试 //} public async Task SnailKnightBet(int KnightId,float bet,int horseNo) { // 准备请求的头部信息,包含授权令牌 Dictionary head523 = new Dictionary { { "Authorization", Global.global.serverResponse.data.token } }; // 请求体 KnightBetBody knightBetBody = new KnightBetBody { userId = Global.global.serverResponse.data.userId, knightId = KnightId, bet = bet, horseNo = horseNo }; // 异步发送请求 string response523 = await web.SendRequest(web.URL + "/snail/gameKnight/userBet", "POST", JsonConvert.SerializeObject(knightBetBody), head523); // 调试输出接收到的响应 Debug.Log("入参"+ JsonConvert.SerializeObject(knightBetBody) + "5.2.3下注: " + response523); // 将响应反序列化为对象 try { // knightRoomBetList = JsonConvert.DeserializeObject(response522); } catch (Exception ex) { Debug.LogError("反序列化响应失败: " + ex.Message); } // 返回解析后的 KnightRoomBetList 对象 return null; } }