167 lines
4.9 KiB
C#
167 lines
4.9 KiB
C#
using Newtonsoft.Json;
|
||
using System;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using System.Threading.Tasks;
|
||
using TMPro;
|
||
using UnityEngine;
|
||
using UnityEngine.UI;
|
||
|
||
public class PerSonalCenterPanel : MonoBehaviour
|
||
{
|
||
public Button invitefriendsBtn;
|
||
public GameObject invitefriendsPanel;
|
||
public GameObject editPanel;
|
||
public UserInfomation14 userInfomation14;
|
||
public Text nickName;
|
||
public Text id;
|
||
public TextMeshProUGUI bindtime;
|
||
|
||
//UI逻辑相关组件
|
||
public Transform trans;
|
||
public Button editBtn;//编辑按钮
|
||
public Button myorderBtn;//我的订单
|
||
public Button realnameBtn;//实名认证
|
||
public Button receivingaddressBtn;//收获地址
|
||
public Button conversionBtn;//转赠
|
||
public Button transformationBtn;//转换
|
||
public Button exchangeBtn;//兑换
|
||
public Button accountsecurityBtn;//账号安全
|
||
//public Button customerserviceBtn;//客户
|
||
|
||
//预制体
|
||
public GameObject editPrefabs;//编辑界面预制体
|
||
public GameObject myorderPrefabs;//我的订单界面预制体
|
||
public GameObject realnamePrefabs;//实名认证界面预制体
|
||
public GameObject receivingaddressPrefabs;//收获地址界面预制体
|
||
public GameObject conversionPrefabs;//转赠界面预制体
|
||
public GameObject transformationPrefabs;//转换界面预制体
|
||
public GameObject exchangePrefabs;//兑换界面预制体
|
||
public GameObject accountsecurityPrefabs;//账号安全界面预制体
|
||
//public GameObject customerservicePrefabs;//客户界面预制体
|
||
|
||
|
||
// Start is called before the first frame update
|
||
void Start()
|
||
{
|
||
GetPlayerInfo();
|
||
|
||
editBtn.onClick.AddListener(EditBtn);
|
||
myorderBtn.onClick.AddListener(MyorderBtn);
|
||
realnameBtn.onClick.AddListener(RealnameBtn);
|
||
receivingaddressBtn.onClick.AddListener(ReceivingaddressBtn);
|
||
conversionBtn.onClick.AddListener(ConversionBtn);
|
||
transformationBtn.onClick.AddListener(TransformationBtn);
|
||
exchangeBtn.onClick.AddListener(ExchangeBtn);
|
||
accountsecurityBtn.onClick.AddListener(AccountsecurityBtn);
|
||
//customerserviceBtn.onClick.AddListener(CustomerserviceBtn);
|
||
|
||
}
|
||
|
||
public void EditBtn()
|
||
{
|
||
GameObject ob=Instantiate(editPrefabs, trans);
|
||
ob.GetComponent<EditPanel>().perSonalCenterPanel = this;
|
||
}
|
||
|
||
public void MyorderBtn()
|
||
{
|
||
GameObject.Instantiate(myorderPrefabs, trans);
|
||
}
|
||
|
||
private void RealnameBtn()
|
||
{
|
||
GameObject.Instantiate(realnamePrefabs, trans);
|
||
}
|
||
|
||
private void ReceivingaddressBtn()
|
||
{
|
||
GameObject.Instantiate(receivingaddressPrefabs, trans);
|
||
}
|
||
|
||
private void ConversionBtn()
|
||
{
|
||
GameObject.Instantiate(conversionPrefabs, trans);
|
||
}
|
||
|
||
private void TransformationBtn()
|
||
{
|
||
GameObject.Instantiate(transformationPrefabs, trans);
|
||
}
|
||
|
||
private void ExchangeBtn()
|
||
{
|
||
GameObject.Instantiate(exchangePrefabs, trans);
|
||
}
|
||
|
||
private void AccountsecurityBtn()
|
||
{
|
||
GameObject.Instantiate(accountsecurityPrefabs, trans);
|
||
}
|
||
|
||
|
||
|
||
// 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 void 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;
|
||
id.text = "ID:"+ userInfomation14.data.cuteNo;
|
||
DateTime bindDateTime = DateTime.Parse(userInfomation14.data.bindTime);
|
||
|
||
// 获取当前时间
|
||
DateTime currentDateTime = DateTime.Now;
|
||
|
||
// 计算时间差
|
||
TimeSpan timeDifference = currentDateTime - bindDateTime;
|
||
bindtime.text = "" + timeDifference.Days + "天" + timeDifference.Hours + ":" + timeDifference.Minutes + ":" +
|
||
timeDifference.Seconds;
|
||
// 解析服务器返回的数据
|
||
Global.global.response = JsonConvert.DeserializeObject<ServerResponse>(response14);
|
||
|
||
// 不需要返回值,只需表示异步操作完成
|
||
//await Task.CompletedTask; // 或者直接返回,不使用 await
|
||
}
|
||
}
|