PasswordUpdataRegionVIewModel.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. using PDF_Master.Helper;
  2. using PDF_Master.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.Threading.Tasks;
  13. using System.Windows;
  14. using System.Windows.Controls;
  15. namespace PDF_Master.ViewModels.Dialog.ServiceDialog
  16. {
  17. public class PasswordUpdataRegionViewModel : BindableBase, INavigationAware
  18. {
  19. private string uuid = ServiceHelper.GetDeviceSerialNumber();
  20. private ErrorCodeHelper ErrorCodeHelper = new ErrorCodeHelper();
  21. private LoginDialogViewModel LoginDialogViewModel;
  22. public IDialogService dialogs;
  23. public bool IsNavigationTarget(NavigationContext navigationContext)
  24. {
  25. return true;
  26. }
  27. public void OnNavigatedFrom(NavigationContext navigationContext)
  28. {
  29. }
  30. public void OnNavigatedTo(NavigationContext navigationContext)
  31. {
  32. navigationContext.Parameters.TryGetValue<LoginDialogViewModel>("LoginDialogViewModel", out LoginDialogViewModel);
  33. LoginEmail = LoginDialogViewModel.LoginEmail;
  34. }
  35. #region 文案
  36. private string _Text_passuodata = "";
  37. public string Text_passuodata
  38. {
  39. get { return _Text_passuodata; }
  40. set
  41. {
  42. SetProperty(ref _Text_passuodata, value);
  43. }
  44. }
  45. private string _LoginPasswordMsg = "";
  46. public string LoginPasswordMsg
  47. {
  48. get { return _LoginPasswordMsg; }
  49. set
  50. {
  51. SetProperty(ref _LoginPasswordMsg, value);
  52. }
  53. }
  54. private string _LoginPasswordMsg2 = "";
  55. public string LoginPasswordMsg2
  56. {
  57. get { return _LoginPasswordMsg2; }
  58. set
  59. {
  60. SetProperty(ref _LoginPasswordMsg2, value);
  61. }
  62. }
  63. private string _Text_ok = "";
  64. public string Text_ok
  65. {
  66. get { return _Text_ok; }
  67. set
  68. {
  69. SetProperty(ref _Text_ok, value);
  70. }
  71. }
  72. private void InitString()
  73. {
  74. Text_passuodata = App.ServiceLoader.GetString("Text_passuodata");
  75. LoginPasswordMsg = App.ServiceLoader.GetString("LoginPasswordMsg");
  76. LoginPasswordMsg2 = App.ServiceLoader.GetString("LoginPasswordMsg2");
  77. Text_ok = App.ServiceLoader.GetString("Text_ok");
  78. }
  79. #endregion
  80. private bool enableNextStep = false;
  81. public bool EnableNextStep
  82. {
  83. get { return enableNextStep; }
  84. set { SetProperty(ref enableNextStep, value); }
  85. }
  86. private string _LoginEmail = "";
  87. public string LoginEmail
  88. {
  89. get { return _LoginEmail; }
  90. set
  91. {
  92. SetProperty(ref _LoginEmail, value);
  93. CheckEnableNextStepEncrypt();
  94. }
  95. }
  96. private string _LoginPasswordlook;
  97. public string LoginPasswordlook
  98. {
  99. get { return _LoginPasswordlook; }
  100. set { SetProperty(ref _LoginPasswordlook, value); }
  101. }
  102. private string _LoginPasswordlook2;
  103. public string LoginPasswordlook2
  104. {
  105. get { return _LoginPasswordlook2; }
  106. set { SetProperty(ref _LoginPasswordlook2, value); }
  107. }
  108. private string _LoginPassword = "";
  109. public string LoginPassword
  110. {
  111. get { return _LoginPassword; }
  112. set
  113. {
  114. SetProperty(ref _LoginPassword, value);
  115. PasswordUpdatalookVis = Visibility.Collapsed;
  116. if (string.IsNullOrEmpty(LoginPassword))
  117. {
  118. ChkVis = Visibility.Collapsed;
  119. }
  120. else
  121. {
  122. ChkVis = Visibility.Visible;
  123. }
  124. CheckEnableNextStepEncrypt();
  125. }
  126. }
  127. private Visibility _ChkVis = Visibility.Collapsed;
  128. public Visibility ChkVis
  129. {
  130. get { return _ChkVis; }
  131. set { SetProperty(ref _ChkVis, value); }
  132. }
  133. private Visibility _ChkVis2 = Visibility.Collapsed;
  134. public Visibility ChkVis2
  135. {
  136. get { return _ChkVis2; }
  137. set { SetProperty(ref _ChkVis2, value); }
  138. }
  139. private Visibility _LoginPasswordVisibility = Visibility.Visible;
  140. public Visibility LoginPasswordVisibility
  141. {
  142. get { return _LoginPasswordVisibility; }
  143. set
  144. {
  145. if (value == Visibility.Visible)
  146. {
  147. LoginTextVisibility = Visibility.Collapsed;
  148. }
  149. else
  150. {
  151. LoginTextVisibility = Visibility.Visible;
  152. }
  153. SetProperty(ref _LoginPasswordVisibility, value);
  154. }
  155. }
  156. private Visibility _LoginTextVisibility = Visibility.Collapsed;
  157. public Visibility LoginTextVisibility
  158. {
  159. get { return _LoginTextVisibility; }
  160. set { SetProperty(ref _LoginTextVisibility, value); }
  161. }
  162. private string _LoginPassword2 = "";
  163. public string LoginPassword2
  164. {
  165. get { return _LoginPassword2; }
  166. set
  167. {
  168. SetProperty(ref _LoginPassword2, value);
  169. PasswordUpdatalookVis = Visibility.Collapsed;
  170. if (string.IsNullOrEmpty(LoginPassword2))
  171. {
  172. ChkVis2 = Visibility.Collapsed;
  173. }
  174. else
  175. {
  176. ChkVis2 = Visibility.Visible;
  177. }
  178. CheckEnableNextStepEncrypt();
  179. }
  180. }
  181. private Visibility _LoginPasswordVisibility2 = Visibility.Visible;
  182. public Visibility LoginPasswordVisibility2
  183. {
  184. get { return _LoginPasswordVisibility2; }
  185. set
  186. {
  187. if (value == Visibility.Visible)
  188. {
  189. LoginTextVisibility2 = Visibility.Collapsed;
  190. }
  191. else
  192. {
  193. LoginTextVisibility2 = Visibility.Visible;
  194. }
  195. SetProperty(ref _LoginPasswordVisibility2, value);
  196. }
  197. }
  198. private Visibility _LoginTextVisibility2 = Visibility.Collapsed;
  199. public Visibility LoginTextVisibility2
  200. {
  201. get { return _LoginTextVisibility2; }
  202. set { SetProperty(ref _LoginTextVisibility2, value); }
  203. }
  204. private string _PasswordUpdatamsglook = "";
  205. public string PasswordUpdatamsglook
  206. {
  207. get { return _PasswordUpdatamsglook; }
  208. set
  209. {
  210. SetProperty(ref _PasswordUpdatamsglook, value);
  211. }
  212. }
  213. private Visibility _PasswordUpdatalookVis = Visibility.Collapsed;
  214. public Visibility PasswordUpdatalookVis
  215. {
  216. get { return _PasswordUpdatalookVis; }
  217. set { SetProperty(ref _PasswordUpdatalookVis, value); }
  218. }
  219. public DelegateCommand<object> DisplayPasswordCommand { get; set; }
  220. public DelegateCommand<object> DisplayPasswordCommand2 { get; set; }
  221. public DelegateCommand ChangeEmailCommand { get; set; }
  222. public DelegateCommand GoCodeUpdataCommand { get; set; }
  223. public DelegateCommand PasswordUpdataCommand { get; set; }
  224. public DelegateCommand LinkLicenseCommand { get; set; }
  225. public DelegateCommand LoginPasswordChangedCommand { get; set; }
  226. public DelegateCommand LoginPasswordChanged2Command { get; set; }
  227. PasswordUpdataRegionViewModel(IRegionManager regionManager, IDialogService dialogService)
  228. {
  229. dialogs = dialogService;
  230. InitString();
  231. DisplayPasswordCommand = new DelegateCommand<object>(DisplayPassword);
  232. DisplayPasswordCommand2 = new DelegateCommand<object>(DisplayPassword2);
  233. PasswordUpdataCommand = new DelegateCommand(PasswordUpdata);
  234. LoginPasswordChangedCommand = new DelegateCommand(LoginPasswordChanged);
  235. LoginPasswordChanged2Command = new DelegateCommand(LoginPasswordChanged2);
  236. }
  237. private void LoginPasswordChanged()
  238. {
  239. if (LoginPassword.Length < 6)
  240. {
  241. LoginPasswordlook = "At least 6 characters";
  242. }
  243. else if (LoginPassword.Length > 24)
  244. {
  245. LoginPasswordlook = "Up to 24 characters";
  246. }
  247. else
  248. {
  249. LoginPasswordlook = "";
  250. }
  251. }
  252. private void LoginPasswordChanged2()
  253. {
  254. if (LoginPassword2.Length < 6)
  255. {
  256. LoginPasswordlook2 = "At least 6 characters";
  257. }
  258. else if (LoginPassword2.Length > 24)
  259. {
  260. LoginPasswordlook2 = "Up to 24 characters";
  261. }
  262. else
  263. {
  264. LoginPasswordlook2 = "";
  265. }
  266. }
  267. private void PasswordUpdata()
  268. {
  269. if (ServiceHelper.Rebirth(LoginEmail, LoginPassword2, LoginPassword, LoginDialogViewModel.PasswordCode) == "200")
  270. {
  271. LoginDialogViewModel.RegionMan("LoginRegion");
  272. }
  273. else
  274. {
  275. PasswordUpdatamsglook = ErrorCodeHelper.Ercode(ServiceHelper.Rebirth(LoginEmail, LoginPassword2, LoginPassword, LoginDialogViewModel.PasswordCode));
  276. PasswordUpdatalookVis = Visibility.Visible;
  277. }
  278. }
  279. private void CheckEnableNextStepEncrypt()
  280. {
  281. EnableNextStep = true;
  282. if (LoginPassword.Length < 6 || LoginPassword.Length > 24 || LoginPassword2.Length < 6 || LoginPassword2.Length > 24)
  283. {
  284. EnableNextStep = false;
  285. }
  286. }
  287. public void DisplayPassword(object e)
  288. {
  289. var chk = e as CheckBox;
  290. if (chk != null)
  291. {
  292. if (chk.IsChecked == true)
  293. {
  294. LoginPasswordVisibility = Visibility.Collapsed;
  295. }
  296. else
  297. {
  298. LoginPasswordVisibility = Visibility.Visible;
  299. }
  300. }
  301. }
  302. public void DisplayPassword2(object e)
  303. {
  304. var chk = e as CheckBox;
  305. if (chk != null)
  306. {
  307. if (chk.IsChecked == true)
  308. {
  309. LoginPasswordVisibility2 = Visibility.Collapsed;
  310. }
  311. else
  312. {
  313. LoginPasswordVisibility2 = Visibility.Visible;
  314. }
  315. }
  316. }
  317. }
  318. }