暂存
This commit is contained in:
1 parent
f4cbad819b
commit
0346b650aa
64 files changed
+12634
-12935
No files matched your search
@@ -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();
|
||||
|
||||
@@ -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,8 +197,11 @@ 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) =>
|
||||
{
|
||||
@@ -265,10 +269,14 @@ public class MapListController : PFUIPanel
|
||||
foreach (var item in list)
|
||||
{
|
||||
var obj = Instantiate(map);
|
||||
obj.transform.SetParent(content.transform);
|
||||
obj.transform.localScale = new Vector3(1, 1, 1);
|
||||
obj.GetComponent<MapItem>().Initial(item);
|
||||
//obj.SendMessage("Initial", );
|
||||
obj.transform.parent = content.transform;
|
||||
obj.transform.localScale = new Vector3(1, 1, 1);
|
||||
}
|
||||
foreach (Transform t in content.transform)
|
||||
{
|
||||
Debug.Log(t.localPosition.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user