49 lines
1.7 KiB
C#
49 lines
1.7 KiB
C#
|
using Newtonsoft.Json;
|
|||
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using UnityEngine;
|
|||
|
//9.4,蜗牛绑定卡槽
|
|||
|
public class bindSlot : MonoBehaviour
|
|||
|
{
|
|||
|
public async Task<BindSlot> QueryUserSnailCount(long snailId,long slotId) // 9.1
|
|||
|
{
|
|||
|
// 准备请求的头部信息,包含授权令牌
|
|||
|
Dictionary<string, string> head = new Dictionary<string, string>
|
|||
|
{
|
|||
|
{ "Authorization", Global.global.serverResponse.data.token }
|
|||
|
};
|
|||
|
|
|||
|
BindSlotBody body = new BindSlotBody();
|
|||
|
body.snailId=snailId;
|
|||
|
body.slotId=slotId;
|
|||
|
Debug.Log(JsonConvert.SerializeObject(body) + "========入参==========");
|
|||
|
// 异步发送请求以获取最新的蜗牛骑士信息
|
|||
|
string response94 = await web.SendRequest(web.URL + "/snail/factory/bindSlot", "POST", JsonConvert.SerializeObject(body), head);
|
|||
|
|
|||
|
// 调试输出接收到的响应
|
|||
|
Debug.Log("9.4,蜗牛绑定卡槽" + response94);
|
|||
|
|
|||
|
// 将响应反序列化为对象
|
|||
|
BindSlot bindSlot = JsonConvert.DeserializeObject<BindSlot>(response94);
|
|||
|
Debug.Log(bindSlot.code);
|
|||
|
// 返回解析后的对象
|
|||
|
return bindSlot;
|
|||
|
}
|
|||
|
}
|
|||
|
//==========请求体========================================
|
|||
|
//请求参数:header:Authorization:1.2接口返回的token
|
|||
|
// body:snailId:Long,蜗牛id
|
|||
|
// slotId:Long,卡槽id
|
|||
|
//返回参数:code:200,成功
|
|||
|
// message:成功,提示语
|
|||
|
// data:null
|
|||
|
public class BindSlotBody
|
|||
|
{
|
|||
|
public long snailId;
|
|||
|
public long slotId;
|
|||
|
}
|
|||
|
public class BindSlot : Response
|
|||
|
{
|
|||
|
public string data;
|
|||
|
}
|