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

56 lines
1.9 KiB
C#

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