_TheStrongestSnail/TheStrongestSnail/Assets/Scripts/kuangChang10/bindSlot.cs
2024-12-02 17:51:28 +08:00

44 lines
1.6 KiB
C#
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Newtonsoft.Json;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
//10.7,绑定卡槽
public class bindSlot107 : MonoBehaviour
{
public async Task<bool> BindSlot(long miningUserId,long slotId)
{
// 准备请求的头部信息,包含授权令牌
Dictionary<string, string> head = new Dictionary<string, string>
{
{ "Authorization", Global.global.serverResponse.data.token }
};
BindSlotBody107 body = new BindSlotBody107();
body.slotId = slotId;
body.miningUserId = miningUserId;
// 异步发送请求以获取最新的蜗牛骑士信息
string response0107 = await web.SendRequest(web.URL + "/snail/mining/bindSlot", "POST", JsonConvert.SerializeObject(body), head);
// 调试输出接收到的响应
Debug.Log("10.7绑定卡槽" + response0107);
BindSlotResponse bindSlotResponse = JsonConvert.DeserializeObject<BindSlotResponse>(response0107);
bool isSucceed;
if (bindSlotResponse.code == 200) { isSucceed = true; }else{ isSucceed = false; }
return isSucceed;
}
}
//======请求体==========================
public class BindSlotBody107
{
public long miningUserId;
public long slotId;
}
//请求参数headerAuthorization1.2接口返回的token
//         bodyminingUserIdLong用户合约id
//               slotIdLong, 卡槽id
//===========返回===============================
public class BindSlotResponse : Response
{
public string data;
}