57 lines
1.7 KiB
C#
57 lines
1.7 KiB
C#
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using UnityEngine;
|
|
|
|
public class AdressList83 : MonoBehaviour
|
|
{
|
|
public AdressResponse adressResponse;
|
|
public async Task<AdressResponse> AdressList()
|
|
{
|
|
// 准备请求的头部信息,包含授权令牌
|
|
Dictionary<string, string> head83 = new Dictionary<string, string>
|
|
{
|
|
{ "Authorization", Global.global.serverResponse.data.token }
|
|
};
|
|
|
|
// 异步发送请求
|
|
string response83 = await web.SendRequest(web.URL + "/snail/area/list", "POST", "{}", head83);
|
|
|
|
// 调试输出接收到的响应
|
|
Debug.Log("8.3地址列表: " + response83);
|
|
|
|
// 将响应反序列化为 AdressResponse 对象
|
|
try
|
|
{
|
|
adressResponse = JsonConvert.DeserializeObject<AdressResponse>(response83);
|
|
Debug.Log(adressResponse.data + "=======================================");
|
|
|
|
// 遍历 data 列表中的每个地址
|
|
if (adressResponse.data != null)
|
|
{
|
|
foreach (var address in adressResponse.data)
|
|
{
|
|
Debug.Log($"地址ID: {address.id}");
|
|
Debug.Log($"收件人: {address.receiveName}");
|
|
Debug.Log($"电话号码: {address.receivePhone}");
|
|
Debug.Log($"区域: {address.area}");
|
|
Debug.Log($"详细地址: {address.address}");
|
|
Debug.Log($"状态: {address.status}");
|
|
Debug.Log($"创建时间: {address.createTime}");
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Debug.LogError("反序列化响应失败: " + ex.Message);
|
|
}
|
|
|
|
// 返回解析后的对象
|
|
return adressResponse;
|
|
}
|
|
}
|
|
|
|
|