157 lines
4.0 KiB
C#
157 lines
4.0 KiB
C#
using Newtonsoft.Json;
|
|
using System;
|
|
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;
|
|
|
|
|
|
//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.Instantiate(editPrefabs, trans);
|
|
}
|
|
|
|
public void MyorderBtn()
|
|
{
|
|
|
|
}
|
|
|
|
private void RealnameBtn()
|
|
{
|
|
|
|
}
|
|
|
|
private void ReceivingaddressBtn()
|
|
{
|
|
|
|
}
|
|
|
|
private void ConversionBtn()
|
|
{
|
|
|
|
}
|
|
|
|
private void TransformationBtn()
|
|
{
|
|
|
|
}
|
|
|
|
private void ExchangeBtn()
|
|
{
|
|
|
|
}
|
|
|
|
private void AccountsecurityBtn()
|
|
{
|
|
|
|
}
|
|
|
|
private void CustomerserviceBtn()
|
|
{
|
|
|
|
}
|
|
|
|
// 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;
|
|
// 解析服务器返回的数据
|
|
Global.global.response = JsonConvert.DeserializeObject<ServerResponse>(response14);
|
|
|
|
// 不需要返回值,只需表示异步操作完成
|
|
//await Task.CompletedTask; // 或者直接返回,不使用 await
|
|
}
|
|
}
|