using System.Collections; using System.Collections.Generic; using System.Threading.Tasks; using UnityEngine; using UnityEngine.UI; public class OrderPanel : MonoBehaviour { public ScrollRect sv; public GameObject orderObj; private string urlPath = "/snail/order/queryPage"; //订单信息 private OrderInfo orderInfo; // Start is called before the first frame update void Start() { ReGetOrder(); } // Update is called once per frame void Update() { } //请求体 public class OrderMsg { public int orderByDesc { get; set; } } public class OrderInfo { public int code; public string message; public OrderData data = new OrderData(); } public class OrderData { public int pageNo; public int pageSize; public int totalCount; public List dataList = new List(); } public class OrderList { //玩家id public int userId; //商品id public int productId; public int productType; //0支付中,1成功,2失败 public int payStatus; public int price; //下单时间 public string createTime; public string receiveName; public string receivePhone; public string area; public string address; } OrderMsg msg = new OrderMsg() { orderByDesc = 1 }; //准备请求的头部信息,包含授权令牌 private Dictionary headInfo = new Dictionary(); // public async Task ReGetOrder() { headInfo.Add("Authorization", Global.global.serverResponse.data.token); // 请求体 //异步发送请求 string responsel6 = await web.SendRequest(web.URL + "/snail/order/queryPage", "POST", JsonUtility.ToJson(msg), headInfo); Debug.Log(responsel6); //orderInfo = JsonUtility.FromJson(responsel6); //测试 //orderInfo = new OrderInfo(); //orderInfo.data.dataList.Add(new OrderList()); //orderInfo.data.dataList.Add(new OrderList()); //orderInfo.data.dataList.Add(new OrderList()); for (int i = 0; i < orderInfo.data.dataList.Count; i++) { //创建对象 GameObject go = Instantiate(orderObj); go.transform.SetParent(sv.content, false); //更新面板 go.GetComponent().UpdatePanel(orderInfo.data.dataList[i]); } } }