PasswordUpdataRegionVIewModel.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  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. Codemax = App.ServiceLoader.GetString("Codemax");
  75. Codemin = App.ServiceLoader.GetString("Codemin");
  76. Text_passuodata = App.ServiceLoader.GetString("Text_toocode");
  77. LoginPasswordMsg = App.ServiceLoader.GetString("LoginPasswordMsg");
  78. LoginPasswordMsg2 = App.ServiceLoader.GetString("LoginPasswordMsg2");
  79. Text_ok = App.ServiceLoader.GetString("Text_ok");
  80. }
  81. #endregion
  82. private bool enableNextStep = false;
  83. public bool EnableNextStep
  84. {
  85. get { return enableNextStep; }
  86. set { SetProperty(ref enableNextStep, value); }
  87. }
  88. private string _LoginEmail = "";
  89. public string LoginEmail
  90. {
  91. get { return _LoginEmail; }
  92. set
  93. {
  94. SetProperty(ref _LoginEmail, value);
  95. CheckEnableNextStepEncrypt();
  96. }
  97. }
  98. private string _LoginPasswordlook;
  99. public string LoginPasswordlook
  100. {
  101. get { return _LoginPasswordlook; }
  102. set { SetProperty(ref _LoginPasswordlook, value); }
  103. }
  104. private string _LoginPasswordlook2;
  105. public string LoginPasswordlook2
  106. {
  107. get { return _LoginPasswordlook2; }
  108. set { SetProperty(ref _LoginPasswordlook2, value); }
  109. }
  110. private string _LoginPassword = "";
  111. public string LoginPassword
  112. {
  113. get { return _LoginPassword; }
  114. set
  115. {
  116. SetProperty(ref _LoginPassword, value);
  117. if (string.IsNullOrEmpty(LoginPassword))
  118. {
  119. ChkVis = Visibility.Collapsed;
  120. }
  121. else
  122. {
  123. ChkVis = Visibility.Visible;
  124. }
  125. CheckEnableNextStepEncrypt();
  126. }
  127. }
  128. private string _LoginPassword2 = "";
  129. public string LoginPassword2
  130. {
  131. get { return _LoginPassword2; }
  132. set
  133. {
  134. SetProperty(ref _LoginPassword2, value);
  135. if (string.IsNullOrEmpty(LoginPassword2))
  136. {
  137. ChkVis2 = Visibility.Collapsed;
  138. }
  139. else
  140. {
  141. ChkVis2 = Visibility.Visible;
  142. }
  143. CheckEnableNextStepEncrypt();
  144. }
  145. }
  146. private Visibility _ChkVis = Visibility.Collapsed;
  147. public Visibility ChkVis
  148. {
  149. get { return _ChkVis; }
  150. set { SetProperty(ref _ChkVis, value); }
  151. }
  152. private Visibility _ChkVis2 = Visibility.Collapsed;
  153. public Visibility ChkVis2
  154. {
  155. get { return _ChkVis2; }
  156. set { SetProperty(ref _ChkVis2, value); }
  157. }
  158. private Visibility _LoginPasswordVisibility = Visibility.Visible;
  159. public Visibility LoginPasswordVisibility
  160. {
  161. get { return _LoginPasswordVisibility; }
  162. set
  163. {
  164. if (value == Visibility.Visible)
  165. {
  166. LoginTextVisibility = Visibility.Collapsed;
  167. }
  168. else
  169. {
  170. LoginTextVisibility = Visibility.Visible;
  171. }
  172. SetProperty(ref _LoginPasswordVisibility, value);
  173. }
  174. }
  175. private Visibility _LoginTextVisibility = Visibility.Collapsed;
  176. public Visibility LoginTextVisibility
  177. {
  178. get { return _LoginTextVisibility; }
  179. set { SetProperty(ref _LoginTextVisibility, value); }
  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 string _Codemax = "";
  214. public string Codemax
  215. {
  216. get { return _Codemax; }
  217. set
  218. {
  219. SetProperty(ref _Codemax, value);
  220. }
  221. }
  222. private string _Codemin = "";
  223. public string Codemin
  224. {
  225. get { return _Codemin; }
  226. set
  227. {
  228. SetProperty(ref _Codemin, value);
  229. }
  230. }
  231. private Visibility _PasswordUpdatalookVis = Visibility.Collapsed;
  232. public Visibility PasswordUpdatalookVis
  233. {
  234. get { return _PasswordUpdatalookVis; }
  235. set { SetProperty(ref _PasswordUpdatalookVis, value); }
  236. }
  237. public DelegateCommand<object> DisplayPasswordCommand { get; set; }
  238. public DelegateCommand<object> DisplayPasswordCommand2 { get; set; }
  239. public DelegateCommand ChangeEmailCommand { get; set; }
  240. public DelegateCommand GoCodeUpdataCommand { get; set; }
  241. public DelegateCommand PasswordUpdataCommand { get; set; }
  242. public DelegateCommand LinkLicenseCommand { get; set; }
  243. public DelegateCommand LoginPasswordChangedCommand { get; set; }
  244. public DelegateCommand LoginPasswordChanged2Command { get; set; }
  245. PasswordUpdataRegionViewModel(IRegionManager regionManager, IDialogService dialogService)
  246. {
  247. dialogs = dialogService;
  248. InitString();
  249. DisplayPasswordCommand = new DelegateCommand<object>(DisplayPassword);
  250. DisplayPasswordCommand2 = new DelegateCommand<object>(DisplayPassword2);
  251. PasswordUpdataCommand = new DelegateCommand(PasswordUpdata);
  252. LoginPasswordChangedCommand = new DelegateCommand(LoginPasswordChanged);
  253. LoginPasswordChanged2Command = new DelegateCommand(LoginPasswordChanged2);
  254. }
  255. private void LoginPasswordChanged()
  256. {
  257. if (LoginPassword.Length < 6 && LoginPassword.Length > 0)
  258. {
  259. LoginPasswordlook = Codemin;
  260. }
  261. else if (LoginPassword.Length > 24)
  262. {
  263. LoginPasswordlook = Codemax;
  264. }
  265. else
  266. {
  267. LoginPasswordlook = "";
  268. }
  269. }
  270. private void LoginPasswordChanged2()
  271. {
  272. if (LoginPassword2.Length < 6 && LoginPassword2.Length > 0)
  273. {
  274. LoginPasswordlook2 = Codemin;
  275. }
  276. else if (LoginPassword2.Length > 24)
  277. {
  278. LoginPasswordlook2 =Codemax;
  279. }
  280. else
  281. {
  282. LoginPasswordlook2 = "";
  283. }
  284. }
  285. private void PasswordUpdata()
  286. {
  287. if (ServiceHelper.Rebirth(LoginEmail, LoginPassword2, LoginPassword, LoginDialogViewModel.PasswordCode) == "200")
  288. {
  289. LoginDialogViewModel.RegionMan("LoginRegion");
  290. }
  291. else
  292. {
  293. PasswordUpdatamsglook = ErrorCodeHelper.Ercode(ServiceHelper.Rebirth(LoginEmail, LoginPassword2, LoginPassword, LoginDialogViewModel.PasswordCode));
  294. PasswordUpdatalookVis = Visibility.Visible;
  295. }
  296. }
  297. private void CheckEnableNextStepEncrypt()
  298. {
  299. EnableNextStep = true;
  300. if (LoginPassword.Length < 6 || LoginPassword.Length > 24|| (LoginPassword!= LoginPassword2))
  301. {
  302. EnableNextStep = false;
  303. }
  304. if (LoginPassword != LoginPassword2)
  305. {
  306. PasswordUpdatalookVis = Visibility.Visible;
  307. PasswordUpdatamsglook = ErrorCodeHelper.Ercode("320");
  308. }
  309. else
  310. {
  311. PasswordUpdatalookVis = Visibility.Collapsed;
  312. }
  313. }
  314. public void DisplayPassword(object e)
  315. {
  316. var chk = e as CheckBox;
  317. if (chk != null)
  318. {
  319. if (chk.IsChecked == true)
  320. {
  321. LoginPasswordVisibility = Visibility.Collapsed;
  322. }
  323. else
  324. {
  325. LoginPasswordVisibility = Visibility.Visible;
  326. }
  327. }
  328. }
  329. public void DisplayPassword2(object e)
  330. {
  331. var chk = e as CheckBox;
  332. if (chk != null)
  333. {
  334. if (chk.IsChecked == true)
  335. {
  336. LoginPasswordVisibility2 = Visibility.Collapsed;
  337. }
  338. else
  339. {
  340. LoginPasswordVisibility2 = Visibility.Visible;
  341. }
  342. }
  343. }
  344. }
  345. }