2021-04-09 09:44:06 +08:00
|
|
|
|
using Assets.Scripts;
|
|
|
|
|
|
using Assets.Scripts.Apis;
|
|
|
|
|
|
using Assets.Scripts.Apis.Models;
|
|
|
|
|
|
using Assets.Scripts.UI.Control;
|
|
|
|
|
|
using Newtonsoft.Json;
|
2021-04-23 15:36:18 +08:00
|
|
|
|
using Newtonsoft.Json.Linq;
|
2021-04-09 09:44:06 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections;
|
2021-03-30 14:23:41 +08:00
|
|
|
|
using System.Collections.Generic;
|
2021-06-07 17:05:49 +08:00
|
|
|
|
using System.Globalization;
|
2021-04-15 15:57:29 +08:00
|
|
|
|
using System.Runtime.InteropServices;
|
2021-04-16 17:49:11 +08:00
|
|
|
|
using System.Threading.Tasks;
|
2021-03-30 14:23:41 +08:00
|
|
|
|
using UnityEngine;
|
2021-04-09 09:44:06 +08:00
|
|
|
|
using UnityEngine.EventSystems;
|
2021-04-16 17:49:11 +08:00
|
|
|
|
using UnityEngine.SceneManagement;
|
2021-04-09 09:44:06 +08:00
|
|
|
|
using UnityEngine.UI;
|
2021-03-30 14:23:41 +08:00
|
|
|
|
|
|
|
|
|
|
public class EditUserController : PFUIPanel
|
|
|
|
|
|
{
|
2021-04-09 09:44:06 +08:00
|
|
|
|
private Button mSaveButton;
|
|
|
|
|
|
private PFUIDropdown mSexDropdown;
|
|
|
|
|
|
private PFUIDropdown mDayDropdown;
|
|
|
|
|
|
private PFUIDropdown mMonthDropdown;
|
|
|
|
|
|
private PFUIDropdown mYearDropdown;
|
2021-04-16 17:49:11 +08:00
|
|
|
|
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;
|
2021-04-09 09:44:06 +08:00
|
|
|
|
private RawImage mHeadImage;
|
|
|
|
|
|
private UserApi userApi;
|
2021-04-15 15:57:29 +08:00
|
|
|
|
private Button mCancelButton;
|
|
|
|
|
|
private Button mBackButton;
|
2021-04-16 17:49:11 +08:00
|
|
|
|
private Button mSwitchButton;
|
2021-04-15 15:57:29 +08:00
|
|
|
|
PfUIButton mChangeAvatar;
|
2021-04-21 16:16:14 +08:00
|
|
|
|
Transform linkContainer;
|
2021-04-23 15:36:18 +08:00
|
|
|
|
Dictionary<string, Selectable> dict;
|
2021-04-21 16:16:14 +08:00
|
|
|
|
|
2021-04-09 09:44:06 +08:00
|
|
|
|
protected override void Awake()
|
|
|
|
|
|
{
|
2021-04-16 17:49:11 +08:00
|
|
|
|
Debug.Log(Utils.GetIP(Utils.ADDRESSFAM.IPv4));
|
2021-04-09 09:44:06 +08:00
|
|
|
|
userApi = new UserApi();
|
2021-04-16 17:49:11 +08:00
|
|
|
|
|
2021-04-09 09:44:06 +08:00
|
|
|
|
var panel = this.transform.Find("Panel");
|
2021-04-16 17:49:11 +08:00
|
|
|
|
mID = panel.Find("IDNumber").Find("input").Find("Text").GetComponent<Text>();
|
|
|
|
|
|
mSexDropdown = panel.Find("SexDropdown").GetComponent<PFUIDropdown>();
|
2021-04-09 09:44:06 +08:00
|
|
|
|
mSexDropdown = panel.Find("SexDropdown").GetComponent<PFUIDropdown>();
|
|
|
|
|
|
mYearDropdown = panel.Find("YearDropdown").GetComponent<PFUIDropdown>();
|
|
|
|
|
|
mMonthDropdown = panel.Find("MonthDropdown").GetComponent<PFUIDropdown>();
|
|
|
|
|
|
mDayDropdown = panel.Find("DayDropdown").GetComponent<PFUIDropdown>();
|
2021-04-16 17:49:11 +08:00
|
|
|
|
mUnitDropdown = panel.Find("UnitDropdown").GetComponent<PFUIDropdown>();
|
2021-04-09 09:44:06 +08:00
|
|
|
|
mSaveButton = this.transform.Find("SaveButton").GetComponent<Button>();
|
2021-04-15 15:57:29 +08:00
|
|
|
|
mCancelButton = this.transform.Find("CancelButton").GetComponent<Button>();
|
2021-04-09 09:44:06 +08:00
|
|
|
|
mHeadImage = this.transform.Find("HeadImage").GetComponent<RawImage>();
|
2021-04-15 15:57:29 +08:00
|
|
|
|
mBackButton = this.transform.Find("BackButton").GetComponent<Button>();
|
2021-04-16 17:49:11 +08:00
|
|
|
|
mSwitchButton = this.transform.Find("SwitchAccountButton").GetComponent<Button>();
|
2021-04-15 15:57:29 +08:00
|
|
|
|
mChangeAvatar = this.transform.Find("ChangeAvatar").GetComponent<PfUIButton>();
|
2021-04-16 17:49:11 +08:00
|
|
|
|
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);
|
2021-04-15 15:57:29 +08:00
|
|
|
|
UIManager.AddEvent(mChangeAvatar.gameObject, EventTriggerType.PointerClick, (e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
OpenFileName ofn = new OpenFileName();
|
|
|
|
|
|
|
|
|
|
|
|
ofn.structSize = Marshal.SizeOf(ofn);
|
|
|
|
|
|
|
2021-04-16 17:49:11 +08:00
|
|
|
|
ofn.filter = "Image Files(*.jpg;*.jpeg;*.png;*.bmp)\0*.jpg;*.png;*.jpeg;*.bmp\0";
|
2021-04-15 15:57:29 +08:00
|
|
|
|
|
|
|
|
|
|
ofn.file = new string(new char[256]);
|
|
|
|
|
|
|
|
|
|
|
|
ofn.maxFile = ofn.file.Length;
|
|
|
|
|
|
|
|
|
|
|
|
ofn.fileTitle = new string(new char[64]);
|
|
|
|
|
|
|
|
|
|
|
|
ofn.maxFileTitle = ofn.fileTitle.Length;
|
|
|
|
|
|
|
|
|
|
|
|
ofn.initialDir = UnityEngine.Application.dataPath;//默认路径
|
|
|
|
|
|
|
|
|
|
|
|
ofn.title = "Open Project";
|
|
|
|
|
|
|
|
|
|
|
|
ofn.defExt = "JPG";//显示文件的类型
|
|
|
|
|
|
//注意 一下项目不一定要全选 但是0x00000008项不要缺少
|
2021-04-26 16:25:52 +08:00
|
|
|
|
ofn.flags = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000008;//OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST| OFN_ALLOWMULTISELECT|OFN_NOCHANGEDIR
|
2021-04-15 15:57:29 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Win32.GetOpenFileName(ofn))
|
|
|
|
|
|
{
|
2021-04-16 17:49:11 +08:00
|
|
|
|
ChangeAvatar(ofn.file);
|
2021-04-15 15:57:29 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2021-04-21 16:16:14 +08:00
|
|
|
|
linkContainer = transform.Find("LinkContainer");
|
2021-04-16 17:49:11 +08:00
|
|
|
|
|
2021-04-09 09:44:06 +08:00
|
|
|
|
mSexDropdown.ClearOptions();
|
|
|
|
|
|
mSexDropdown.AddOptions(new List<string>
|
|
|
|
|
|
{
|
2021-04-30 10:32:01 +08:00
|
|
|
|
"Male","Female"
|
2021-04-09 09:44:06 +08:00
|
|
|
|
});
|
2021-04-16 17:49:11 +08:00
|
|
|
|
mUnitDropdown.ClearOptions();
|
|
|
|
|
|
mUnitDropdown.AddOptions(UIManager.Instance.loginRegOptions.units);
|
2021-04-09 09:44:06 +08:00
|
|
|
|
mYearDropdown.ClearOptions();
|
|
|
|
|
|
var years = new List<string>();
|
|
|
|
|
|
for (int i = 1960; i < 2099; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
years.Add(i.ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
mYearDropdown.AddOptions(years);
|
|
|
|
|
|
mYearDropdown.OnValueChange = (index) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
//Debug.Log(index);
|
|
|
|
|
|
SetDayDropdown();
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
mMonthDropdown.ClearOptions();
|
|
|
|
|
|
var months = new List<string>();
|
|
|
|
|
|
for (int i = 1; i < 13; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
months.Add(i.ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
mMonthDropdown.AddOptions(months);
|
|
|
|
|
|
//mMonthDropdown.SelectValue("9");
|
|
|
|
|
|
mMonthDropdown.OnValueChange = (index) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
SetDayDropdown();
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
mDayDropdown.ClearOptions();
|
|
|
|
|
|
SetDayDropdown();
|
|
|
|
|
|
|
|
|
|
|
|
//mDayDropdown.AddOptions()
|
|
|
|
|
|
|
|
|
|
|
|
//mDayDropdown.AddOptions(new List<Dropdown.OptionData>
|
|
|
|
|
|
//{
|
|
|
|
|
|
// new Dropdown.OptionData()
|
|
|
|
|
|
//});
|
2021-04-23 15:36:18 +08:00
|
|
|
|
dict = new Dictionary<string, Selectable>
|
|
|
|
|
|
{
|
|
|
|
|
|
{"NickName",mNickName.GetComponent<InputField>() },
|
|
|
|
|
|
{"FTP",mFTP.GetComponent<InputField>() },
|
|
|
|
|
|
{"Weight",mWeight.GetComponent<InputField>() },
|
|
|
|
|
|
{"Height",mHeight.GetComponent<InputField>() },
|
|
|
|
|
|
{"WheelDiameter",mWD.GetComponent<InputField>() },
|
|
|
|
|
|
{"MaxHeartRate",mMHR.GetComponent<InputField>() },
|
|
|
|
|
|
{"BicycleWeight",mBW.GetComponent<InputField>() },
|
|
|
|
|
|
{"Contact",mName.GetComponent<InputField>() },
|
|
|
|
|
|
{"ContactPhone",mPhone.GetComponent<InputField>() },
|
|
|
|
|
|
{"ContactAddress",mAddr.GetComponent<InputField>() },
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2021-04-21 16:16:14 +08:00
|
|
|
|
|
2021-04-09 09:44:06 +08:00
|
|
|
|
}
|
2021-04-16 17:49:11 +08:00
|
|
|
|
async Task Login()
|
2021-04-09 09:44:06 +08:00
|
|
|
|
{
|
2021-04-16 17:49:11 +08:00
|
|
|
|
var result = await new UserApi().Login("13115011550", "laozhong", "");
|
|
|
|
|
|
App.CurrentUser = result.data;
|
|
|
|
|
|
}
|
2021-04-28 15:21:06 +08:00
|
|
|
|
void LoadDataSync()
|
2021-04-16 17:49:11 +08:00
|
|
|
|
{
|
2021-04-19 18:16:56 +08:00
|
|
|
|
//if (!App.FromLogin)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// await Login();
|
|
|
|
|
|
//}
|
2021-04-15 15:57:29 +08:00
|
|
|
|
|
2021-04-16 17:49:11 +08:00
|
|
|
|
var currentUser = App.CurrentUser;
|
|
|
|
|
|
if (currentUser == null) return;
|
|
|
|
|
|
//mIdText.text = currentUser.Id.ToString();
|
|
|
|
|
|
//mNameText.text = currentUser.Nickname;
|
2021-04-09 09:44:06 +08:00
|
|
|
|
|
2021-04-16 17:49:11 +08:00
|
|
|
|
//Utils.DisplayImage(StartCoroutine, mHeadImage, currentUser.WxHeadImg);
|
2021-04-09 09:44:06 +08:00
|
|
|
|
|
2021-05-20 20:00:33 +08:00
|
|
|
|
Utils.DisplayHead(mHeadImage, currentUser.WxHeadImg);
|
2021-04-16 17:49:11 +08:00
|
|
|
|
if (currentUser.Sex == 1)
|
|
|
|
|
|
{
|
2021-04-30 10:32:01 +08:00
|
|
|
|
mSexDropdown.SelectIndex(0);
|
2021-04-16 17:49:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2021-04-30 10:32:01 +08:00
|
|
|
|
mSexDropdown.SelectIndex(1);
|
2021-04-16 17:49:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
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());
|
|
|
|
|
|
}
|
2021-04-27 18:26:30 +08:00
|
|
|
|
mID.text = currentUser.Id.ToString("000000");
|
2021-04-16 17:49:11 +08:00
|
|
|
|
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;
|
2021-04-21 16:16:14 +08:00
|
|
|
|
//string.IsNullOrEmpty(currentUser.Unionid)
|
|
|
|
|
|
linkContainer.Find("Wx").GetComponent<Image>().sprite =
|
|
|
|
|
|
string.IsNullOrEmpty(currentUser.Unionid)
|
|
|
|
|
|
? Resources.Load<Sprite>("Images/Wechat_person_0")
|
|
|
|
|
|
: Resources.Load<Sprite>("Images/Wechat_person_1");
|
2021-04-09 09:44:06 +08:00
|
|
|
|
}
|
2021-03-30 14:23:41 +08:00
|
|
|
|
// Start is called before the first frame update
|
|
|
|
|
|
protected override void Start()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.Start();
|
2021-04-16 17:49:11 +08:00
|
|
|
|
mConutryDropdown.ClearOptions();
|
|
|
|
|
|
mConutryDropdown.AddOptions(UIManager.Instance.loginRegOptions.countrys);
|
|
|
|
|
|
mConutryDropdown.OnValueChange = (int index) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
mConutryDropdown.transform.Find("RawImage").GetComponent<RawImage>().texture =
|
|
|
|
|
|
UIManager.Instance.loginRegOptions.GetCountryImage(index);
|
|
|
|
|
|
};
|
2021-04-21 11:19:31 +08:00
|
|
|
|
mConutryDropdown.SelectValue(App.CurrentUser.Country);
|
|
|
|
|
|
//mConutryDropdown.transform.Find("RawImage").GetComponent<RawImage>().texture =
|
|
|
|
|
|
// UIManager.Instance.loginRegOptions.GetCountryImage(UIManager.Instance.loginRegOptions.countryDefaultValue);
|
2021-04-16 17:49:11 +08:00
|
|
|
|
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);
|
|
|
|
|
|
}
|
2021-04-23 15:36:18 +08:00
|
|
|
|
public override void Show()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.Show();
|
|
|
|
|
|
LoadDataSync();
|
2021-04-28 15:21:06 +08:00
|
|
|
|
App.isChanged = false;
|
2021-04-23 15:36:18 +08:00
|
|
|
|
}
|
2021-04-16 17:49:11 +08:00
|
|
|
|
private void Switch(BaseEventData arg0)
|
|
|
|
|
|
{
|
2021-04-29 11:36:30 +08:00
|
|
|
|
UIManager.ShowConfirm("Logout", "Do you want to log out and change accounts?", () =>
|
|
|
|
|
|
{
|
2021-08-24 17:50:14 +08:00
|
|
|
|
#if !(UNITY_ANDROID || UNITY_IOS)
|
2021-05-08 11:07:55 +08:00
|
|
|
|
SceneManager.LoadScene("Login");
|
2021-08-24 17:50:14 +08:00
|
|
|
|
#else
|
|
|
|
|
|
SceneManager.LoadScene("Login-Mobile");
|
|
|
|
|
|
#endif
|
2021-04-29 11:36:30 +08:00
|
|
|
|
UIManager.CloseConfirm();
|
2021-05-06 16:02:37 +08:00
|
|
|
|
},2);
|
2021-03-30 14:23:41 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|
|
|
void Update()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2021-04-09 09:44:06 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SetDayDropdown()
|
|
|
|
|
|
{
|
2021-06-10 17:46:43 +08:00
|
|
|
|
//Debug.Log(mDayDropdown.SelectedItem);
|
2021-06-09 18:16:35 +08:00
|
|
|
|
|
|
|
|
|
|
|
2021-04-09 09:44:06 +08:00
|
|
|
|
mDayDropdown.ClearOptions();
|
|
|
|
|
|
var year = mYearDropdown.SelectedItem;
|
|
|
|
|
|
var month = mMonthDropdown.SelectedItem;
|
|
|
|
|
|
|
|
|
|
|
|
//var date = new DateTime(int.Parse(year), int.Parse(month), 1);
|
|
|
|
|
|
var days = DateTime.DaysInMonth(int.Parse(year), int.Parse(month));
|
|
|
|
|
|
var list = new List<string>();
|
|
|
|
|
|
for (int i = 1; i <= days; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
list.Add(i.ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
mDayDropdown.ClearOptions();
|
|
|
|
|
|
mDayDropdown.AddOptions(list);
|
2021-05-20 20:07:45 +08:00
|
|
|
|
mDayDropdown.SelectIndex(0);
|
2021-04-09 09:44:06 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-04-28 15:21:06 +08:00
|
|
|
|
void Save(BaseEventData e)
|
2021-04-09 09:44:06 +08:00
|
|
|
|
{
|
2021-04-29 11:36:30 +08:00
|
|
|
|
//UIManager.ShowConfirm("Confirm", "Are you sure to edit?", SaveFunc);
|
2021-06-09 19:44:06 +08:00
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
SaveFunc();
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
Utils.showToast(gameObject, ex.Message);
|
|
|
|
|
|
}
|
2021-04-09 09:44:06 +08:00
|
|
|
|
//App.CurrentUser = user;
|
|
|
|
|
|
|
2021-04-16 17:49:11 +08:00
|
|
|
|
//UIManager.ShowAlert("result.errMsg");
|
|
|
|
|
|
}
|
2021-05-12 10:42:26 +08:00
|
|
|
|
void SaveFunc()
|
2021-04-29 11:36:30 +08:00
|
|
|
|
{
|
|
|
|
|
|
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));
|
2021-04-30 10:32:01 +08:00
|
|
|
|
user.Sex = mSexDropdown.SelectedIndex == 0 ? 1 : 2;
|
2021-04-29 11:36:30 +08:00
|
|
|
|
user.Nickname = mNickName.Text;
|
|
|
|
|
|
user.Country = UIManager.Instance.loginRegOptions.GetCountryName(mConutryDropdown.SelectedIndex);
|
|
|
|
|
|
var errorList = new List<object>();
|
|
|
|
|
|
if (string.IsNullOrEmpty(mNickName.Text)) errorList.Add(new { Field = "Nickname", ErrMsg = "请填写昵称" });
|
|
|
|
|
|
if (string.IsNullOrEmpty(mFTP.Text)) errorList.Add(new { Field = "FTP", ErrMsg = "请填写FTP" });
|
|
|
|
|
|
if (string.IsNullOrEmpty(mHeight.Text)) errorList.Add(new { Field = "Height", ErrMsg = "请填写身高" });
|
|
|
|
|
|
if (string.IsNullOrEmpty(mWeight.Text)) errorList.Add(new { Field = "Weight", ErrMsg = "请填写体重" });
|
|
|
|
|
|
if (string.IsNullOrEmpty(mMHR.Text)) errorList.Add(new { Field = "MaxHeartRate", ErrMsg = "请填写最大心率" });
|
|
|
|
|
|
if (string.IsNullOrEmpty(mBW.Text)) errorList.Add(new { Field = "BicycleWeight", ErrMsg = "请填写车重" });
|
|
|
|
|
|
if (string.IsNullOrEmpty(mWD.Text)) errorList.Add(new { Field = "WheelDiameter", ErrMsg = "请填写轮径" });
|
|
|
|
|
|
if (errorList.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
Utils.SetValidate(dict, JArray.FromObject(errorList));
|
|
|
|
|
|
Utils.showToast(gameObject, "Please fill in the information");//请填写相关信息
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2021-06-08 11:32:06 +08:00
|
|
|
|
user.FTP = Convert.ToInt32(mFTP.Text, CultureInfo.InstalledUICulture); //int.Parse(mFTP.Text);
|
|
|
|
|
|
user.Height = Convert.ToInt32(mHeight.Text, CultureInfo.InstalledUICulture); //int.Parse(mHeight.Text);
|
|
|
|
|
|
user.Weight = Convert.ToDouble(mWeight.Text, CultureInfo.InstalledUICulture); //double.Parse(mWeight.Text);
|
|
|
|
|
|
user.MaxHeartRate = Convert.ToInt32(mMHR.Text, CultureInfo.InstalledUICulture); //int.Parse(mMHR.Text);
|
|
|
|
|
|
user.BicycleWeight = Convert.ToDouble(mBW.Text, CultureInfo.InstalledUICulture); //double.Parse(mBW.Text);
|
|
|
|
|
|
user.WheelDiameter = Convert.ToInt32(mWD.Text, CultureInfo.InstalledUICulture); //int.Parse(mWD.Text);
|
2021-04-29 11:36:30 +08:00
|
|
|
|
user.Unit = mUnitDropdown.SelectedIndex;
|
|
|
|
|
|
user.Contact = mName.Text;
|
|
|
|
|
|
user.ContactPhone = mPhone.Text;
|
|
|
|
|
|
user.ContactAddress = mAddr.Text;
|
2021-07-30 14:01:10 +08:00
|
|
|
|
var result = userApi.Update(user, out string cookie,"");
|
2021-04-29 11:36:30 +08:00
|
|
|
|
App.isChanged = false;
|
|
|
|
|
|
if (result.result == false)
|
|
|
|
|
|
{
|
|
|
|
|
|
Utils.SetValidate(dict, JArray.FromObject(result.data));
|
|
|
|
|
|
Utils.showToast(gameObject, result.errMsg);
|
|
|
|
|
|
//UIManager.ShowAlert(result.errMsg);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
2021-07-27 18:36:49 +08:00
|
|
|
|
{
|
2021-04-30 21:09:21 +08:00
|
|
|
|
App.CurrentUser = JObject.FromObject(result.data).ToObject<UserResultModel>();
|
2021-07-30 14:01:10 +08:00
|
|
|
|
App.CurrentUser.cookie = cookie;
|
2021-07-27 18:36:49 +08:00
|
|
|
|
if (App.CurrentUser.Birthday.HasValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
App.CurrentUser.Birthday = App.CurrentUser.Birthday.Value.ToLocalTime();
|
|
|
|
|
|
}
|
2021-04-29 11:36:30 +08:00
|
|
|
|
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;
|
|
|
|
|
|
}
|
|
|
|
|
|
Utils.showToast(gameObject, "Success", type: 1);
|
|
|
|
|
|
//UIManager.ShowAlert("Success");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LoadDataSync();
|
|
|
|
|
|
}
|
2021-05-12 10:42:26 +08:00
|
|
|
|
void ChangeAvatar(string path)
|
2021-04-16 17:49:11 +08:00
|
|
|
|
{
|
2021-07-30 14:01:10 +08:00
|
|
|
|
var r = userApi.Update(App.CurrentUser, out string cookie,path);
|
2021-04-28 15:21:06 +08:00
|
|
|
|
App.isChanged = false;
|
2021-04-16 17:49:11 +08:00
|
|
|
|
if (r.result)
|
|
|
|
|
|
{
|
2021-04-23 15:36:18 +08:00
|
|
|
|
var img = JObject.FromObject(r.data).Value<string>("WxHeadImg");
|
2021-07-26 19:50:10 +08:00
|
|
|
|
Utils.DisplayImage(mHeadImage, img, true);
|
2021-04-16 17:49:11 +08:00
|
|
|
|
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;
|
|
|
|
|
|
}
|
2021-07-26 19:50:10 +08:00
|
|
|
|
Debug.Log(img);
|
2021-04-16 17:49:11 +08:00
|
|
|
|
App.CurrentUser.WxHeadImg = img;
|
2021-07-30 14:01:10 +08:00
|
|
|
|
App.CurrentUser.cookie = cookie;
|
2021-04-27 18:26:30 +08:00
|
|
|
|
Utils.showToast(gameObject, "Success", type: 1);
|
|
|
|
|
|
//UIManager.ShowAlert();
|
2021-04-16 17:49:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2021-04-27 18:26:30 +08:00
|
|
|
|
Utils.showToast(gameObject, r.errMsg);
|
|
|
|
|
|
//UIManager.ShowAlert();
|
2021-04-16 17:49:11 +08:00
|
|
|
|
}
|
2021-04-09 09:44:06 +08:00
|
|
|
|
}
|
2021-04-15 15:57:29 +08:00
|
|
|
|
void Cancel(BaseEventData e)
|
|
|
|
|
|
{
|
2021-04-29 11:36:30 +08:00
|
|
|
|
UIManager.ShowPrePanel();
|
|
|
|
|
|
//if (App.isChanged)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// UIManager.ShowConfirm("Tips", "It is detected that you have modified, do you want to give up and return?", () =>
|
|
|
|
|
|
// {
|
|
|
|
|
|
// UIManager.ShowPrePanel();
|
|
|
|
|
|
// UIManager.CloseConfirm();
|
|
|
|
|
|
// });
|
2021-04-28 15:21:06 +08:00
|
|
|
|
|
2021-04-29 11:36:30 +08:00
|
|
|
|
//}
|
|
|
|
|
|
//else
|
|
|
|
|
|
//{
|
|
|
|
|
|
// UIManager.ShowPrePanel();
|
|
|
|
|
|
//}
|
2021-04-15 15:57:29 +08:00
|
|
|
|
}
|
2021-03-30 14:23:41 +08:00
|
|
|
|
}
|