126 lines
5.6 KiB
C#
126 lines
5.6 KiB
C#
using Assets.Scripts;
|
|
using Assets.Scripts.Apis;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
using UnityEngine.UI;
|
|
using UnityEngine.EventSystems;
|
|
|
|
public class UserInfoController : PFUIPanel
|
|
{
|
|
// Start is called before the first frame update
|
|
UserApi userApi;
|
|
Transform infoPanel,summaryPanel;
|
|
protected override void Awake()
|
|
{
|
|
this.transform.localPosition = new Vector3(0, 0, 0);
|
|
|
|
Button exitBtn = this.transform.Find("InfoPanel").Find("Button").GetComponent<Button>();
|
|
|
|
UIManager.AddEvent(exitBtn.gameObject, EventTriggerType.PointerClick, (b) =>
|
|
{
|
|
UIManager.ShowPrePanel();
|
|
//UIManager.ShowHomePanel();
|
|
});
|
|
//exitBtn.onClick.AddListener(() =>
|
|
//{
|
|
// UIManager.ShowHomePanel();
|
|
//});
|
|
UIManager.AddEvent(transform.Find("InfoPanel").Find("SwitchAccountButton").gameObject,
|
|
EventTriggerType.PointerClick, (b) =>
|
|
{
|
|
UIManager.ShowConfirm("Logout", "Do you want to log out and change accounts?", () =>
|
|
{
|
|
SceneManager.LoadScene("1-Login");
|
|
UIManager.CloseConfirm();
|
|
});
|
|
});
|
|
infoPanel = transform.Find("InfoPanel").Find("P");
|
|
|
|
Button editBtn = infoPanel.Find("EditButton").GetComponent<Button>();
|
|
UIManager.AddEvent(editBtn.gameObject, EventTriggerType.PointerClick, (b) =>
|
|
{
|
|
UIManager.ShowEditUserPanel();
|
|
});
|
|
//editBtn.onClick.AddListener(() =>
|
|
//{
|
|
// UIManager.ShowEditUserPanel();
|
|
//});
|
|
UIManager.AddEvent(transform.Find("InfoPanel").gameObject, EventTriggerType.PointerEnter, (b) =>
|
|
{
|
|
editBtn.gameObject.SetActive(true);
|
|
});
|
|
UIManager.AddEvent(transform.Find("InfoPanel").gameObject, EventTriggerType.PointerExit, (b) =>
|
|
{
|
|
editBtn.gameObject.SetActive(false);
|
|
});
|
|
summaryPanel = transform.Find("SummaryPanel");
|
|
}
|
|
public override void Show()
|
|
{
|
|
base.Show();
|
|
Load();
|
|
}
|
|
void Load()
|
|
{
|
|
//if (!App.FromLogin)
|
|
//{
|
|
// var result = await userApi.Login("15651831367", "123456", "");
|
|
// App.CurrentUser = result.data;
|
|
//}
|
|
var r = ConfigHelper.userApi.GetSummary();
|
|
if (r.result)
|
|
{
|
|
var summary = r.data;
|
|
var user = App.CurrentUser;
|
|
if (!string.IsNullOrEmpty(user.WxHeadImg))
|
|
{
|
|
Utils.DisplayImage(StartCoroutine, infoPanel.Find("Avatar").GetComponent<RawImage>(), user.WxHeadImg);
|
|
}
|
|
else
|
|
{
|
|
infoPanel.Find("Avatar").GetComponent<RawImage>().texture = Resources.Load<Texture>("Images/icon-1024");
|
|
}
|
|
|
|
infoPanel.Find("Status").Find("Country").GetComponent<RawImage>().texture
|
|
= UIManager.Instance.loginRegOptions.GetCountryImageByName(user.Country);
|
|
infoPanel.Find("Status").Find("Wx").gameObject.SetActive(
|
|
!string.IsNullOrEmpty(user.Unionid));
|
|
infoPanel.Find("IdText").GetComponent<Text>().text = $"ID:{user.Id.ToString("000000")}";
|
|
infoPanel.Find("NameText").GetComponent<Text>().text = $"{user.Nickname}";
|
|
infoPanel.Find("EmailText").GetComponent<Text>().text = $"{user.Phone}";
|
|
infoPanel.Find("DescText").GetComponent<Text>().text = $"{summary.Tips}";
|
|
infoPanel.Find("Ftp").Find("Value").GetComponent<Text>().text = user.FTP.ToString();
|
|
infoPanel.Find("MHR").Find("Value").GetComponent<Text>().text = user.MaxHeartRate.ToString();
|
|
infoPanel.Find("Weight").Find("Value").GetComponent<Text>().text = $"{user.Weight}KG";
|
|
infoPanel.Find("BW").Find("Value").GetComponent<Text>().text = $"{user.BicycleWeight}KG";
|
|
infoPanel.Find("WD").Find("Value").GetComponent<Text>().text = $"{user.WheelDiameter}MM";
|
|
infoPanel.Find("Ftp").Find("Time").GetComponent<Text>().text = user.LastUpdateFtpTime.ToString("yyyy-MM-dd");
|
|
infoPanel.Find("Weight").Find("Time").GetComponent<Text>().text = user.LastUpdateWeightTime.ToString("yyyy-MM-dd");
|
|
infoPanel.Find("BW").Find("Time").GetComponent<Text>().text = user.LastUpdateBicycleWeightTime.ToString("yyyy-MM-dd");
|
|
infoPanel.Find("WD").Find("Time").GetComponent<Text>().text = user.LastUpdateWheelStraight.ToString("yyyy-MM-dd");
|
|
infoPanel.Find("MHR").Find("Time").GetComponent<Text>().text = user.LastUpdateMaxHeartRate.ToString("yyyy-MM-dd");
|
|
if (user.Sex == 2)
|
|
{
|
|
infoPanel.Find("SexIcon").GetComponent<Image>().sprite = Resources.Load<Sprite>("Images/woman");
|
|
}
|
|
else
|
|
{
|
|
infoPanel.Find("SexIcon").GetComponent<Image>().sprite = Resources.Load<Sprite>("Images/man");
|
|
}
|
|
summaryPanel.Find("Number").Find("Value").GetComponent<Text>().text = summary.Count.ToString();
|
|
summaryPanel.Find("Time").Find("Value").GetComponent<Text>().text = summary.TotalTicks.ToString();
|
|
summaryPanel.Find("KM").Find("Value").GetComponent<Text>().text = summary.TotalDistance.ToString();
|
|
summaryPanel.Find("Climb").Find("Value").GetComponent<Text>().text = summary.TotalClimb.ToString();
|
|
summaryPanel.Find("Calories").Find("Value").GetComponent<Text>().text = summary.TotalKj.ToString();
|
|
}
|
|
|
|
}
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
}
|