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 queryKnightBetResult(int KnightId) // 5.2.2//需传入KightId public async Task updateAddress(int id,string receiveName, string receivePhone, string area, string address) { // 准备请求的头部信息,包含授权令牌 Dictionary head81 = new Dictionary { { "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(response82); Debug.Log(updateAddressResponse.data + "======================================="); } catch (Exception ex) { Debug.LogError("反序列化响应失败: " + ex.Message); } // 返回解析后的 对象 return updateAddressResponse; } }