LoginRegionViewModel.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. using PDF_Office.Helper;
  2. using PDF_Office.Model;
  3. using Prism.Commands;
  4. using Prism.Mvvm;
  5. using Prism.Regions;
  6. using Prism.Services.Dialogs;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Diagnostics;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Text.RegularExpressions;
  13. using System.Threading.Tasks;
  14. using System.Windows;
  15. using System.Windows.Controls;
  16. namespace PDF_Office.ViewModels.Dialog.ServiceDialog
  17. {
  18. public class LoginRegionViewModel : BindableBase, INavigationAware
  19. {
  20. private LoginDialogViewModel LoginDialogViewModel;
  21. public IDialogService dialogs;
  22. public bool IsNavigationTarget(NavigationContext navigationContext)
  23. {
  24. return true;
  25. }
  26. public void OnNavigatedFrom(NavigationContext navigationContext)
  27. {
  28. }
  29. public void OnNavigatedTo(NavigationContext navigationContext)
  30. {
  31. navigationContext.Parameters.TryGetValue<LoginDialogViewModel>("LoginDialogViewModel", out LoginDialogViewModel);
  32. }
  33. private bool enableNextStep = false;
  34. public bool EnableNextStep
  35. {
  36. get { return enableNextStep; }
  37. set { SetProperty(ref enableNextStep, value); }
  38. }
  39. private string _LoginEmaillook;
  40. public string LoginEmaillook
  41. {
  42. get { return _LoginEmaillook; }
  43. set { SetProperty(ref _LoginEmaillook, value);}
  44. }
  45. private string _LoginNextStep = "Next Step";
  46. public string LoginNextStep
  47. {
  48. get { return _LoginNextStep; }
  49. set
  50. {
  51. SetProperty(ref _LoginNextStep, value);
  52. }
  53. }
  54. private string _LoginEmail = "";
  55. public string LoginEmail
  56. {
  57. get { return _LoginEmail; }
  58. set
  59. {
  60. SetProperty(ref _LoginEmail, value);
  61. if (LoginEmail == "")
  62. {
  63. LoginEmaillook = "";
  64. }
  65. else
  66. {
  67. CheckMail(LoginEmail);
  68. }
  69. CheckEnableNextStepEncrypt();
  70. }
  71. }
  72. private string _LoginEmailMsg = "Enter email address";
  73. public string LoginEmailMsg
  74. {
  75. get { return _LoginEmailMsg; }
  76. set
  77. {
  78. SetProperty(ref _LoginEmailMsg, value);
  79. }
  80. }
  81. public DelegateCommand LoginNextCommand { get; set; }
  82. public DelegateCommand GoLoginCommand { get; set; }
  83. LoginRegionViewModel(IRegionManager regionManager, IDialogService dialogService)
  84. {
  85. dialogs = dialogService;
  86. LoginNextCommand = new DelegateCommand(LoginNext);
  87. GoLoginCommand = new DelegateCommand(GoLogin);
  88. }
  89. private void LoginNext()
  90. {
  91. if (ServiceHelper.Ok_email(LoginEmail, "1") == "success")
  92. {
  93. LoginDialogViewModel.LoginEmail = LoginEmail;
  94. LoginDialogViewModel.RegionMan("LoginPasswordRegion");
  95. }
  96. else
  97. {
  98. LoginEmaillook = ServiceHelper.Ok_email(LoginEmail, "1");
  99. }
  100. ServiceHelper.ALLEmail = LoginEmail;
  101. }
  102. private void CheckMail(string mail)
  103. {
  104. string str = "^([a-z0-9_\\.-]+)@([\\da-z\\.-]+)\\.([a-z\\.]{2,6})$";
  105. Regex mReg = new Regex(str);
  106. if (mReg.IsMatch(mail))
  107. {
  108. LoginEmaillook = "";
  109. }
  110. else
  111. {
  112. LoginEmaillook = "请输入正确的邮箱格式";
  113. }
  114. }
  115. private void GoLogin()
  116. {
  117. LoginDialogViewModel.Close();
  118. App.mainWindowViewModel.OpenRegister();
  119. }
  120. private void CheckEnableNextStepEncrypt()
  121. {
  122. EnableNextStep = true;
  123. if (string.IsNullOrEmpty(LoginEmail)||LoginEmaillook!="")
  124. {
  125. EnableNextStep = false;
  126. }
  127. }
  128. }
  129. }