前两个页面迁移完成

This commit is contained in:
Caiyanpeng committed 2021-03-26 09:50:04 +08:00
1 parent ba324aa68d
commit e7044b3cde
67 files changed
+6373 -3171

No files matched your search

+85
View File
@@ -0,0 +1,85 @@
using Assets.Scripts;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class HomeController : 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>("UI/Prefab/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:
+78
View File
@@ -0,0 +1,78 @@
using Assets.Cyp;
using Assets.Scripts;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class LoginController : MonoBehaviour
{
[SerializeField] InputField phone;
[SerializeField] InputField pwd;
[SerializeField] Button login;
[SerializeField] RawImage loading;
// Start is called before the first frame update
void Start()
{
if (login != null)
{
login.onClick.AddListener(Submit);
}
if (loading != null)
{
loading.texture.wrapMode = TextureWrapMode.Repeat;
}
}
async void Submit()
{
if (phone == null || pwd == null)
{
Utils.showToast(gameObject, "未绑定", 1);
return;
}
//if (string.IsNullOrEmpty(phone.text) || string.IsNullOrEmpty(pwd.text))
//{
// Utils.showToast(gameObject, "请输入信息", 1);
// return;
//}
//var res = await Global.userApi.Login(phone.text, pwd.text, "");
//测试用
var res = await ConfigHelper.userApi.Login("15651831367", "123456", "");
//var res = await NoAuthApi.Login(phone.text, pwd.text);
if (res.result)
{
ConfigHelper.CurrentUser = res.data;
SceneManager.LoadScene("2-Main");
}
else
{
}
}
// Update is called once per frame
void Update()
{
if (phone.isFocused && pwd != null && Input.GetKeyDown(KeyCode.Tab))
{
pwd.ActivateInputField();
}
//if (Input.GetKeyDown(KeyCode.Return) && )
//{
//}
//if (Input.GetKeyDown(KeyCode.Return)) {
// Debug.Log("回车键");
// if (pwd.isFocused)
// {
// this.Submit();
// }
//}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 56b7510faf14fb04ab59d33b95cbc4a1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: