主场景迁移
This commit is contained in:
1 parent
ba994e715c
commit
ba324aa68d
18 files changed
+94
-13
No files matched your search
@@ -0,0 +1,85 @@
|
||||
using Assets.Scripts;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class UserInfo : MonoBehaviour
|
||||
{
|
||||
[SerializeField] Text Ftp;
|
||||
[SerializeField] RawImage Avatar;
|
||||
[SerializeField] Text Weight;
|
||||
[SerializeField] Text WKG;
|
||||
[SerializeField] Text Calories;
|
||||
[SerializeField] Text KM;
|
||||
[SerializeField] Text Climb;
|
||||
[SerializeField] Text NickName;
|
||||
[SerializeField] Button More;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
var parent = Utils.FindUpParent(gameObject.transform);
|
||||
if (parent.Find("ToastContainer") == null)
|
||||
{
|
||||
var toast = Instantiate(Resources.Load<GameObject>("ToastContainer"));
|
||||
toast.name = "ToastContainer";
|
||||
toast.GetComponent<RectTransform>().position = new Vector3(Screen.width / 2, Screen.height / 2, 0);
|
||||
toast.transform.parent = parent;
|
||||
}
|
||||
if (ConfigHelper.CurrentUser != null)
|
||||
{
|
||||
SetCurrentUser();
|
||||
GetSummary();
|
||||
}
|
||||
if (More != null)
|
||||
{
|
||||
More.onClick.AddListener(MoreFunc);
|
||||
}
|
||||
}
|
||||
|
||||
void MoreFunc()
|
||||
{
|
||||
Utils.showToast(gameObject, "更多信息", 1);
|
||||
}
|
||||
|
||||
void SetCurrentUser()
|
||||
{
|
||||
var user = ConfigHelper.CurrentUser;
|
||||
Ftp.text = user.FTP.ToString();
|
||||
Weight.text = user.Weight.ToString();
|
||||
WKG.text = $"{user.Weight}KG/{user.BicycleWeight}KG";
|
||||
NickName.text = user.Nickname;
|
||||
Utils.DisplayImage(StartCoroutine, Avatar, user.WxHeadImg);
|
||||
}
|
||||
void GetSummary()
|
||||
{
|
||||
var res = ConfigHelper.userApi.GetSummary();
|
||||
if (res.result)
|
||||
{
|
||||
KM.text = $"{res.data.TotalDistance.ToString("#0.00")}KM";
|
||||
Climb.text = $"{res.data.TotalClimb.ToString()}M";
|
||||
Calories.text = $"{res.data.Kcal.ToString()}KCAL";
|
||||
//Calories.text = res.data.
|
||||
}
|
||||
else
|
||||
{
|
||||
Utils.showToast(gameObject, res.errMsg);
|
||||
}
|
||||
//var res = await NoAuthApi.GetCurrentUser();
|
||||
//if (res.result)
|
||||
//{
|
||||
// Global.CurrentUser = res.data;
|
||||
// SetCurrentUser();
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// Utils.showToast(gameObject, res.errMsg);
|
||||
//}
|
||||
}
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 32d45078acd8c0341bc9d900a607ebcd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in new issue
Block a user