From 0c1c2ed3825e3caa3e79db12de48535fa346d580 Mon Sep 17 00:00:00 2001 From: lishuo Date: Mon, 21 Feb 2022 16:16:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=9D=E5=AD=98=E4=BC=98=E5=8C=96&=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E8=AE=B0=E5=BD=95=E8=87=AA=E5=8A=A8=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Scenes/Ride/Scripts/CyclingController.cs | 8 +++- .../UI/Prefab/ResultList/LocalRouteItem.cs | 48 +++++++++++-------- .../Prefab/ResultList/ResultListController.cs | 2 +- 3 files changed, 35 insertions(+), 23 deletions(-) diff --git a/Assets/Scripts/Scenes/Ride/Scripts/CyclingController.cs b/Assets/Scripts/Scenes/Ride/Scripts/CyclingController.cs index 59c9c7a5..1a67ba82 100644 --- a/Assets/Scripts/Scenes/Ride/Scripts/CyclingController.cs +++ b/Assets/Scripts/Scenes/Ride/Scripts/CyclingController.cs @@ -62,6 +62,7 @@ public class CyclingController : DeviceServiceMonoBase #endregion GameObject loadingcanvas; AbstratctLoadingController loadingController; + private async Task Login() { var result = await new UserApi().Login("15261826280", "123456", ""); @@ -73,6 +74,8 @@ public class CyclingController : DeviceServiceMonoBase public GraphChartBase graph { get; set; } private float activeSeconds { get; set; }//移动端用户进入骑行超过2min,界面进入沉浸状态 + public int RankingId; + public string recordId; protected override void Awake() { base.Awake(); @@ -83,6 +86,7 @@ public class CyclingController : DeviceServiceMonoBase } #endif //获取路书信息 + recordId = Guid.NewGuid().ToString(); mapApi = ConfigHelper.mapApi; routeId = App.RouteIdParam > 0 ? App.RouteIdParam : 2633; competitionId = App.CompetionId; @@ -1196,14 +1200,14 @@ public BaseUIManager singleUIManager; var tempContent = Newtonsoft.Json.JsonConvert.SerializeObject(tempRecordData); System.IO.File.WriteAllText(filePath, tempContent); } - public int RankingId; + public void Save(double totalDistance) { ClearTempFile(); cyclingController.recorderData.EndTime = UIManager.Now.GetDateTime(); isQuit = true; isStart = false; - string recordId = Guid.NewGuid().ToString(); + //string recordId = Guid.NewGuid().ToString(); //var path = Helper.GetDataDir("MapWorkoutRecords/"+ recordId); var path = PFConstants.MapWorkoutRecordFolder + "/" + recordId; Helper.CreateDirectoryIfNotExsit(path); diff --git a/Assets/Scripts/UI/Prefab/ResultList/LocalRouteItem.cs b/Assets/Scripts/UI/Prefab/ResultList/LocalRouteItem.cs index 939e49dc..4c32b979 100644 --- a/Assets/Scripts/UI/Prefab/ResultList/LocalRouteItem.cs +++ b/Assets/Scripts/UI/Prefab/ResultList/LocalRouteItem.cs @@ -88,33 +88,41 @@ public class LocalRouteItem : MonoBehaviour, IPointerExitHandler, IPointerEnterH listFileName.Add(item); } } + DeleteLocalRecord(); } + void DeleteLocalRecord(bool showMessage=false) + { + //自动上传 + try + { + MapInterruptRecordApi service = ConfigHelper.mapInterruptRecordApi; + var result = service.Add(record, listFileName); + //删除文件 + if (result.result) + { + Helper.DelectDir(path); + Destroy(gameObject); + } + if (showMessage) + { + Utils.showToast(gameObject, result.errMsg); + } + + } + catch (Exception e) + { + Utils.showToast(gameObject, e.Message); + } + } void GoUplaod() { UIManager.ShowConfirm("Upload", "Upload the local record?", () => { - try - { - MapInterruptRecordApi service = new MapInterruptRecordApi(); - var result = service.Add(record, listFileName); - //删除文件 - UIManager.CloseConfirm(); - if (result.result) - { - Helper.DelectDir(path); - DestroyImmediate(gameObject); - } - else - { - Utils.showToast(gameObject, result.errMsg); - } - } - catch (Exception e) - { - Utils.showToast(gameObject, e.Message); - } + DeleteLocalRecord(true); + //删除文件 + UIManager.CloseConfirm(); }); } void GoDelete() diff --git a/Assets/Scripts/UI/Prefab/ResultList/ResultListController.cs b/Assets/Scripts/UI/Prefab/ResultList/ResultListController.cs index 46f54fa2..aeb4cbfb 100644 --- a/Assets/Scripts/UI/Prefab/ResultList/ResultListController.cs +++ b/Assets/Scripts/UI/Prefab/ResultList/ResultListController.cs @@ -264,7 +264,7 @@ public class ResultListController : PFUIPanel { if (Directory.Exists(item)) { - var d = new DirectoryInfo(item); + //var d = new DirectoryInfo(item); //var createTime = d.CreationTime;//create time //var newTime = createTime.AddSeconds(30D); //if (newTime < DateTime.Now)