From f713d60e13c45633cb2f9c20bab329f40f5cf463 Mon Sep 17 00:00:00 2001 From: liuliang <597380732@qq.com> Date: Tue, 26 Nov 2024 21:16:12 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9D=93=E5=8F=B7=E8=8E=B7=E5=8F=96=E4=B8=8E?= =?UTF-8?q?=E8=B4=AD=E4=B9=B0=E6=8E=A5=E5=8F=A3=E7=9A=84=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Assets/Scenes/Scene_lianghao.unity | 2 +- .../Assets/Scripts/GoodId/BuyGoodId42.cs | 38 +++++++++++++++++++ .../Assets/Scripts/GoodId/BuyGoodId42.cs.meta | 11 ++++++ .../Assets/Scripts/Login/Global.cs | 32 +++++++++++++++- .../Assets/Scripts/lianghaoLL/LoginItem.cs | 5 ++- .../Scripts/lianghaoLL/Nice_numPanel.cs | 26 ++++++------- .../Assets/Scripts/lianghaoLL/NumberTc.cs | 3 +- 7 files changed, 96 insertions(+), 21 deletions(-) create mode 100644 TheStrongestSnail/Assets/Scripts/GoodId/BuyGoodId42.cs create mode 100644 TheStrongestSnail/Assets/Scripts/GoodId/BuyGoodId42.cs.meta diff --git a/TheStrongestSnail/Assets/Scenes/Scene_lianghao.unity b/TheStrongestSnail/Assets/Scenes/Scene_lianghao.unity index eeec112..6924193 100644 --- a/TheStrongestSnail/Assets/Scenes/Scene_lianghao.unity +++ b/TheStrongestSnail/Assets/Scenes/Scene_lianghao.unity @@ -394,7 +394,7 @@ GameObject: - component: {fileID: 1939568758} - component: {fileID: 1939568757} m_Layer: 5 - m_Name: Canvas + m_Name: lianghaoCanvas m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 diff --git a/TheStrongestSnail/Assets/Scripts/GoodId/BuyGoodId42.cs b/TheStrongestSnail/Assets/Scripts/GoodId/BuyGoodId42.cs new file mode 100644 index 0000000..5857d60 --- /dev/null +++ b/TheStrongestSnail/Assets/Scripts/GoodId/BuyGoodId42.cs @@ -0,0 +1,38 @@ +using Newtonsoft.Json; +using System.Collections; +using System.Collections.Generic; +using System.Threading.Tasks; +using UnityEngine; + +public class BuyGoodId42 : MonoBehaviour +{ + public async Task buyGoodId(int cutePoolId) // 4.2 + { + // 准备请求的头部信息,包含授权令牌 + Dictionary head41 = new Dictionary + { + { "Authorization", Global.global.serverResponse.data.token } + }; + + // 请求体 + BuyGoodIdBody buyGoodIdBody = new BuyGoodIdBody + { + userId = Global.global.serverResponse.data.userId, + cutePoolId = cutePoolId + }; + + // 异步发送请求 + Debug.Log("======入参======" + JsonConvert.SerializeObject(buyGoodIdBody)); + string response42 = await web.SendRequest(web.URL + "/snail/cutePool/buy", "POST", JsonConvert.SerializeObject(buyGoodIdBody), head41); + + // 调试输出接收到的响应 + Debug.Log("4.2购买靓号==" + response42); + + // 将响应反序列化为对象 + BuyGoodIdResponse buyGoodIdResponse = JsonConvert.DeserializeObject(response42); + Debug.Log("8==================================D" + buyGoodIdResponse.Data.TotalCount); + return buyGoodIdResponse; + + } +} + diff --git a/TheStrongestSnail/Assets/Scripts/GoodId/BuyGoodId42.cs.meta b/TheStrongestSnail/Assets/Scripts/GoodId/BuyGoodId42.cs.meta new file mode 100644 index 0000000..912b5b3 --- /dev/null +++ b/TheStrongestSnail/Assets/Scripts/GoodId/BuyGoodId42.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e55a4e0a058739742a83e8d77ae91065 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/TheStrongestSnail/Assets/Scripts/Login/Global.cs b/TheStrongestSnail/Assets/Scripts/Login/Global.cs index 2e05bd8..4956c30 100644 --- a/TheStrongestSnail/Assets/Scripts/Login/Global.cs +++ b/TheStrongestSnail/Assets/Scripts/Login/Global.cs @@ -628,7 +628,7 @@ public class GoodIdItem { public int Id { get; set; } public string CuteNo { get; set; } - public float BeansCoin { get; set; } + public decimal BeansCoin { get; set; } public int UserId { get; set; } public int Type { get; set; } public int Status { get; set; } @@ -638,4 +638,32 @@ public class GoodIdItem public class GoodIdPageBody { public int orderByDesc { get; set; } -} \ No newline at end of file +} +//====4.2璐拱闈撳彿========================================================= +//璇锋眰浣 +public class BuyGoodIdBody +{ + public int userId { get; set; } + public int cutePoolId { get; set; } +} +//杩斿洖鍊 + +public class BuyGoodIdResponse : Response +{ + public BuyGoodIdData Data { get; set; } +} + +public class BuyGoodIdData +{ + public int PageNo { get; set; } + public int PageSize { get; set; } + public int TotalCount { get; set; } + public List DataList { get; set; } // 浣犲彲浠ユ牴鎹渶瑕佸皢List鏇挎崲涓篖ist=========================================================== +} + + + + + + + diff --git a/TheStrongestSnail/Assets/Scripts/lianghaoLL/LoginItem.cs b/TheStrongestSnail/Assets/Scripts/lianghaoLL/LoginItem.cs index 53073b7..85d1be2 100644 --- a/TheStrongestSnail/Assets/Scripts/lianghaoLL/LoginItem.cs +++ b/TheStrongestSnail/Assets/Scripts/lianghaoLL/LoginItem.cs @@ -17,12 +17,13 @@ public class LoginItem :MonoBehaviour public async void Init() { - idResponse=await goodId.queryUnionPage(); + idResponse = await goodId.queryUnionPage(); for (int i = 0; i < idResponse.Data.DataList.Count; i++) { - GameObject Lhitem = (GameObject)Instantiate(Resources.Load("LLPrefabs/Beautiful_numberttem"),contentItem); + GameObject Lhitem = (GameObject)Instantiate(Resources.Load("LLPrefabs/Beautiful_numberttem"), contentItem); Lhitem.GetComponent().BeautifulNumber.text = idResponse.Data.DataList[i].CuteNo; Lhitem.GetComponent().price.text = idResponse.Data.DataList[i].BeansCoin.ToString(); + Lhitem.GetComponent().id = idResponse.Data.DataList[i].Id; if (idResponse.Data.DataList[i].Type == 1) { Lhitem.GetComponent().musk_show(); diff --git a/TheStrongestSnail/Assets/Scripts/lianghaoLL/Nice_numPanel.cs b/TheStrongestSnail/Assets/Scripts/lianghaoLL/Nice_numPanel.cs index f42bebf..0bf3428 100644 --- a/TheStrongestSnail/Assets/Scripts/lianghaoLL/Nice_numPanel.cs +++ b/TheStrongestSnail/Assets/Scripts/lianghaoLL/Nice_numPanel.cs @@ -7,6 +7,8 @@ public class Nice_numPanel : MonoBehaviour public Button CancleBtn; public Button ConfirmBtn; public NumberTc numberTc; + BuyGoodIdResponse buyGoodIdResponse = new BuyGoodIdResponse(); + BuyGoodId42 buyGoodId42 = new BuyGoodId42(); // Start is called before the first frame update void Start() { @@ -16,29 +18,23 @@ public class Nice_numPanel : MonoBehaviour void CanclePanel() { - Destroy(this.gameObject); + Destroy(this.gameObject); } - void ConfirmBuy() + async void ConfirmBuy() { - string pricetext = numberTc.price.text; - if ((PlayerInfo.instance.Money - float.Parse(pricetext)) >= 0) - { - - numberTc.musk_show(); - Destroy(this.gameObject); - } - else - { - Debug.Log("弹出蜗壳不足的弹窗"); - } - + //string pricetext = numberTc.price.text; + buyGoodIdResponse = await buyGoodId42.buyGoodId(numberTc.id); + Debug.Log(buyGoodIdResponse); + numberTc.musk_show(); + Destroy(this.gameObject); + //Debug.Log("弹出蜗壳不足的弹窗"); } // Update is called once per frame void Update() { - + } } diff --git a/TheStrongestSnail/Assets/Scripts/lianghaoLL/NumberTc.cs b/TheStrongestSnail/Assets/Scripts/lianghaoLL/NumberTc.cs index 72e194c..a32bde4 100644 --- a/TheStrongestSnail/Assets/Scripts/lianghaoLL/NumberTc.cs +++ b/TheStrongestSnail/Assets/Scripts/lianghaoLL/NumberTc.cs @@ -7,13 +7,14 @@ public class NumberTc : MonoBehaviour { public TextMeshProUGUI BeautifulNumber; public TextMeshProUGUI price; + public int id; public Button Show_buy; public Canvas jiemianCanvas; public GameObject musk; // Start is called before the first frame update void Start() { - jiemianCanvas = GameObject.Find("Canvas").GetComponent(); + jiemianCanvas = GameObject.Find("lianghaoCanvas").GetComponent(); Show_buy.onClick.AddListener(ShowBuy_TanChuang); }