2021-04-16 17:49:11 +08:00
|
|
|
|
using Assets.Scripts;
|
|
|
|
|
|
using Assets.Scripts.Apis;
|
|
|
|
|
|
using System.Collections;
|
2021-03-25 16:53:39 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using UnityEngine;
|
2021-04-16 17:49:11 +08:00
|
|
|
|
using UnityEngine.SceneManagement;
|
2021-03-29 09:10:59 +08:00
|
|
|
|
using UnityEngine.UI;
|
2021-04-23 09:22:12 +08:00
|
|
|
|
using UnityEngine.EventSystems;
|
2021-03-25 16:53:39 +08:00
|
|
|
|
|
2021-03-30 14:23:41 +08:00
|
|
|
|
public class UserInfoController : PFUIPanel
|
2021-03-25 16:53:39 +08:00
|
|
|
|
{
|
|
|
|
|
|
// Start is called before the first frame update
|
2021-04-16 17:49:11 +08:00
|
|
|
|
UserApi userApi;
|
|
|
|
|
|
Transform infoPanel,summaryPanel;
|
2021-09-02 14:18:26 +08:00
|
|
|
|
protected override void Awake()
|
2021-03-25 16:53:39 +08:00
|
|
|
|
{
|
|
|
|
|
|
this.transform.localPosition = new Vector3(0, 0, 0);
|
2021-03-29 09:10:59 +08:00
|
|
|
|
Button exitBtn = this.transform.Find("InfoPanel").Find("Button").GetComponent<Button>();
|
2022-02-11 13:46:38 +08:00
|
|
|
|
#if UNITY_ANDROID || UNITY_IOS
|
2022-01-27 14:11:28 +08:00
|
|
|
|
UIManager.AddEvent(transform.Find("InfoButton").gameObject, EventTriggerType.PointerClick, b =>
|
|
|
|
|
|
{
|
|
|
|
|
|
UIManager.ShowAppleInfoModal(() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
Load();
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
2022-02-11 13:46:38 +08:00
|
|
|
|
#endif
|
2021-04-23 09:22:12 +08:00
|
|
|
|
UIManager.AddEvent(exitBtn.gameObject, EventTriggerType.PointerClick, (b) =>
|
2021-03-29 09:10:59 +08:00
|
|
|
|
{
|
2021-04-23 15:36:18 +08:00
|
|
|
|
UIManager.ShowPrePanel();
|
|
|
|
|
|
//UIManager.ShowHomePanel();
|
2021-03-29 09:10:59 +08:00
|
|
|
|
});
|
2021-04-19 15:44:11 +08:00
|
|
|
|
//exitBtn.onClick.AddListener(() =>
|
|
|
|
|
|
//{
|
|
|
|
|
|
// UIManager.ShowHomePanel();
|
|
|
|
|
|
//});
|
2021-04-16 17:49:11 +08:00
|
|
|
|
UIManager.AddEvent(transform.Find("InfoPanel").Find("SwitchAccountButton").gameObject,
|
2021-04-23 09:22:12 +08:00
|
|
|
|
EventTriggerType.PointerClick, (b) =>
|
2021-04-16 17:49:11 +08:00
|
|
|
|
{
|
2021-08-26 09:29:35 +08:00
|
|
|
|
UIManager.SwitchAccount();
|
2021-04-16 17:49:11 +08:00
|
|
|
|
});
|
|
|
|
|
|
infoPanel = transform.Find("InfoPanel").Find("P");
|
2021-04-23 15:36:18 +08:00
|
|
|
|
|
2021-04-16 17:49:11 +08:00
|
|
|
|
Button editBtn = infoPanel.Find("EditButton").GetComponent<Button>();
|
2021-04-23 09:22:12 +08:00
|
|
|
|
UIManager.AddEvent(editBtn.gameObject, EventTriggerType.PointerClick, (b) =>
|
2021-04-19 15:44:11 +08:00
|
|
|
|
{
|
|
|
|
|
|
UIManager.ShowEditUserPanel();
|
|
|
|
|
|
});
|
2021-08-09 16:32:47 +08:00
|
|
|
|
UIManager.AddEvent(infoPanel.Find("Avatar").gameObject, EventTriggerType.PointerClick, (b) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
UIManager.ShowEditUserPanel();
|
|
|
|
|
|
});
|
2021-04-19 15:44:11 +08:00
|
|
|
|
//editBtn.onClick.AddListener(() =>
|
|
|
|
|
|
//{
|
|
|
|
|
|
// UIManager.ShowEditUserPanel();
|
|
|
|
|
|
//});
|
2021-08-25 14:32:49 +08:00
|
|
|
|
#if UNITY_ANDROID || UNITY_IOS
|
|
|
|
|
|
editBtn.gameObject.SetActive(true);
|
|
|
|
|
|
var recordBtn = infoPanel.Find("RecordButton");
|
2021-08-26 09:29:35 +08:00
|
|
|
|
UIManager.AddEvent(recordBtn.gameObject, EventTriggerType.PointerClick, (b) =>
|
2021-08-25 14:32:49 +08:00
|
|
|
|
{
|
2021-08-26 09:29:35 +08:00
|
|
|
|
Debug.Log(62);
|
|
|
|
|
|
UIManager.ShowResultListPanel();
|
2021-08-25 14:32:49 +08:00
|
|
|
|
});
|
|
|
|
|
|
#else
|
2021-04-23 15:36:18 +08:00
|
|
|
|
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);
|
|
|
|
|
|
});
|
2021-08-25 14:32:49 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
|
2021-04-16 17:49:11 +08:00
|
|
|
|
summaryPanel = transform.Find("SummaryPanel");
|
2021-07-23 09:04:56 +08:00
|
|
|
|
//创建比赛
|
2021-08-25 14:32:49 +08:00
|
|
|
|
#if !(UNITY_ANDROID || UNITY_IOS)
|
2021-07-23 09:04:56 +08:00
|
|
|
|
var createBtn = summaryPanel.Find("CreateBtn").gameObject;
|
|
|
|
|
|
UIManager.AddEvent(createBtn, EventTriggerType.PointerClick, (b) =>
|
|
|
|
|
|
{
|
2021-08-11 10:30:23 +08:00
|
|
|
|
Application.OpenURL(App.CurrentUser.WebHost + "Mine/EditMatch?Token=" + App.CurrentUser.cookie);
|
2021-07-23 09:04:56 +08:00
|
|
|
|
});
|
2021-08-25 14:32:49 +08:00
|
|
|
|
#endif
|
2021-04-21 11:19:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
public override void Show()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.Show();
|
2021-04-16 17:49:11 +08:00
|
|
|
|
Load();
|
2021-08-25 14:32:49 +08:00
|
|
|
|
#if !(UNITY_ANDROID || UNITY_IOS)
|
2021-04-29 23:45:29 +08:00
|
|
|
|
if (summaryPanel != null)
|
2021-04-29 22:05:19 +08:00
|
|
|
|
{
|
2021-04-29 23:45:29 +08:00
|
|
|
|
summaryPanel.Find("Panel").Find("RideResultList").GetComponent<ResultListController>().Load();
|
2021-04-29 22:05:19 +08:00
|
|
|
|
}
|
2021-08-25 14:32:49 +08:00
|
|
|
|
#endif
|
2021-03-25 16:53:39 +08:00
|
|
|
|
}
|
2021-04-30 21:09:21 +08:00
|
|
|
|
async void Load()
|
2021-04-16 17:49:11 +08:00
|
|
|
|
{
|
2021-04-19 18:16:56 +08:00
|
|
|
|
//if (!App.FromLogin)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// var result = await userApi.Login("15651831367", "123456", "");
|
|
|
|
|
|
// App.CurrentUser = result.data;
|
|
|
|
|
|
//}
|
2022-05-25 18:40:47 +08:00
|
|
|
|
Utils.DisplayHead(infoPanel.Find("Avatar").GetComponent<RawImage>(), App.CurrentUser.WxHeadImg);
|
2021-04-30 21:09:21 +08:00
|
|
|
|
var r = await ConfigHelper.userApi.GetSummary();
|
2021-04-16 17:49:11 +08:00
|
|
|
|
if (r.result)
|
|
|
|
|
|
{
|
|
|
|
|
|
var summary = r.data;
|
|
|
|
|
|
var user = App.CurrentUser;
|
2021-07-30 14:01:10 +08:00
|
|
|
|
Debug.Log(user.CanCreateRace);
|
2022-02-11 13:46:38 +08:00
|
|
|
|
if(infoPanel == null) infoPanel = transform.Find("InfoPanel").Find("P");
|
|
|
|
|
|
if(summaryPanel == null) summaryPanel = transform.Find("SummaryPanel");
|
2021-05-20 20:00:33 +08:00
|
|
|
|
Utils.DisplayHead(infoPanel.Find("Avatar").GetComponent<RawImage>(), user.WxHeadImg);
|
2022-02-11 13:46:38 +08:00
|
|
|
|
#if UNITY_ANDROID || UNITY_IOS
|
2022-01-27 14:11:28 +08:00
|
|
|
|
transform.Find("InfoButton").gameObject.SetActive(string.IsNullOrEmpty(user.Phone));
|
2022-02-11 13:46:38 +08:00
|
|
|
|
#endif
|
2021-04-16 17:49:11 +08:00
|
|
|
|
infoPanel.Find("Status").Find("Country").GetComponent<RawImage>().texture
|
|
|
|
|
|
= UIManager.Instance.loginRegOptions.GetCountryImageByName(user.Country);
|
2022-01-27 14:11:28 +08:00
|
|
|
|
//infoPanel.Find("Status").Find("Wx").gameObject.SetActive(
|
|
|
|
|
|
// !string.IsNullOrEmpty(user.Unionid));
|
2021-04-23 09:22:12 +08:00
|
|
|
|
infoPanel.Find("IdText").GetComponent<Text>().text = $"ID:{user.Id.ToString("000000")}";
|
2021-04-16 17:49:11 +08:00
|
|
|
|
infoPanel.Find("NameText").GetComponent<Text>().text = $"{user.Nickname}";
|
|
|
|
|
|
infoPanel.Find("EmailText").GetComponent<Text>().text = $"{user.Phone}";
|
2021-04-23 15:36:18 +08:00
|
|
|
|
infoPanel.Find("DescText").GetComponent<Text>().text = $"{summary.Tips}";
|
2021-08-25 14:32:49 +08:00
|
|
|
|
#if UNITY_IOS || UNITY_ANDROID
|
|
|
|
|
|
infoPanel.Find("Container/Ftp").Find("Value").GetComponent<Text>().text = user.FTP.ToString();
|
|
|
|
|
|
infoPanel.Find("Container/MHR").Find("Value").GetComponent<Text>().text = user.MaxHeartRate.ToString();
|
2022-01-05 17:40:12 +08:00
|
|
|
|
infoPanel.Find("Container/Weight").Find("Value").GetComponent<Text>().text = $"{user.Weight}";
|
|
|
|
|
|
infoPanel.Find("Container/BW").Find("Value").GetComponent<Text>().text = $"{user.BicycleWeight}";
|
|
|
|
|
|
infoPanel.Find("Container/WD").Find("Value").GetComponent<Text>().text = $"{user.WheelDiameter}";
|
2021-12-30 16:51:04 +08:00
|
|
|
|
infoPanel.Find("Container/Ftp").Find("Time").GetComponent<Text>().text = user.LastUpdateFtpTime.ToLocalString("dd-MM-yyyy");
|
|
|
|
|
|
infoPanel.Find("Container/Weight").Find("Time").GetComponent<Text>().text = user.LastUpdateWeightTime.ToLocalString("dd-MM-yyyy");
|
|
|
|
|
|
infoPanel.Find("Container/BW").Find("Time").GetComponent<Text>().text = user.LastUpdateBicycleWeightTime.ToLocalString("dd-MM-yyyy");
|
|
|
|
|
|
infoPanel.Find("Container/WD").Find("Time").GetComponent<Text>().text = user.LastUpdateWheelStraight.ToLocalString("dd-MM-yyyy");
|
|
|
|
|
|
infoPanel.Find("Container/MHR").Find("Time").GetComponent<Text>().text = user.LastUpdateMaxHeartRate.ToLocalString("dd-MM-yyyy");
|
2021-08-25 14:32:49 +08:00
|
|
|
|
#else
|
2021-04-16 17:49:11 +08:00
|
|
|
|
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";
|
2021-12-30 16:51:04 +08:00
|
|
|
|
infoPanel.Find("Ftp").Find("Time").GetComponent<Text>().text = user.LastUpdateFtpTime.ToLocalString("dd-MM-yyyy");
|
|
|
|
|
|
infoPanel.Find("Weight").Find("Time").GetComponent<Text>().text = user.LastUpdateWeightTime.ToLocalString("dd-MM-yyyy");
|
|
|
|
|
|
infoPanel.Find("BW").Find("Time").GetComponent<Text>().text = user.LastUpdateBicycleWeightTime.ToLocalString("dd-MM-yyyy");
|
|
|
|
|
|
infoPanel.Find("WD").Find("Time").GetComponent<Text>().text = user.LastUpdateWheelStraight.ToLocalString("dd-MM-yyyy");
|
|
|
|
|
|
infoPanel.Find("MHR").Find("Time").GetComponent<Text>().text = user.LastUpdateMaxHeartRate.ToLocalString("dd-MM-yyyy");
|
2021-08-25 14:32:49 +08:00
|
|
|
|
#endif
|
2021-04-27 18:26:30 +08:00
|
|
|
|
if (user.Sex == 2)
|
|
|
|
|
|
{
|
|
|
|
|
|
infoPanel.Find("SexIcon").GetComponent<Image>().sprite = Resources.Load<Sprite>("Images/woman");
|
|
|
|
|
|
}
|
2021-04-28 15:21:06 +08:00
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
infoPanel.Find("SexIcon").GetComponent<Image>().sprite = Resources.Load<Sprite>("Images/man");
|
|
|
|
|
|
}
|
2021-04-16 17:49:11 +08:00
|
|
|
|
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();
|
2021-08-25 14:32:49 +08:00
|
|
|
|
#if !(UNITY_ANDROID || UNITY_IOS)
|
2021-07-30 14:01:10 +08:00
|
|
|
|
summaryPanel.Find("CreateBtn").gameObject.SetActive(user.CanCreateRace);
|
2021-08-25 14:32:49 +08:00
|
|
|
|
#endif
|
2021-04-16 17:49:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2021-05-26 18:04:58 +08:00
|
|
|
|
public void Reset()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (summaryPanel != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
summaryPanel.Find("Panel").Find("RideResultList").GetComponent<ResultListController>().Reset();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-03-25 16:53:39 +08:00
|
|
|
|
// Update is called once per frame
|
|
|
|
|
|
void Update()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|