_TheStrongestSnail/TheStrongestSnail/Assets/Scripts/AddressSystem8/newAddress81.cs
2024-11-27 19:02:29 +08:00

55 lines
1.8 KiB
C#

using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
public class newAddress81 : MonoBehaviour
{
//返回的(解析后)
public newAddressResponse newAddressResponse;
//public async Task<KnightBetResult> queryKnightBetResult(int KnightId) // 5.2.2//需传入KightId
public async Task<newAddressResponse> newAddress(string receiveName, string receivePhone,string area, string address)
{
// 准备请求的头部信息,包含授权令牌
Dictionary<string, string> head81 = new Dictionary<string, string>
{
{ "Authorization", Global.global.serverResponse.data.token }
};
// 请求体
newAddressBody newAddressBody = new newAddressBody
{
receivePhone = receivePhone,
area = area,
address = address,
receiveName = receiveName,
};
//Debug.Log("8.1=====入参======"+ JsonConvert.SerializeObject(newAddressBody));
// 异步发送请求
//string response525 = await web.SendRequest(web.URL + "/snail/gameKnight/queryUserBetResult", "POST", JsonUtility.ToJson(queryKnightRoomListBody), head525);
string response81 = await web.SendRequest(web.URL + "/snail/area/save", "POST", JsonConvert.SerializeObject(newAddressBody), head81);
// 调试输出接收到的响应
Debug.Log("8.1新增地址:======== " + response81);
//将响应反序列化为 KnightRoomList 对象
try
{
newAddressResponse = JsonConvert.DeserializeObject<newAddressResponse>(response81);
//Debug.Log(newAddressResponse.data+"");
}
catch (Exception ex)
{
Debug.LogError("反序列化响应失败: " + ex.Message);
}
// 返回解析后的 对象
return newAddressResponse;
}
}