Cute_demon_attacks/meng_yao/Assets/script/ConnactServer/InitInfo.cs
2024-10-31 20:40:09 +08:00

86 lines
1.7 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor.Hardware;
using UnityEditorInternal.VersionControl;
using UnityEngine;
using UnityEngine.UI;
public class InitInfo : MonoBehaviour
{
private MainObject parsedData;
private Username userdata;
public Text name;
// Start is called before the first frame update
private async void Start()
{
string response = await web.SendRequest("http://47.109.133.52/Player/GetInfo", "POST");
Debug.Log(response);
parsedData = JsonUtility.FromJson<MainObject>(response);
Debug.Log(parsedData.Info.Gold);
AssestPanel.instance.SetCoinText(parsedData.Info.Gold);
AssestPanel.instance.SetStoneText(parsedData.Info.Gem);
GetListByPhone getlistbyphone = new GetListByPhone();
getlistbyphone.Phone = "1";
string jsonString = JsonUtility.ToJson(getlistbyphone);
string userponse = await web.SendRequest("http://47.109.133.52/Player/GetListByPhone", "POST", jsonString);
Debug.Log(userponse);
userdata = JsonUtility.FromJson<Username>(userponse);
Debug.Log(userdata.ErrorCode);
//name.text=userdata.nameitem.Name;
}
// Update is called once per frame
void Update()
{
}
}
public class MainObject
{
public Info Info;
public int ErrorCode;
public string ErrorMessage;
}
[Serializable]
public class Info
{
public string Id;
public int Gold;
public int Gem;
public string Phone;
public string Name;
}
public class Username
{
public List<nameitem> namelist;
public int ErrorCode;
public string ErrorMessage;
}
public class nameitem
{
public string Id;
public string Phone;
public string Name;
}