_TheStrongestSnail/TheStrongestSnail/Assets/Scripts/AddressSystem8/areaInfo84.cs
2024-11-27 15:58:54 +08:00

41 lines
1.1 KiB
C#

using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
//8.4查看地址详情
public class areaInfo84 : MonoBehaviour
{
public AdressInfoResponse adressInfoResponse;
public async Task<AdressInfoResponse> AdressInfo(int areaId)
{
// 准备请求的头部信息,包含授权令牌
Dictionary<string, string> head84 = new Dictionary<string, string>
{
{ "Authorization", Global.global.serverResponse.data.token }
};
// 异步发送请求
string response84 = await web.SendRequest(web.URL + "/snail/area/queryInfo?areaId=" + areaId, "GET", "{}", head84);
// 调试输出接收到的响应
Debug.Log("8.4地址详情====================: " + response84);
// 将响应反序列化为 AdressInfoResponse 对象
try
{
adressInfoResponse = JsonConvert.DeserializeObject<AdressInfoResponse>(response84);
}
catch (Exception ex)
{
Debug.LogError("反序列化响应失败: " + ex.Message);
}
// 返回解析后的对象
return adressInfoResponse;
}
}