Merge remote-tracking branch 'origin/dev' into dev_lishuo

# Conflicts:
#	Assets/Resources/Apis/Models.meta
#	Assets/Scripts/UI/Prefab/ResultList/RouteItem.cs
This commit is contained in:
lishuo committed 2021-04-19 14:40:43 +08:00
commit af63072f29
101 files changed
+11247 -12377

No files matched your search

+21 -4
View File
@@ -43,6 +43,13 @@ namespace Assets.Scripts.UI.Control
//var image = this.transform.GetComponent<Image>();
// var png = Resources.Load<Sprite>("Images/ipt-1");
//image.sprite = png;
var _text = mInnerInputField.transform.Find("Text").GetComponent<Text>();
if (_text.color!=Color.white)
{
Text = "";
}
_text.color = Color.white;
outline.enabled = true;
ColorUtility.TryParseHtmlString("#F93086", out Color color);
@@ -83,7 +90,7 @@ namespace Assets.Scripts.UI.Control
outline.enabled = false;
}
UIManager.AddEvent(this.mInnerInputField.gameObject, EventTriggerType.PointerClick, new UnityAction<BaseEventData>(this.OnSelect));
//UIManager.AddEvent(this.mInnerInputField.gameObject, EventTriggerType.PointerClick, new UnityAction<BaseEventData>(this.OnSelect));
UIManager.AddEvent(this.mInnerInputField.gameObject, EventTriggerType.Select, new UnityAction<BaseEventData>(this.OnSelect));
UIManager.AddEvent(this.mInnerInputField.gameObject, EventTriggerType.Deselect, new UnityAction<BaseEventData>(this.OnDeselect));
UIManager.AddEvent(this.mInnerInputField.gameObject, EventTriggerType.PointerEnter, new UnityAction<BaseEventData>((e) =>
@@ -112,13 +119,23 @@ namespace Assets.Scripts.UI.Control
{
if (value)
{
this.mInnerInputField.GetComponent<Text>().color = Color.white;
outline.enabled = true;
outline.effectColor = Utils.HexToColorHtml("#F93086");
ColorUtility.TryParseHtmlString("#F93086", out Color color);
this.mInnerInputField.transform.Find("Text").GetComponent<Text>().color = color;
}
else
{
ColorUtility.TryParseHtmlString("#F93086", out Color color);
this.mInnerInputField.GetComponent<Text>().color = color;
this.mInnerInputField.transform.Find("Text").GetComponent<Text>().color = Color.white;
outline.enabled = false;
}
}
public void SetValidate(string msg)
{
this.mInnerInputField.transform.Find("Text").GetComponent<Text>().color = Utils.HexToColorHtml("#F93086");
Text = msg;
outline.enabled = true;
outline.effectColor = Utils.HexToColorHtml("#F93086");
}
}
}
+7 -1
View File
@@ -4,10 +4,16 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;
namespace Assets.Scripts.UI.Control
{
public class PfText : PFUIComponentBase
[RequireComponent(typeof(Text))]
public class PFUIText : PFUIComponentBase
{
protected void Awake()
{
}
}
}
+29 -9
View File
@@ -8,7 +8,7 @@ using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class Item : MonoBehaviour, IPointerClickHandler
public class Item : PFUIPanel //, IPointerClickHandler
{
private Text text;
@@ -49,7 +49,8 @@ public class Item : MonoBehaviour, IPointerClickHandler
}
}
public Action onClick;
private void Awake()
private Transform hot;
protected override void Awake()
{
text = this.transform.Find("name").GetComponent<Text>();
km = this.transform.Find("km").GetComponent<Text>();
@@ -63,6 +64,11 @@ public class Item : MonoBehaviour, IPointerClickHandler
var rect = ((RectTransform)transform).rect;
material.SetVector(Shader.PropertyToID("_WidthHeightRadius"), new Vector4(rect.width, rect.height, rect.height * 0.5f, 0));
this.GetComponent<Image>().material = material;
hot = this.transform.Find("Hot");
SetRounded(hot, 17);
UIManager.AddEvent(this.gameObject, EventTriggerType.PointerClick, OnPointerClick);
}
public void Selected(bool value)
@@ -74,28 +80,42 @@ public class Item : MonoBehaviour, IPointerClickHandler
this.GetComponent<UIGradient>().color2 = Utils.HexToColor("F93086");
this.GetComponent<Image>().color = Color.white;
this.transform.Find("km").GetComponent<Text>().color = Color.white;
this.transform.Find("count").GetComponent<Text>().color = Color.white;
km.color = Color.white;
count.color = Color.white;
this.transform.Find("DistanceIcon").GetComponent<Image>().color = Color.white;
this.transform.Find("BikeIcon").GetComponent<Image>().color = Color.white;
hot.GetComponent<UIGradient>().color1 = Color.white;
hot.GetComponent<UIGradient>().color2 = Color.white;
hot.Find("PFUIText").GetComponent<Text>().color = Utils.HexToColor("F93086");
}
else
{
this.GetComponent<UIGradient>().enabled = false;
this.GetComponent<Image>().color = Utils.HexToColor("353543");
this.transform.Find("km").GetComponent<Text>().color = Utils.HexToColor("5C5C6E");
this.transform.Find("count").GetComponent<Text>().color = Utils.HexToColor("F93086");
km.color = Utils.HexToColor("5C5C6E");
count.color = Utils.HexToColor("F93086");
this.transform.Find("DistanceIcon").GetComponent<Image>().color = Utils.HexToColor("5C5C6E");
this.transform.Find("BikeIcon").GetComponent<Image>().color = Utils.HexToColor("F93086");
hot.GetComponent<UIGradient>().color1 = Utils.HexToColor("FF7485");
hot.GetComponent<UIGradient>().color2 = Utils.HexToColor("F93086");
hot.Find("PFUIText").GetComponent<Text>().color = Color.white;
}
}
public void SetModel(NearRouteModel model)
{
this.Text = model.Name;
this.Distance = model.Distance + "KM";
this.Distance = model.Distance.ToString("0.0") + "KM";
this.Count = model.TheHeat.ToString();
}
// Start is called before the first frame update
void Start()
protected override void Start()
{
}
@@ -106,7 +126,7 @@ public class Item : MonoBehaviour, IPointerClickHandler
}
public void OnPointerClick(PointerEventData eventData)
public void OnPointerClick(BaseEventData eventData)
{
if(onClick != null)
{
+17 -6
View File
@@ -9,6 +9,7 @@ using UnityEngine.SceneManagement;
using UnityEngine.UI;
using System;
using System.Linq;
using Assets.Scripts;
public class Tips : MonoBehaviour
{
@@ -30,6 +31,7 @@ public class Tips : MonoBehaviour
private List<CountryModel> countryList;
private GameObject level;
private GameObject m3DIcon;
private RawImage altitudeGraph;
private void Awake()
{
var materialSource = Resources.Load<Material>("UI/Material/RoundedCornersTextureMaterial");
@@ -63,6 +65,8 @@ public class Tips : MonoBehaviour
level.GetComponent<Image>().material = material1;
m3DIcon = this.transform.Find("3DIcon").gameObject;
altitudeGraph = this.transform.Find("AltitudeGraph").GetComponent<RawImage>();
}
// Start is called before the first frame update
@@ -81,7 +85,7 @@ public class Tips : MonoBehaviour
{
if (this.isActiveAndEnabled)
{
if(_model.Id == model.Id)
if(_model != null && _model.Id == model.Id)
{
//this.gameObject.SetActive(false);
return;
@@ -94,10 +98,10 @@ public class Tips : MonoBehaviour
Name.text = _model.Name;
Count.text = _model.TheHeat.ToString();
Distance.text = _model.Distance.ToString("#.0")+"KM";
TotalClimb.text = _model.TotalClimb.ToString();
Distance.text = _model.Distance.ToString("0.0")+"KM";
TotalClimb.text = _model.TotalClimb.ToString("0") +"FT";
averageGrade.text = _model.AverageGrade.ToString() + "%";
averageGrade.text = _model.AverageGrade.ToString("0.0") + "%";
//var country = countryList.SingleOrDefault(r => r.abbreviation.Equals(_model.CountryCode, StringComparison.InvariantCultureIgnoreCase));
//if(country )
@@ -110,7 +114,12 @@ public class Tips : MonoBehaviour
level.transform.Find("Text").GetComponent<Text>().text = _model.Hard;
m3DIcon.SetActive(_model.Enable3D);
//altitudeGraph
Utils.DisplayImage(StartCoroutine, altitudeGraph, _model.AltitudeGraph);
//Utils.DisplayImage(StartCoroutine, altitudeGraph, "http://192.168.0.97:5082/Map/AltitudeGraph?id=1215");
}
@@ -137,9 +146,11 @@ public class Tips : MonoBehaviour
}
this.transform.localPosition = localPosition;
this.transform.localScale = new Vector2(2, 2);
this.SetModel(model);
//tips.Show();
this.gameObject.SetActive(true);
this.SetModel(model);
}
public void Hide()
{
@@ -42,15 +42,14 @@ public class ConnectDeviceModal : PFUIPanel
var panel = container.Find("Panel");
content = panel.Find("Scroll View").Find("Viewport").Find("Content").GetComponent<VerticalLayoutGroup>();
Material material = null;
if (material == null)
{
material = Instantiate(Resources.Load<Material>("UI/Material/RoundedCornersTextureMaterial"));
}
var rect = ((RectTransform)panel.transform).rect;
material.SetVector(Shader.PropertyToID("_WidthHeightRadius"), new Vector4(rect.width, rect.height, 20f, 0));
panel.GetComponent<Image>().material = material;
//Material material = null;
//if (material == null)
//{
// material = Instantiate(Resources.Load<Material>("UI/Material/RoundedCornersTextureMaterial"));
//}
//var rect = ((RectTransform)panel.transform).rect;
//material.SetVector(Shader.PropertyToID("_WidthHeightRadius"), new Vector4(rect.width, rect.height, 20f, 0));
base.SetRounded(panel.GetComponent<Image>().transform, 20f);
UIManager.AddEvent(closeBtn.gameObject, EventTriggerType.PointerClick, new UnityEngine.Events.UnityAction<BaseEventData>(e =>
{
@@ -65,13 +65,19 @@ namespace Assets.Scripts.UI.Prefab.Login
public Texture GetCountryImage(int index)
{
var c = countryList[index];
if (c == null) return null;
if (c == null) return Resources.Load<Texture>(countryList[countryDefaultValue].source);
return Resources.Load<Texture>(c.source);
}
public Texture GetCountryImage(string code)
{
return GetCountryImage(GetCountryIndexByCode(code));
}
public Texture GetCountryImageByName(string name)
{
var c = countryList.Find(x=>x.country == name);
if (c == null) return Resources.Load<Texture>(countryList[countryDefaultValue].source);
return Resources.Load<Texture>(c.source);
}
public int GetCountryIndexByCode(string code)
{
if (string.IsNullOrEmpty(code))
@@ -80,10 +86,25 @@ namespace Assets.Scripts.UI.Prefab.Login
if (c == -1) return countryDefaultValue;
return c;
}
public int GetCountryIndexByName(string country)
{
var c = countryList.FindIndex(x => x.country == country);
if (c == -1) return countryDefaultValue;
return c;
}
public List<Dropdown.OptionData> GetDayOptions(int year,int month)
{
int day = DateTime.DaysInMonth(year, month);
return DayOptions.dayOption[day];
}
public string GetCountryName(int index)
{
var c = countryList[index];
if (c == null) return countryList[countryDefaultValue].country;
return c.country;
}
}
}
@@ -14,19 +14,23 @@ using UnityEngine.UI;
public class QuickLoginUser : MonoBehaviour
{
QUserInfo user;
Transform top;
// Start is called before the first frame update
void Start()
{
}
public void Initial(QUserInfo user)
public void Initial(QUserInfo user,Transform top)
{
if (user == null) return;
this.top = top;
transform.GetComponent<Button>().onClick.AddListener(async () =>
{
ApiBase.SetCookie(user.Cookie);
var r = await ConfigHelper.userApi.QuickLogin();
if (r.result)
{
//
top.GetComponent<LoginController>().SaveInfo(r.data);
App.CurrentUser = r.data;
//ConfigHelper.CurrentUser = r.data.Value<UserResultModel>("user");
//ConfigHelper.CurrentUser = re;
@@ -83,10 +87,9 @@ public class QuickLoginUser : MonoBehaviour
private void DeleteList(int index)
{
var userInfosJson = PlayerPrefs.GetString("UserInfos");
var userInfos = JsonConvert.DeserializeObject<List<QUserInfo>>(userInfosJson);
var userInfos = UIManager.Instance.userInfos;
userInfos.RemoveAt(index);
PlayerPrefs.SetString("UserInfos", JsonConvert.SerializeObject(userInfos));
UIManager.Instance.userInfos = userInfos;
}
public void setActive()
+123 -7
View File
@@ -1,12 +1,24 @@
using Assets.Scripts;
using Assets.Scripts.Apis;
using Assets.Scripts.Apis.Models;
using DG.Tweening;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class MapItem : MonoBehaviour
public class PropNames
{
public static List<string> icons = new List<string> { "icon1", "icon2", "icon3" };
public static List<string> texts = new List<string> { "DistanceText", "EleText", "SlopeText" };
public static Dictionary<bool, string> colorDict = new Dictionary<bool, string>
{
{ true,"#ffffff"},{false,"#5c5c6e" }
};
}
public class MapItem : MonoBehaviour, IPointerExitHandler, IPointerEnterHandler
{
// Start is called before the first frame update
//[SerializeField] Text text;
@@ -19,20 +31,44 @@ public class MapItem : MonoBehaviour
// Update is called once per frame
void Update()
{
}
float? localY = null;
MapRoute map;
public void Initial(MapRoute myMap)
{
gameObject.GetComponent<Button>().onClick.AddListener(()=>
map = myMap;
//localY = transform.GetComponent<RectTransform>().rect.height;
//Debug.Log(localY);
//UIManager.AddEvent(gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, (Base) =>
//{
// UIManager.ShowMapDetailPanel(myMap.Id);
//});
//UIManager.AddEvent(gameObject, UnityEngine.EventSystems.EventTriggerType.PointerEnter, (Base) =>
//{
// if (localY == null)
// {
// localY = transform.localPosition.y;
// }
// //transform.localPosition.Set(transform.localPosition.x,localY.Value+8, transform.localPosition.z);
// //transform.DOLocalMoveY(localY.Value + 8, 0.5f);
// //transform.domov(localY+8, 0.5f);
//});
//UIManager.AddEvent(gameObject, UnityEngine.EventSystems.EventTriggerType.PointerExit, (Base) =>
//{
// //transform.localPosition.Set(transform.localPosition.x, localY.Value, transform.localPosition.z);
// //transform.DOLocalMoveY(localY.Value, 0.5f);
//});
transform.GetComponent<Button>().onClick.AddListener(() =>
{
Debug.Log(123);
UIManager.ShowMapDetailPanel(myMap.Id);
//SceneManager.LoadScene("4-Demo", LoadSceneMode.Additive);
});
transform.Find("Name").GetComponent<Text>().text = myMap.Name;
Utils.DisplayImage(StartCoroutine, transform.Find("MapTitleImg").GetComponent<RawImage>(), myMap.CoverImage);
transform.Find("CollectImg").gameObject.SetActive(myMap.IsFavorite);
transform.Find("Hot").gameObject.SetActive(myMap.IsFire);
var props = transform.Find("Props");
var props = transform.Find("Props");
props.Find("DistanceText").GetComponent<Text>().text = $"{myMap.Distance.ToString("#0.00")}KM";
props.Find("EleText").GetComponent<Text>().text = $"{(myMap.TotalClimb ?? 0.0).ToString("#0.00")}M";
props.Find("SlopeText").GetComponent<Text>().text = $"{myMap.AverageGrade.ToString("#0.00")}%";
@@ -42,5 +78,85 @@ public class MapItem : MonoBehaviour
diff.Find("Text").GetComponent<Text>().text = myMap.Hard;
tabContainer.Find("3d").gameObject.SetActive(myMap.Enable3D);
tabContainer.Find("Country").GetComponent<RawImage>().texture = UIManager.Instance.loginRegOptions.GetCountryImage(myMap.CountryCode);
transform.Find("CollectImg").GetComponent<Button>().onClick.AddListener(Collect);
transform.Find("CollectImg").gameObject.SetActive(false);
transform.Find("CollectImg").Find("Image").GetComponent<Image>().sprite =
UIManager.Instance.collectDict[myMap.IsFavorite];
transform.Find("BtnInfo").GetComponent<Button>().onClick.AddListener(Info);
transform.Find("BtnRide").GetComponent<Button>().onClick.AddListener(Ride);
Utils.DisplayImage(StartCoroutine, transform.Find("MapHBImg").GetComponent<RawImage>(), myMap.AltitudeGraph);
SetActive4Button(false);
}
private void Ride()
{
App.RouteIdParam = map.Id;
SceneManager.LoadScene("Ride");
}
private void Info()
{
UIManager.ShowMapDetailPanel(map.Id);
}
public void OnPointerEnter(PointerEventData eventData)
{
if (localY == null)
{
localY = transform.localPosition.y;
}
transform.Find("CollectImg").gameObject.SetActive(true);
transform.DOLocalMoveY(localY.Value + 5, 0.5f);
SetActive4Button(true);
SetColor(map.IsFavorite);
}
void SetActive4Button(bool b)
{
transform.Find("MapHBImg").gameObject.SetActive(!b);
transform.Find("BtnInfo").gameObject.SetActive(b);
transform.Find("BtnRide").gameObject.SetActive(b);
}
public void OnPointerExit(PointerEventData eventData)
{
transform.DOLocalMoveY(localY.Value, 0.5f);
transform.Find("CollectImg").gameObject.SetActive(false);
SetActive4Button(false);
SetColor(false);
}
private void SetColor(bool isFav)
{
PropNames.icons.ForEach((v) =>
{
transform.Find("Props").Find(v).GetComponent<Image>().color = Utils.HexToColorHtml(
PropNames.colorDict[isFav]);
});
PropNames.texts.ForEach((v) =>
{
transform.Find("Props").Find(v).GetComponent<Text>().color = Utils.HexToColorHtml(
PropNames.colorDict[isFav]);
});
}
async void Collect()
{
JsonResult<object> r;
if (map.IsFavorite)
{
r = await ConfigHelper.mapApi.CancelFav(map.Id.ToString());
}
else
{
r = await ConfigHelper.mapApi.AddFav(map.Id.ToString());
}
if (r.result)
{
map.IsFavorite = !map.IsFavorite;
transform.Find("CollectImg").Find("Image").GetComponent<Image>().sprite =
UIManager.Instance.collectDict[map.IsFavorite];
SetColor(map.IsFavorite);
}
else
{
UIManager.ShowAlert(r.errMsg);
}
}
}
@@ -0,0 +1,38 @@
using Assets.Scripts;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class NewsController : PFUIPanel
{
// Start is called before the first frame update
void Start()
{
content = transform.Find("Main").Find("Inner").Find("Content");
exit = transform.Find("Main").Find("Exit");
if (exit != null)
{
exit.GetComponent<Button>().onClick.AddListener(() =>
{
Close();
});
}
Get();
}
Transform content,exit;
async void Get()
{
var r = await ConfigHelper.userApi.GetNotify();
if (r.result)
{
content.GetComponent<Text>().text = r.data.Value<string>("Content");
//content.GetComponent<Text>().text
}
}
// Update is called once per frame
void Update()
{
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 71855add6efca96458ac893b08f2dd4a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -39,6 +39,7 @@ public class BigMapController : PFUIPanel
begin = Resources.Load("UI/Prefab/BigMap/Begin");
mapManager = this.transform.Find("Map").GetComponent<AbstractMap>();
mapManager.MaxZoom = 4;
mapManager.OnInitialized += MapManager_OnInitialized;
mapManager.OnUpdated += MapManager_OnUpdated;
@@ -57,7 +58,7 @@ public class BigMapController : PFUIPanel
mapManager.Destroy();
UIManager.ShowMapListPanel();
//this.gameObject.SetActive(false);
DestroyImmediate(this.gameObject);
//DestroyImmediate(this.gameObject);
});
var panel = canvas.transform.Find("Panel");
@@ -91,7 +92,7 @@ public class BigMapController : PFUIPanel
UIManager.AddEvent(headImage.gameObject, EventTriggerType.PointerClick, (e) =>
{
UIManager.ShowEditUserPanel();
UIManager.ShowUserInfoPanel();
});
}
@@ -126,6 +127,8 @@ public class BigMapController : PFUIPanel
}
private void MapManager_OnUpdated()
{
Debug.Log("update");
foreach (var item in linesCache)
{
//if(item.Value.LineObject != null)
@@ -40,14 +40,19 @@ public class DeviceController : PFUIPanel
//UIManager.CloseModal();
this.Close();
}));
//UIManager.AddEvent(mReturnBtn.gameObject, EventTriggerType.PointerUp, (e) =>
//{
// Debug.Log("aaaaaaaaaaaaaa");
//});
var bg = this.transform.Find("Status").Find("Bg");
antStatus = bg.Find("Ant+").GetComponent<Image>();
ant0 = Resources.Load<Sprite>("Images/ANT+_0");
ant1 = Resources.Load<Sprite>("Images/ANT+_1");
ant1 = Resources.Load<Sprite>("Images/ANT+_2");
Debug.Log("device start");
base.SetRounded(bg, 64);
}
@@ -7,8 +7,10 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class EditUserController : PFUIPanel
@@ -18,38 +20,63 @@ public class EditUserController : PFUIPanel
private PFUIDropdown mDayDropdown;
private PFUIDropdown mMonthDropdown;
private PFUIDropdown mYearDropdown;
private Text mIdText;
private Text mNameText;
private PFUIDropdown mConutryDropdown;
private PFUIDropdown mUnitDropdown;
private Text mID;
private PFUIInputField mNickName;
private PFUIInputField mFTP;
private PFUIInputField mWeight;
private PFUIInputField mHeight;
private PFUIInputField mMHR;
private PFUIInputField mBW;
private PFUIInputField mWD;
private PFUIInputField mName;
private PFUIInputField mPhone;
private PFUIInputField mAddr;
private RawImage mHeadImage;
private UserApi userApi;
private Button mCancelButton;
private Button mBackButton;
private Button mSwitchButton;
PfUIButton mChangeAvatar;
protected override void Awake()
{
Debug.Log(Utils.GetIP(Utils.ADDRESSFAM.IPv4));
userApi = new UserApi();
mIdText = this.transform.Find("IdText").GetComponent<Text>();
mNameText = this.transform.Find("NameText").GetComponent<Text>();
var panel = this.transform.Find("Panel");
mID = panel.Find("IDNumber").Find("input").Find("Text").GetComponent<Text>();
mSexDropdown = panel.Find("SexDropdown").GetComponent<PFUIDropdown>();
mSexDropdown = panel.Find("SexDropdown").GetComponent<PFUIDropdown>();
mYearDropdown = panel.Find("YearDropdown").GetComponent<PFUIDropdown>();
mMonthDropdown = panel.Find("MonthDropdown").GetComponent<PFUIDropdown>();
mDayDropdown = panel.Find("DayDropdown").GetComponent<PFUIDropdown>();
mUnitDropdown = panel.Find("UnitDropdown").GetComponent<PFUIDropdown>();
mSaveButton = this.transform.Find("SaveButton").GetComponent<Button>();
mCancelButton = this.transform.Find("CancelButton").GetComponent<Button>();
mHeadImage = this.transform.Find("HeadImage").GetComponent<RawImage>();
mBackButton = this.transform.Find("BackButton").GetComponent<Button>();
UIManager.AddEvent(mBackButton.gameObject, EventTriggerType.PointerClick, Cancel);
mSwitchButton = this.transform.Find("SwitchAccountButton").GetComponent<Button>();
mChangeAvatar = this.transform.Find("ChangeAvatar").GetComponent<PfUIButton>();
mConutryDropdown = panel.Find("CountryDropdown").GetComponent<PFUIDropdown>();
mNickName = panel.Find("NickName").Find("input").GetComponent<PFUIInputField>();
mFTP = panel.Find("Ftp").Find("input").GetComponent<PFUIInputField>();
mWeight = panel.Find("Weight").Find("input").GetComponent<PFUIInputField>();
mHeight = panel.Find("Height").Find("input").GetComponent<PFUIInputField>();
mMHR = panel.Find("MHR").Find("input").GetComponent<PFUIInputField>();
mBW = panel.Find("BW").Find("input").GetComponent<PFUIInputField>();
mWD = panel.Find("WD").Find("input").GetComponent<PFUIInputField>();
mName = panel.Find("Name").Find("input").GetComponent<PFUIInputField>();
mPhone = panel.Find("PN").Find("input").GetComponent<PFUIInputField>();
mAddr = panel.Find("Addr").Find("input").GetComponent<PFUIInputField>();
UIManager.AddEvent(mBackButton.gameObject, EventTriggerType.PointerClick, Cancel);
UIManager.AddEvent(mChangeAvatar.gameObject, EventTriggerType.PointerClick, (e) =>
{
OpenFileName ofn = new OpenFileName();
ofn.structSize = Marshal.SizeOf(ofn);
ofn.filter = "All Files\0*.*\0\0";
ofn.filter = "Image Files(*.jpg;*.jpeg;*.png;*.bmp)\0*.jpg;*.png;*.jpeg;*.bmp\0";
ofn.file = new string(new char[256]);
@@ -70,18 +97,19 @@ public class EditUserController : PFUIPanel
if (Win32.GetOpenFileName(ofn))
{
Debug.Log(ofn.file);
ChangeAvatar(ofn.file);
}
});
mSexDropdown.ClearOptions();
mSexDropdown.AddOptions(new List<string>
{
"男","女"
});
mUnitDropdown.ClearOptions();
mUnitDropdown.AddOptions(UIManager.Instance.loginRegOptions.units);
mYearDropdown.ClearOptions();
var years = new List<string>();
for (int i = 1960; i < 2099; i++)
@@ -120,49 +148,84 @@ public class EditUserController : PFUIPanel
//});
LoadDataSync();
}
void LoadDataSync()
async Task Login()
{
var rect = ((RectTransform)mHeadImage.transform).rect;
SetRounded(mHeadImage.transform, rect.height);
var result = await new UserApi().Login("13115011550", "laozhong", "");
App.CurrentUser = result.data;
}
async Task LoadDataSync()
{
if (!App.FromLogin)
{
await Login();
}
var currentUser = App.CurrentUser;
if (currentUser == null) return;
//mIdText.text = currentUser.Id.ToString();
//mNameText.text = currentUser.Nickname;
mIdText.text = currentUser.Id.ToString();
mNameText.text = currentUser.Nickname;
//Utils.DisplayImage(StartCoroutine, mHeadImage, currentUser.WxHeadImg);
Utils.DisplayImage(StartCoroutine, mHeadImage, currentUser.WxHeadImg);
//if (!string.IsNullOrWhiteSpace(currentUser.WxHeadImg))
//{
// Utils.DisplayImage(StartCoroutine, mHeadImage, currentUser.WxHeadImg);
//}
//if (currentUser.Sex == 1)
//{
// mSexDropdown.SelectValue("男");
//}
//else
//{
// mSexDropdown.SelectValue("女");
//}
//if (currentUser.Birthday.HasValue)
//{
// var birthday = currentUser.Birthday.Value;
// mYearDropdown.SelectValue(birthday.Year.ToString());
// mMonthDropdown.SelectValue(birthday.Month.ToString());
// mDayDropdown.SelectValue(birthday.Day.ToString());
//}
UIManager.AddEvent(mSaveButton.gameObject, EventTriggerType.PointerClick, Save);
UIManager.AddEvent(mCancelButton.gameObject, EventTriggerType.PointerClick, Cancel);
if (!string.IsNullOrWhiteSpace(currentUser.WxHeadImg))
{
Utils.DisplayImage(StartCoroutine, mHeadImage, currentUser.WxHeadImg);
}
if (currentUser.Sex == 1)
{
mSexDropdown.SelectValue("男");
}
else
{
mSexDropdown.SelectValue("女");
}
mUnitDropdown.SelectIndex(currentUser.Unit);
if (currentUser.Birthday.HasValue)
{
var birthday = currentUser.Birthday.Value;
mYearDropdown.SelectValue(birthday.Year.ToString());
mMonthDropdown.SelectValue(birthday.Month.ToString());
mDayDropdown.SelectValue(birthday.Day.ToString());
}
mID.text = currentUser.Id.ToString();
mNickName.Text = currentUser.Nickname;
mFTP.Text = currentUser.FTP.ToString();
mWeight.Text = currentUser.Weight.ToString();
mHeight.Text = currentUser.Height.ToString();
mMHR.Text = currentUser.MaxHeartRate.ToString();
mBW.Text = currentUser.BicycleWeight.ToString();
mWD.Text = currentUser.WheelDiameter.ToString();
mName.Text = currentUser.Contact;
mPhone.Text = currentUser.ContactPhone;
mAddr.Text = currentUser.ContactAddress;
}
// Start is called before the first frame update
protected override void Start()
{
base.Start();
mConutryDropdown.ClearOptions();
mConutryDropdown.AddOptions(UIManager.Instance.loginRegOptions.countrys);
mConutryDropdown.SelectIndex(UIManager.Instance.loginRegOptions.countryDefaultValue);
mConutryDropdown.transform.Find("RawImage").GetComponent<RawImage>().texture =
UIManager.Instance.loginRegOptions.GetCountryImage(UIManager.Instance.loginRegOptions.countryDefaultValue);
mConutryDropdown.OnValueChange = (int index) =>
{
mConutryDropdown.transform.Find("RawImage").GetComponent<RawImage>().texture =
UIManager.Instance.loginRegOptions.GetCountryImage(index);
};
var rect = ((RectTransform)mHeadImage.transform).rect;
SetRounded(mHeadImage.transform, rect.height);
UIManager.AddEvent(mSaveButton.gameObject, EventTriggerType.PointerClick, Save);
UIManager.AddEvent(mCancelButton.gameObject, EventTriggerType.PointerClick, Cancel);
UIManager.AddEvent(mSwitchButton.gameObject, EventTriggerType.PointerClick, Switch);
}
private void Switch(BaseEventData arg0)
{
SceneManager.LoadScene("1-Login");
}
// Update is called once per frame
@@ -191,22 +254,65 @@ public class EditUserController : PFUIPanel
async void Save(BaseEventData e)
{
//var user = JsonConvert.DeserializeObject<UserResultModel>(JsonConvert.SerializeObject(App.CurrentUser));
//user.Birthday = new DateTime(int.Parse(mYearDropdown.SelectedItem), int.Parse(mMonthDropdown.SelectedItem), int.Parse(mDayDropdown.SelectedItem));
//user.Sex = mSexDropdown.SelectedItem == "男" ? 1 : 2;
//var result = await userApi.Update(user);
//if (result.result == false)
//{
// UIManager.ShowAlert(result.errMsg);
// return;
//}
var user = JsonConvert.DeserializeObject<UserResultModel>(JsonConvert.SerializeObject(App.CurrentUser));
user.Birthday = new DateTime(int.Parse(mYearDropdown.SelectedItem), int.Parse(mMonthDropdown.SelectedItem), int.Parse(mDayDropdown.SelectedItem));
user.Sex = mSexDropdown.SelectedItem == "男" ? 1 : 2;
user.Nickname = mNickName.Text;
user.Country = UIManager.Instance.loginRegOptions.GetCountryName(mConutryDropdown.SelectedIndex);
user.FTP = int.Parse(mFTP.Text);
user.Height = int.Parse(mHeight.Text);
user.Weight = int.Parse(mWeight.Text);
user.MaxHeartRate = int.Parse(mMHR.Text);
user.BicycleWeight = int.Parse(mBW.Text);
user.WheelDiameter = int.Parse(mWD.Text);
user.Unit = mUnitDropdown.SelectedIndex;
user.Contact = mName.Text;
user.ContactPhone = mPhone.Text;
user.ContactAddress = mAddr.Text;
var result = await userApi.Update(user);
if (result.result == false)
{
UIManager.ShowAlert(result.errMsg);
}
else
{
App.CurrentUser = user;
var userinfos = UIManager.Instance.userInfos;
var i = userinfos.FindIndex(x => x.Id == App.CurrentUser.Id);
if (i != -1)
{
userinfos[i].NickName = user.Nickname;
UIManager.Instance.userInfos = userinfos;
}
UIManager.ShowAlert("Success");
}
LoadDataSync();
//App.CurrentUser = user;
UIManager.ShowAlert("result.errMsg");
//UIManager.ShowAlert("result.errMsg");
}
async void ChangeAvatar(string path)
{
var r = await userApi.Update(App.CurrentUser, path);
if (r.result)
{
var img = r.data.Value<string>("WxHeadImg");
Utils.DisplayImage(StartCoroutine, mHeadImage, img);
var userinfos = UIManager.Instance.userInfos;
var i = userinfos.FindIndex(x => x.Id == App.CurrentUser.Id);
if (i != -1)
{
userinfos[i].Avatar = img;
UIManager.Instance.userInfos = userinfos;
}
App.CurrentUser.WxHeadImg = img;
UIManager.ShowAlert("Success");
}
else
{
UIManager.ShowAlert(r.errMsg);
}
}
void Cancel(BaseEventData e)
{
UIManager.ShowHomePanel();
@@ -100,9 +100,10 @@ public class HomeController : PFUIPanel
userInfo.Find("GroupTop").Find("FtpContainer").Find("FtpValue").GetComponent<Text>().text = App.CurrentUser.FTP.ToString();
userInfo.Find("GroupTop").Find("WeightContainer").Find("WeightValue").GetComponent<Text>().text = App.CurrentUser.Weight.ToString();
userInfo.Find("GroupTop").Find("WKGContainer").Find("WKGValue").GetComponent<Text>().text = $"{App.CurrentUser.Weight}kg/{App.CurrentUser.BicycleWeight}kg";
userInfo.Find("CaloriesContainer").Find("CaloriesValue").GetComponent<Text>().text = summary.Kcal;
userInfo.Find("KMContainer").Find("KMValue").GetComponent<Text>().text = summary.TotalDistance.ToString();
userInfo.Find("ClimbContainer").Find("ClimbValue").GetComponent<Text>().text = summary.TotalClimb;
userInfo.Find("CaloriesContainer").Find("CaloriesValue").GetComponent<Text>().text = summary.Kcal +" KCAL";
userInfo.Find("KMContainer").Find("KMValue").GetComponent<Text>().text = summary.TotalDistance.ToString("0") +" KM";
userInfo.Find("ClimbContainer").Find("ClimbValue").GetComponent<Text>().text = summary.TotalClimb +" M";
userInfo.Find("IDText").GetComponent<Text>().text = "ID:"+App.CurrentUser.Id;
//var user = ConfigHelper.CurrentUser;
//Ftp.text = summary.Ftp.ToString();
//Weight.text = user.Weight.ToString();
@@ -148,4 +149,9 @@ public class HomeController : PFUIPanel
{
}
public override void Show()
{
base.Show();
}
}
@@ -45,6 +45,7 @@ public class MapListController : PFUIPanel
//{
// hardSelector.onValueChanged.AddListener(ChangeHard);
//}
ApiBase.SetCookie("15A37DF28842CBA8E4E550BFA24186C8222D392F3EE18D9E95A49CC32796D2E3F6E40385C6A114942546EE1DD793DF34880DE48090B91AD2460EB887B59664BB3965F3371DDA1F1401EC7F27C5A1084566E47069F12CB6BBC0BC7A84ADC5582B");
btnMapMode = this.transform.Find("SwitchMode").gameObject;
SetRounded(btnMapMode.transform, 64);
UIManager.AddEvent(btnMapMode, EventTriggerType.PointerClick, (e) =>
@@ -196,12 +197,15 @@ public class MapListController : PFUIPanel
var rect = ((RectTransform)headImage.transform).rect;
material.SetVector(Shader.PropertyToID("_WidthHeightRadius"), new Vector4(rect.width, rect.height, rect.height, 0));
headImage.material = material;
Utils.DisplayImage(StartCoroutine, headImage, App.CurrentUser.WxHeadImg);
if (App.FromLogin)
{
Utils.DisplayImage(StartCoroutine, headImage, App.CurrentUser.WxHeadImg);
}
UIManager.AddEvent(headImage.gameObject, EventTriggerType.PointerClick, (e) =>
{
UIManager.ShowEditUserPanel();
UIManager.ShowUserInfoPanel();
});
}
@@ -1,13 +1,19 @@
using System.Collections;
using Assets.Scripts;
using Assets.Scripts.Apis;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class UserInfoController : PFUIPanel
{
// Start is called before the first frame update
UserApi userApi;
Transform infoPanel,summaryPanel;
protected override void Start()
{
userApi = ConfigHelper.userApi;
this.transform.localPosition = new Vector3(0, 0, 0);
Button exitBtn = this.transform.Find("InfoPanel").Find("Button").GetComponent<Button>();
@@ -16,14 +22,55 @@ public class UserInfoController : PFUIPanel
{
UIManager.ShowHomePanel();
});
Button editBtn = this.transform.Find("InfoPanel").Find("EditButton").GetComponent<Button>();
UIManager.AddEvent(transform.Find("InfoPanel").Find("SwitchAccountButton").gameObject,
UnityEngine.EventSystems.EventTriggerType.PointerClick, (b) =>
{
SceneManager.LoadScene("1-Login");
});
infoPanel = transform.Find("InfoPanel").Find("P");
Button editBtn = infoPanel.Find("EditButton").GetComponent<Button>();
editBtn.onClick.AddListener(() =>
{
UIManager.ShowEditUserPanel();
});
summaryPanel = transform.Find("SummaryPanel");
Load();
}
async void Load()
{
if (!App.FromLogin)
{
var result = await userApi.Login("15651831367", "123456", "");
App.CurrentUser = result.data;
}
var r = userApi.GetSummary();
if (r.result)
{
var summary = r.data;
var user = App.CurrentUser;
Utils.DisplayImage(StartCoroutine, infoPanel.Find("Avatar").GetComponent<RawImage>(), user.WxHeadImg);
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}";
infoPanel.Find("NameText").GetComponent<Text>().text = $"{user.Nickname}";
infoPanel.Find("EmailText").GetComponent<Text>().text = $"{user.Phone}";
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";
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()
{
@@ -25,6 +25,7 @@ public class RouteItem : MonoBehaviour, IPointerExitHandler, IPointerEnterHandle
}
string titleColor = "#5c5c6e";
RouteResult data;
public void Initial(RouteResult result)
{
routeResult = result;
@@ -64,7 +65,8 @@ public class RouteItem : MonoBehaviour, IPointerExitHandler, IPointerEnterHandle
private void Delete()
{
throw new NotImplementedException();
//throw new NotImplementedException();
UIManager.ShowAlert("暂未实现");
}
private void GoReRide()