_xiaofang/xiaofang/Assets/Script/DirllInterface/gameRoomReserve.cs
2024-12-25 17:24:22 +08:00

50 lines
1.9 KiB
C#

using Newtonsoft.Json;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
public class gameRoomReserve : MonoBehaviour
{
// 创建请求头,使用最新的 token
public Dictionary<string, string> CreateHeaders()
{
Debug.Log("====5555=====" + GlobalData.ServerData.data.access_token);
return new Dictionary<string, string>
{
{ "Authorization","Bearer "+GlobalData.ServerData.data.access_token },
{"clientId", "e5cd7e4891bf95d1d19206ce24a7b32e" }
};
}
//预定演练
public async Task<ScheduledDrillResponse> scheduledDrill(string reserveDate,string templateId)
{
ScheduledDrillBody body = new ScheduledDrillBody();
body.reserveDate= reserveDate;
//body.templateId = GlobalData.newTemplateData.data;
body.templateId=templateId;
//=====================================================================================================================================================
Debug.Log(JsonConvert.SerializeObject(body) + "预定演练入参");
string response = await web.SendRequest(web.URL + "/game/gameRoom/reserve", "POST", JsonConvert.SerializeObject(body), CreateHeaders());
Debug.Log("预定演练" + response);
// 解析服务器返回的数据
ScheduledDrillResponse scheduledDrillResponse = JsonConvert.DeserializeObject<ScheduledDrillResponse>(response);
//存静态
GlobalData.scheduledDrillResponse = scheduledDrillResponse;
Debug.Log("这个不是是静态的" + scheduledDrillResponse.data);
Debug.Log("现在是静态的"+GlobalData.scheduledDrillResponse.data);
return scheduledDrillResponse;
}
}
//====================================
public class ScheduledDrillBody
{
public string templateId;
public string reserveDate;
}
public class ScheduledDrillResponse : Response
{
public string data;//空
}