48 lines
1.6 KiB
C#
48 lines
1.6 KiB
C#
using Newtonsoft.Json;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using System.Threading.Tasks;
|
||
using UnityEngine;
|
||
|
||
public class submitTemplate : MonoBehaviour
|
||
{
|
||
// 创建请求头,使用最新的 token
|
||
public Dictionary<string, string> CreateHeaders()
|
||
{
|
||
if (string.IsNullOrEmpty(Global.global.loginResponse.data.access_token))
|
||
{
|
||
Debug.LogWarning("尝试创建请求头时,token 未设置。");
|
||
return new Dictionary<string, string>();
|
||
}
|
||
|
||
return new Dictionary<string, string>
|
||
{
|
||
{ "Authorization","Bearer "+Global.global.loginResponse.data.access_token },
|
||
{"clientId", "e5cd7e4891bf95d1d19206ce24a7b32e" }
|
||
};
|
||
}
|
||
//提交预定演练模板
|
||
public async Task<SubmitTemplate> SubmitTemplate(submitTemplateBody _submitTemplateBody)
|
||
{
|
||
string response = await web.SendRequest(web.URL + "/game/gameRoom/reserve", "POST", JsonConvert.SerializeObject(_submitTemplateBody), CreateHeaders());
|
||
Debug.Log("提交预定演练模板: " + response);
|
||
SubmitTemplate serverData = JsonConvert.DeserializeObject<SubmitTemplate>(response);
|
||
if (serverData.data == null)
|
||
{
|
||
Debug.Log("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
|
||
}
|
||
Debug.Log(serverData.data);
|
||
return serverData;
|
||
}
|
||
}
|
||
//========请求体========================================
|
||
public class submitTemplateBody
|
||
{
|
||
public string templateId;
|
||
public string reserveDate;
|
||
}
|
||
//===========返回值============================================
|
||
public class SubmitTemplate : Response
|
||
{
|
||
public string data;//++++++++++++++++++++++++++++++++++++
|
||
} |