_TheStrongestSnail/TheStrongestSnail/Assets/Scripts/lianghaoLL/OrderPanel.cs
2024-11-30 17:28:53 +08:00

102 lines
2.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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<OrderList> dataList = new List<OrderList>();
}
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<string, string> headInfo = new Dictionary<string, string>();
//
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<OrderInfo>(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<OrderObj>().UpdatePanel(orderInfo.data.dataList[i]);
}
}
}