/// <summary> /// 获取当前活动 /// </summary> /// <param name="tryTimes"></param> /// <returns></returns> private async Task GetCurrentActivities(int tryTimes = 2) { if (LastGetActivityTime > DateTime.Now.AddMinutes(-5)) //三分钟以内不重复获取 { return; } var advertisementResult = await OfoApi.GetAdvertisementsAsync(await PositionUtility.GetUnFixBasicPositionAsync()); if (await CheckOfoApiResult(advertisementResult)) { LastGetActivityTime = DateTime.Now; //缓存起始屏幕splash var cacheSplashTask = Task.Run(async() => { try { if (advertisementResult?.Data?.splash?.Count > 0) { var splashInfo = advertisementResult.Data.splash[0]; if (!splashInfo.ImgName.Equals(Global.AppConfig.LastCacheSplashFileName)) //缓存的不是当前Splash { if (await LocalCacheUtility.CacheHttpFileAsync(splashInfo.ImgName, splashInfo.ImgUrl)) { Global.AppConfig.LastCacheSplashFileName = splashInfo.ImgName; Global.AppConfig.CacheSplashExpire = VariousUtility.TimeStampToDateTime(splashInfo.expire * 10000L); Global.SaveAppConfig(); } } } } catch (Exception ex) { Debug.WriteLine(ex); } }); var activity = advertisementResult.Data.activity?.Count > 0 ? advertisementResult.Data.activity[0] : null; if (activity != null) { if (Global.AppConfig.LastShowActivityId == activity.id && Global.AppConfig.LastShowActivityTime > DateTime.Now.AddHours(-3)) //今天已经显示过当前活动,则不再显示 { return; } else //显示活动 { ActivityPopupContentView activityPopupContentView = new ActivityPopupContentView(); ActivityPopupContentViewModel popupContentViewModel = new ActivityPopupContentViewModel() { Activity = activity, }; await ShowContentNotifyAsync(activityPopupContentView, popupContentViewModel); } } } else { if (tryTimes-- > 0) { await GetCurrentActivities(tryTimes); } } }
protected override async Task InitializationAsync() { var cacheSize = await LocalCacheUtility.GetLocalCacheSizeAsync(true); CacheSize = VariousUtility.ByteSizeToString(cacheSize); }
public SettingContentViewModel() { LoginOutCommand = new RelayCommand(async(state) => { var dialogResult = await MessageDialogUtility.ShowMessageAsync("您确认要退出登录吗?", "退出登录"); if (dialogResult == MessageDialogResult.OK) { Global.ClearUserStatus(); await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { if (Window.Current?.Content is Frame rootFrame) { rootFrame.BackStack.Clear(); } }); await TryNavigateAsync(typeof(NoLoginView)); } }); ClearCacheCommand = new RelayCommand(async(state) => { var dialogResult = await MessageDialogUtility.ShowMessageAsync("您确认要清除所有缓存吗?", "缓存清理"); if (dialogResult == MessageDialogResult.OK) { Global.ClearCacheSetting(); await LocalCacheUtility.ClearLocalCacheFile(); await MessageDialogUtility.ShowMessageAsync("缓存清理完成", "缓存清理", MessageDialogType.OK); var cacheSize = await LocalCacheUtility.GetLocalCacheSizeAsync(true); CacheSize = VariousUtility.ByteSizeToString(cacheSize); } }); AboutSoftWareLicenseCommand = new RelayCommand((state) => { var args = new ContentPageArgs() { Name = "软件授权", ContentElement = new SoftWareLicenseContentView(), }; ContentNavigation(args); }); AboutUsCommand = new RelayCommand((state) => { var args = new ContentPageArgs() { Name = "关于我们", ContentElement = new AboutUsContentView(), }; ContentNavigation(args); }); AboutSoftWareCommand = new RelayCommand((state) => { var args = new ContentPageArgs() { Name = "免责声明", ContentElement = new AboutSoftWareContentView(), }; ContentNavigation(args); }); }
private async void SendEmailButtonClick(object sender, RoutedEventArgs e) { var version = $"{Package.Current.Id.Version.Major}.{Package.Current.Id.Version.Minor}.{Package.Current.Id.Version.Build}"; var mailto = new Uri($"mailto:[email protected]?subject=ofo共享单车反馈&body=%0A%0A版本信息:{version}%0A系统信息:{VariousUtility.GetSystemDetail()}%0A"); await Launcher.LaunchUriAsync(mailto); }