using System; using Newtonsoft.Json; using System.Collections; using System.Collections.Generic; using System.Threading.Tasks; using UnityEngine; using UnityEngine.UI; public class WalletPanel : MonoBehaviour { public GameObject zhuanzengConnect; public GameObject zhuanhuanConnect; public GameObject woniuSc; public GameObject wokeSc; public Button woniuBtn; public Button wokeBtn; public GameObject Musk; public GameObject ConvertGameObject; public GameObject TransferGameObject; public WalletconvertResponse Walletconvert; public WallettransferResponse Wallettransfer; // Start is called before the first frame update async void Start() { woniuBtn.onClick.AddListener(WoniuClick); wokeBtn.onClick.AddListener(WokeClick); Walletconvert =await QueryUserMiningSlot(); Wallettransfer = await QueryUserMiningSlotT(); Init(); } void Init() { foreach (var convert in Walletconvert.data.dataList) { GameObject ob = Instantiate(ConvertGameObject); ob.transform.parent = zhuanzengConnect.transform; ob.transform.localScale = new Vector3(1, 1, 1); ConvertPre convertPre = ob.gameObject.GetComponent(); convertPre.Convert = convert; } foreach (var trams in Wallettransfer.data.dataList) { GameObject ob = Instantiate(TransferGameObject); ob.transform.parent = zhuanhuanConnect.transform; ob.transform.localScale = new Vector3(1, 1, 1); TransferPre tramsfers = ob.gameObject.GetComponent(); tramsfers.tramsfer = trams; tramsfers.Init(); } wokeSc.gameObject.SetActive(false); } void WoniuClick() { woniuBtn.transform.SetParent(this.transform); wokeBtn.transform.SetParent(Musk.transform); woniuSc.gameObject.SetActive(true); wokeSc.gameObject.SetActive(false); } void WokeClick() { woniuBtn.transform.SetParent(Musk.transform); wokeBtn.transform.SetParent(this.transform); woniuSc.gameObject.SetActive(false); wokeSc.gameObject.SetActive(true); } // Update is called once per frame void Update() { } public async Task QueryUserMiningSlot() { // 准备请求的头部信息,包含授权令牌 Dictionary head = new Dictionary { { "Authorization", Global.global.serverResponse.data.token } }; queryPlayerInfo queryPlayerInfo = new queryPlayerInfo(); RealPlayerInfo realPlayerInfo = await queryPlayerInfo.QueryPlayerInfoPro(); WalletConvert body = new WalletConvert(); body.userId = realPlayerInfo.data.userId; // 异步发送请求以获取最新的蜗牛骑士信息 string response0104 = await web.SendRequest(web.URL + "/snail/transfer/queryTransferRecord", "POST", JsonConvert.SerializeObject(body), head); // 调试输出接收到的响应 Debug.Log("1.20查询蜗壳转换记录" + response0104); // 将响应反序列化为对象 WalletconvertResponse Response = JsonConvert.DeserializeObject(response0104); //foreach (var convert in Response.data.dataList) //{ // Debug.Log(convert.id); // Debug.Log(convert.fromUserId); // Debug.Log(convert.toUserId); // Debug.Log(convert.type); // Debug.Log(convert.voluteCoin); // Debug.Log(convert.slotId); // Debug.Log(convert.slotCount); // Debug.Log(convert.createTime); //} // 返回解析后的对象 return Response; } public async Task QueryUserMiningSlotT() { // 准备请求的头部信息,包含授权令牌 Dictionary head = new Dictionary { { "Authorization", Global.global.serverResponse.data.token } }; queryPlayerInfo queryPlayerInfo = new queryPlayerInfo(); RealPlayerInfo realPlayerInfo = await queryPlayerInfo.QueryPlayerInfoPro(); WalletTransfer body = new WalletTransfer(); body.userId = realPlayerInfo.data.userId; // 异步发送请求以获取最新的蜗牛骑士信息 string response0104 = await web.SendRequest(web.URL + "/snail/transfer/queryConvertRecord", "POST", JsonConvert.SerializeObject(body), head); // 调试输出接收到的响应 Debug.Log("1.21查询蜗壳兑换记录" + response0104); // 将响应反序列化为对象 WallettransferResponse Response = JsonConvert.DeserializeObject(response0104); //foreach (var convert in Response.data.dataList) //{ // Debug.Log(convert.id); // Debug.Log(convert.userId); // Debug.Log(convert.convertType); // Debug.Log(convert.voluteCoin); // Debug.Log(convert.beansCoin); // Debug.Log(convert.createTime); //} // 返回解析后的对象 return Response; } } //请求 public class WalletConvert { public long userId; } public class WalletTransfer { public long userId; } //Transfer //返回 /// /// 转换记录 /// public class WalletconvertResponse : Response { public UserconvertData data { get; set; } } public class WallettransferResponse : Response { public UsertransferData data { get; set; } } public class UserconvertData { public int pageNo { get; set; } public int pageSize { get; set; } public int totalCount { get; set; } public List dataList { get; set; } } public class UsertransferData { public int pageNo { get; set; } public int pageSize { get; set; } public int totalCount { get; set; } public List dataList { get; set; } } public class Convert { public long id { get; set; } public long fromUserId { get; set; } public long toUserId { get; set; } public int type { get; set; } public Decimal voluteCoin { get; set; } public long slotId { get; set; } public long slotCount { get; set; } public String createTime { get; set; } public String updateTime { get; set; } } public class Tramsfer { public long id { get; set; } public long userId { get; set; } public int convertType { get; set; } public Decimal voluteCoin { get; set; } public Decimal beansCoin { get; set; } public String createTime { get; set; } public String updateTime { get; set; } }