_TheStrongestSnail/TheStrongestSnail/Assets/Scripts/LqUiScripts/PerSonalCenterPanel.cs
2024-11-26 00:40:56 +08:00

66 lines
2.0 KiB
C#

using Newtonsoft.Json;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;
public class PerSonalCenterPanel : MonoBehaviour
{
public Button invitefriendsBtn;
public GameObject invitefriendsPanel;
public GameObject editPanel;
public UserInfomation14 userInfomation14;
public Text nickName;
// Start is called before the first frame update
void Start()
{
GetPlayerInfo();
}
// Update is called once per frame
void Update()
{
}
void SetPlayerName()
{
}
public void SetInviteFriendsPanel()
{
invitefriendsPanel.gameObject.SetActive(true);
transform.gameObject.SetActive(false);
}
public void SetEditPanel()
{
editPanel.gameObject.SetActive(true);
}
public void SetPerSonalCenterPanel()
{
transform.gameObject.SetActive(false);
}
public async Task GetPlayerInfo() // 1.4
{
// 准备请求的头部信息,包含授权令牌
Dictionary<string, string> head14 = new Dictionary<string, string>
{
{ "Authorization", Global.global.serverResponse.data.token }
};
// 异步查询玩家信息
string response14 = await web.SendRequest(web.URL + "/snail/user/queryUserInfo", "POST", "{}", head14);
Debug.Log("1.4查询玩家信息" + response14);
userInfomation14 = JsonConvert.DeserializeObject<UserInfomation14>(response14);
Debug.Log("玩家剩余蜗蛋:" + userInfomation14.data.beansCoin);
//Money = userInfomation14.beansCoin;
Debug.Log("&&&&&&&&&&&&&&&&&&&&7" + userInfomation14.data.nickName);
nickName.text = userInfomation14.data.nickName;
// 解析服务器返回的数据
Global.global.response = JsonConvert.DeserializeObject<ServerResponse>(response14);
// 不需要返回值,只需表示异步操作完成
await Task.CompletedTask; // 或者直接返回,不使用 await
}
}