using Newtonsoft.Json; using System; using System.Collections; using System.Collections.Generic; using System.Threading.Tasks; using UnityEngine; //2.1获取商城列表 public class getMallList21 : MonoBehaviour { public async Task getMallList(int productType, int pageNo, int pageSize) { // 准备请求的头部信息,包含授权令牌 Dictionary head21 = new Dictionary { { "Authorization", Global.global.serverResponse.data.token } }; // 请求体 getMallListBody getMallListBody = new getMallListBody { productType = productType, pageNo = pageNo, pageSize = pageSize }; Debug.Log("====入参====" + JsonConvert.SerializeObject(getMallListBody)); // 异步发送请求 string response21 = await web.SendRequest(web.URL + "/snail/product/page", "POST", JsonConvert.SerializeObject(getMallListBody), head21); // 调试输出接收到的响应 Debug.Log("2.1商城列表:=============== " + response21); // 解析响应的 JSON 数据 MallResponsePro mallResponse = JsonConvert.DeserializeObject(response21); // 检查响应是否成功 if (mallResponse.code == 200) { } else { // 处理错误信息 Debug.LogError("请求失败: " + mallResponse.message); } return mallResponse; } }