_TheStrongestSnail/TheStrongestSnail/Assets/Scripts/Conversion/DonatePanelItem.cs
舒荣森 0a90f577ae add
2024-11-26 18:14:09 +08:00

54 lines
1.7 KiB
C#

using Newtonsoft.Json;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class DonatePanelItem : BaseUIPanel
{
public TMP_InputField Recipient;
public TMP_InputField GiftQuantity;
public Text NumberOfFreeSnailShells;
public Text Fees;
public Text Total;
public Button Button;
void Start()
{
GiftQuantity.onValueChanged.AddListener(GiftQuantityData);
Button.onClick.AddListener(buttonOnClick);
testLogo();
}
public class voluteCoinItem
{
public string toCuteNo;
public int voluteCoin;
}
async void buttonOnClick()
{
voluteCoinItem body = new voluteCoinItem();
body.toCuteNo = Recipient.text;
body.voluteCoin = int.Parse(GiftQuantity.text);
string response = await web.SendRequest(web.URL + "/snail/transfer/voluteCoin", "POST", JsonUtility.ToJson(body), testhead);//²âÊÔ
ServerResponse18 serverResponse = JsonConvert.DeserializeObject<ServerResponse18>(response);
if (serverResponse.code != 200)
{
addEventPopUp(serverResponse.message);
}
Destroy(gameObject);
}
async void GiftQuantityData(string userInput)
{
NumberOfFreeSnailShells.text = userInput;
await ButtonClickAnimationAsync(NumberOfFreeSnailShells.gameObject, 1.05f);
Fees.text = (int.Parse(userInput) * 0.08).ToString();
await ButtonClickAnimationAsync(Fees.gameObject, 1.05f);
Total.text = (int.Parse(userInput) + (int.Parse(userInput) * 0.08)).ToString();
await ButtonClickAnimationAsync(Total.gameObject, 1.05f);
}
}