123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334 |
- using PDF_Office.Helper;
- using PDF_Office.Properties;
- using Prism.Commands;
- using Prism.Mvvm;
- using Prism.Regions;
- using Prism.Services.Dialogs;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Threading;
- namespace PDF_Office.ViewModels.Dialog.ServiceDialog
- {
- public class UserOutCodeRegionViewModel : BindableBase, INavigationAware
- {
- private static Guid myuuid = Guid.NewGuid();
- private string uuid = myuuid.ToString();
- public IDialogService dialogs;
- private UserDialogViewModel UserDialogViewModel;
- private int time = 60;
- private bool _EnableNextStep = true;
- public bool EnableNextStep
- {
- get { return _EnableNextStep; }
- set { SetProperty(ref _EnableNextStep, value); }
- }
- private string _codetime = "60";
- public string Codetime
- {
- get { return _codetime; }
- set { SetProperty(ref _codetime, value); }
- }
- private string _Codesum = "";
- public string Codesum
- {
- get { return _Codesum; }
- set { SetProperty(ref _Codesum, value); }
- }
- private string _Code1 = "";
- public string Code1
- {
- get { return _Code1; }
- set { SetProperty(ref _Code1, value);
- if (CodeSum())
- {
- Code6Changed();
- }
- }
- }
- private string _Code2 = "";
- public string Code2
- {
- get { return _Code2; }
- set { SetProperty(ref _Code2, value);
- if (CodeSum())
- {
- Code6Changed();
- }
- }
- }
- private string _Code3 = "";
- public string Code3
- {
- get { return _Code3; }
- set { SetProperty(ref _Code3, value);
- if (CodeSum())
- {
- Code6Changed();
- }
- }
- }
- private string _Code4 = "";
- public string Code4
- {
- get { return _Code4; }
- set { SetProperty(ref _Code4, value);
- if (CodeSum())
- {
- Code6Changed();
- }
- }
- }
- private string _Code5 = "";
- public string Code5
- {
- get { return _Code5; }
- set { SetProperty(ref _Code5, value);
- if (CodeSum())
- {
- Code6Changed();
- }
- }
- }
- private string _Code6 = "";
- public string Code6
- {
- get { return _Code6; }
- set { SetProperty(ref _Code6, value);
- }
- }
- private string _UserCodemsg = "";
- public string UserCodemsg
- {
- get { return _UserCodemsg; }
- set { SetProperty(ref _UserCodemsg, value); }
- }
- private Visibility _codeagin = Visibility.Collapsed;
- public Visibility Codeagin
- {
- get { return _codeagin; }
- set { SetProperty(ref _codeagin, value); }
- }
- private Visibility _UserCodemsgVis = Visibility.Collapsed;
- public Visibility UserCodemsgVis
- {
- get { return _UserCodemsgVis; }
- set { SetProperty(ref _UserCodemsgVis, value); }
- }
- public bool IsNavigationTarget(NavigationContext navigationContext)
- {
- return true;
- }
- public void OnNavigatedFrom(NavigationContext navigationContext)
- {
- }
- public void OnNavigatedTo(NavigationContext navigationContext)
- {
- navigationContext.Parameters.TryGetValue<UserDialogViewModel>("UserDialogViewModel", out UserDialogViewModel);
- }
- public DelegateCommand UserOutCancelCommand { get; set; }
- public DelegateCommand CodetooCommand { get; set; }
- public DelegateCommand Code6ChangedCommand { get; set; }
- public DelegateCommand UserOutCommand { get; set; }
- public UserOutCodeRegionViewModel(IRegionManager regionManager, IDialogService dialogService)
- {
- Timebegin();
- dialogs = dialogService;
- UserOutCancelCommand = new DelegateCommand(UserOutCancel);
- CodetooCommand = new DelegateCommand(Codetoo);
- Code6ChangedCommand = new DelegateCommand(Code6Changed);
- UserOutCommand = new DelegateCommand(UserOut);
- }
- private void UserOutCancel()
- {
- UserDialogViewModel.Close();
- }
- //注销
- private void UserOut()
- {
- Codesum = Code1 + Code2 + Code3 + Code4 + Code5 + Code6;
- if (Codesum.Length == 6)
- {
-
-
- if (ServiceHelper.Ok_code(UserDialogViewModel.UserEmail, Codesum, "user_log_off") == "success")
- {
-
- if (ServiceHelper.Usergout(Codesum) == "success")
- {
- Settings.Default.AppProperties.LoginToken = "";
- App.IsLogin =false;
- Settings.Default.Save();
- App.mainWindowViewModel.UserVis = Visibility.Collapsed;
- App.mainWindowViewModel.RegisterVis = Visibility.Collapsed;
- App.mainWindowViewModel.LoginVis = Visibility.Visible;
- UserDialogViewModel.Close();
- }
- else
- {
- UserCodemsg = ServiceHelper.Usergout(Codesum);
- UserCodemsgVis = Visibility.Visible;
- }
- }
- else
- {
- UserCodemsg = ServiceHelper.Ok_code(UserDialogViewModel.UserEmail, Codesum, "user_log_off");
- UserCodemsgVis = Visibility.Visible;
- }
-
-
- }
- else
- {
- UserCodemsg = "请输入六位数验证码";
- }
- }
- private bool CodeSum()
- {
- Codesum = Code1 + Code2 + Code3 + Code4 + Code5 + Code6;
- if (Codesum.Length == 6)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- private void Code6Changed()
- {
- if (Code6.Length == 1)
- {
- if (CodeSum() == true)
- {
- if (ServiceHelper.Ok_code(UserDialogViewModel.UserEmail, Codesum, "user_log_off") == "success")
- {
- if (ServiceHelper.Usergout(Codesum) == "success")
- {
- App.IsLogin = false;
- UserDialogViewModel.Close();
- }
- else
- {
- UserCodemsg = ServiceHelper.Usergout(Codesum);
- UserCodemsgVis = Visibility.Visible;
- }
- }
- else
- {
- UserCodemsg = ServiceHelper.Ok_code(UserDialogViewModel.UserEmail, Codesum, "user_log_off");
- UserCodemsgVis = Visibility.Visible;
- }
- }
- else
- {
- UserCodemsg = "请输入六位数验证码";
- UserCodemsgVis = Visibility.Visible;
- }
- }
-
- }
- private void Codetoo()
- {
- Codeagin = Visibility.Collapsed;
- time = 60;
- ServiceHelper.Get_code("user_log_off", UserDialogViewModel.UserEmail);
- }
- public void disTimer_Tick(object sender, EventArgs e)
- {
- if (time == 0)
- {
- Codeagin = Visibility.Visible;
- Codetime = "";
- }
- else
- {
- time--;
- Codetime = "(" + time.ToString() + ")";
- }
- }
- private DispatcherTimer disTimer = new DispatcherTimer();
- public void Timebegin()
- {
- time = 60;
- //设置定时器
- disTimer.Tick += new EventHandler(disTimer_Tick);//每一秒执行的方法
- disTimer.Interval = new TimeSpan(10000000); //时间间隔为一秒。
- disTimer.Start();//计时开始
- }
- }
- }
|