LoginRegionViewModel.cs 4.7 KB

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