修改细节

This commit is contained in:
Caiyanpeng committed 2021-04-28 15:22:04 +08:00
1 parent 5080503ebd
commit c8111d7db3
25 files changed
+1677 -7833

No files matched your search

@@ -82,7 +82,7 @@ public class FeedbackController : PFUIPanel
{
if (paths.ContainsValue(path))
{
Utils.showToast(gameObject, "图片已存在,请选择其他图片");
Utils.showToast(gameObject, "Picture already exists, please choose another picture");//图片已存在,请选择其他图片
return;
}
self.GetComponent<Image>().sprite = Utils.PngToSprite(path, 110, 110);
@@ -116,7 +116,7 @@ public class FeedbackController : PFUIPanel
}
else
{
Utils.showToast(gameObject, "已提交", type: 1);
Utils.showToast(gameObject, "Submitted", type: 1);//已提交
}
}
// Update is called once per frame
@@ -6,6 +6,7 @@ using DG.Tweening;
using UnityEngine.UI;
using Assets.Scripts.Apis;
using Newtonsoft.Json.Linq;
using Assets.Scripts;
public class EarthController : PFUIPanel
{
@@ -45,7 +46,6 @@ public class EarthController : PFUIPanel
protected override void Start()
{
itemObject = Resources.Load("UI/Prefab/BigMap/Item");
var rootPanel = this.transform.Find("Canvas").Find("Panel");
var panel = rootPanel.Find("Panel");
@@ -171,7 +171,7 @@ public class EditUserController : PFUIPanel
var result = await new UserApi().Login("13115011550", "laozhong", "");
App.CurrentUser = result.data;
}
async Task LoadDataSync()
void LoadDataSync()
{
//if (!App.FromLogin)
//{
@@ -246,6 +246,7 @@ public class EditUserController : PFUIPanel
{
base.Show();
LoadDataSync();
App.isChanged = false;
}
private void Switch(BaseEventData arg0)
{
@@ -276,58 +277,64 @@ public class EditUserController : PFUIPanel
mDayDropdown.AddOptions(list);
}
async void Save(BaseEventData e)
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;
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, "请填写相关信息");
return;
}
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)
{
Utils.SetValidate(dict, JArray.FromObject(result.data));
Utils.showToast(gameObject, result.errMsg);
//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;
}
Utils.showToast(gameObject, "Success", type: 1);
//UIManager.ShowAlert("Success");
}
LoadDataSync();
UIManager.ShowConfirm("Confirm", "Are you sure to edit?", async () =>
{
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);
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;
}
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);
App.isChanged = false;
if (result.result == false)
{
Utils.SetValidate(dict, JArray.FromObject(result.data));
Utils.showToast(gameObject, result.errMsg);
//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;
}
Utils.showToast(gameObject, "Success", type: 1);
//UIManager.ShowAlert("Success");
}
LoadDataSync();
});
//App.CurrentUser = user;
//UIManager.ShowAlert("result.errMsg");
@@ -335,6 +342,7 @@ public class EditUserController : PFUIPanel
async void ChangeAvatar(string path)
{
var r = await userApi.Update(App.CurrentUser, path);
App.isChanged = false;
if (r.result)
{
var img = JObject.FromObject(r.data).Value<string>("WxHeadImg");
@@ -358,6 +366,18 @@ public class EditUserController : PFUIPanel
}
void Cancel(BaseEventData e)
{
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();
});
}
else
{
UIManager.ShowPrePanel();
}
}
}
@@ -100,6 +100,10 @@ public class HomeController : PFUIPanel
{
userInfo.Find("SexIcon").GetComponent<Image>().sprite = Resources.Load<Sprite>("Images/woman");
}
else
{
userInfo.Find("SexIcon").GetComponent<Image>().sprite = Resources.Load<Sprite>("Images/man");
}
Utils.DisplayImage(StartCoroutine, userInfo.Find("Avatar").GetComponent<RawImage>(), App.CurrentUser.WxHeadImg);
userInfo.Find("Country").GetComponent<RawImage>().texture = UIManager.Instance.loginRegOptions.GetCountryImageByName(App.CurrentUser.Country);
@@ -84,10 +84,19 @@ public class UserInfoController : PFUIPanel
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";
//infoPanel.Find("Ftp").Find("Time").GetComponent<Text>().text = user.LastUpdateFtpTime.ToString("yyyy-MM-dd");
//infoPanel.Find("MHR").Find("Time").GetComponent<Text>().text = user.MaxHeartRate.ToString();
//infoPanel.Find("Weight").Find("Time").GetComponent<Text>().text = user.LastUpdateWeightTime.ToString("yyyy-MM-dd");
//infoPanel.Find("BW").Find("Time").GetComponent<Text>().text = user.LastUpdateBicycleWeightTime.ToString("yyyy-MM-dd");
//infoPanel.Find("WD").Find("Time").GetComponent<Text>().text = $"{user.WheelDiameter}MM";
if (user.Sex == 2)
{
infoPanel.Find("SexIcon").GetComponent<Image>().sprite = Resources.Load<Sprite>("Images/woman");
}
else
{
infoPanel.Find("SexIcon").GetComponent<Image>().sprite = Resources.Load<Sprite>("Images/man");
}
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();
@@ -89,35 +89,57 @@ public class RouteItem : MonoBehaviour, IPointerExitHandler, IPointerEnterHandle
right.Find("Value").GetComponent<Text>().text = result.Ranking.ToString();
}
right.gameObject.SetActive(true);
gameObject.GetComponent<Button>().onClick.AddListener(() =>
{
Application.OpenURL(result.ViewUrl);
});
this.index = index;
}
private void Delete()
{
//throw new NotImplementedException();
UIManager.ShowAlert("暂未实现");
UIManager.ShowConfirm("Delete", "Delete this record?", async () =>
{
var r = await ConfigHelper.mapApi.DeleteRecord(routeResult.Id);
UIManager.CloseConfirm();
if (r.result)
{
DestroyImmediate(gameObject);
}
else
{
Utils.showToast(gameObject, r.errMsg);
}
});
}
private void GoReRide()
{
App.RouteIdParam = routeResult.RouteId;
App.routeResult = routeResult;
App.routeResult.ContinueCyclingParam = null;
SceneManager.LoadScene("Ride");
UIManager.ShowConfirm("ReRide", "Ride again?", () =>
{
App.RouteIdParam = routeResult.RouteId;
App.routeResult = routeResult;
App.routeResult.ContinueCyclingParam = null;
SceneManager.LoadScene("Ride");
});
}
private void GoContinue()
{
if (routeResult.ContinueCyclingParam != null)
UIManager.ShowConfirm("Continue", "Continue riding?", () =>
{
App.RouteIdParam = routeResult.RouteId;
App.routeResult = routeResult;
SceneManager.LoadScene("Ride");
}
if (routeResult.ContinueCyclingParam != null)
{
App.RouteIdParam = routeResult.RouteId;
App.routeResult = routeResult;
SceneManager.LoadScene("Ride");
}
});
}
void SetButtonColor(bool f)
{
if (index == 0)
if (index == 0 && routeResult!=null)
{
if (f)
{
@@ -166,6 +188,7 @@ public class RouteItem : MonoBehaviour, IPointerExitHandler, IPointerEnterHandle
}
titleColor = "#414251";
SetButtonColor(false);
Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
}
public void OnPointerEnter(PointerEventData eventData)
@@ -192,5 +215,6 @@ public class RouteItem : MonoBehaviour, IPointerExitHandler, IPointerEnterHandle
}
titleColor = "#5c5c6e";
SetButtonColor(true);
Cursor.SetCursor(Resources.Load<Texture2D>("Images/PointerButtonHover"), Vector2.zero, CursorMode.Auto);
}
}