PasswordUpdataRegionVIewModel.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  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 _Containspaces = "密码不能包含空格";
  214. public string Containspaces
  215. {
  216. get { return _Containspaces; }
  217. set
  218. {
  219. SetProperty(ref _Containspaces, value);
  220. }
  221. }
  222. private string _Codemax = "";
  223. public string Codemax
  224. {
  225. get { return _Codemax; }
  226. set
  227. {
  228. SetProperty(ref _Codemax, value);
  229. }
  230. }
  231. private string _Codemin = "";
  232. public string Codemin
  233. {
  234. get { return _Codemin; }
  235. set
  236. {
  237. SetProperty(ref _Codemin, value);
  238. }
  239. }
  240. private Visibility _PasswordUpdatalookVis = Visibility.Collapsed;
  241. public Visibility PasswordUpdatalookVis
  242. {
  243. get { return _PasswordUpdatalookVis; }
  244. set { SetProperty(ref _PasswordUpdatalookVis, value); }
  245. }
  246. public DelegateCommand<object> DisplayPasswordCommand { get; set; }
  247. public DelegateCommand<object> DisplayPasswordCommand2 { get; set; }
  248. public DelegateCommand ChangeEmailCommand { get; set; }
  249. public DelegateCommand GoCodeUpdataCommand { get; set; }
  250. public DelegateCommand PasswordUpdataCommand { get; set; }
  251. public DelegateCommand LinkLicenseCommand { get; set; }
  252. public DelegateCommand LoginPasswordChangedCommand { get; set; }
  253. public DelegateCommand LoginPasswordChanged2Command { get; set; }
  254. PasswordUpdataRegionViewModel(IRegionManager regionManager, IDialogService dialogService)
  255. {
  256. dialogs = dialogService;
  257. InitString();
  258. DisplayPasswordCommand = new DelegateCommand<object>(DisplayPassword);
  259. DisplayPasswordCommand2 = new DelegateCommand<object>(DisplayPassword2);
  260. PasswordUpdataCommand = new DelegateCommand(PasswordUpdata);
  261. LoginPasswordChangedCommand = new DelegateCommand(LoginPasswordChanged);
  262. LoginPasswordChanged2Command = new DelegateCommand(LoginPasswordChanged2);
  263. }
  264. private void LoginPasswordChanged()
  265. {
  266. if (LoginPassword.Length < 6 && LoginPassword.Length > 0)
  267. {
  268. LoginPasswordlook = Codemin;
  269. }
  270. else if (LoginPassword.Length > 24)
  271. {
  272. LoginPasswordlook = Codemax;
  273. }
  274. else if (LoginPassword.Contains(" ") == true)
  275. {
  276. LoginPasswordlook = Containspaces;
  277. }
  278. else
  279. {
  280. LoginPasswordlook = "";
  281. }
  282. }
  283. private void LoginPasswordChanged2()
  284. {
  285. if (LoginPassword2.Length < 6 && LoginPassword2.Length > 0)
  286. {
  287. LoginPasswordlook2 = Codemin;
  288. }
  289. else if (LoginPassword2.Length > 24)
  290. {
  291. LoginPasswordlook2 =Codemax;
  292. }
  293. else if (LoginPassword2.Contains(" ") == true)
  294. {
  295. LoginPasswordlook2 = Containspaces;
  296. }
  297. else
  298. {
  299. LoginPasswordlook2 = "";
  300. }
  301. }
  302. private void PasswordUpdata()
  303. {
  304. string code = ServiceHelper.Rebirth(LoginEmail, LoginPassword2, LoginPassword, LoginDialogViewModel.PasswordCode);
  305. if (code == "200")
  306. {
  307. LoginDialogViewModel.RegionMan("LoginRegion");
  308. }
  309. else
  310. {
  311. PasswordUpdatamsglook = ErrorCodeHelper.Ercode(code);
  312. PasswordUpdatalookVis = Visibility.Visible;
  313. }
  314. }
  315. private void CheckEnableNextStepEncrypt()
  316. {
  317. EnableNextStep = true;
  318. if (LoginPassword.Length < 6 || LoginPassword.Length > 24|| (LoginPassword!= LoginPassword2) || LoginPassword.Contains(" ") == true)
  319. {
  320. EnableNextStep = false;
  321. }
  322. if (LoginPassword != LoginPassword2)
  323. {
  324. PasswordUpdatalookVis = Visibility.Visible;
  325. PasswordUpdatamsglook = ErrorCodeHelper.Ercode("320");
  326. }
  327. else
  328. {
  329. PasswordUpdatalookVis = Visibility.Collapsed;
  330. }
  331. }
  332. public void DisplayPassword(object e)
  333. {
  334. var chk = e as CheckBox;
  335. if (chk != null)
  336. {
  337. if (chk.IsChecked == true)
  338. {
  339. LoginPasswordVisibility = Visibility.Collapsed;
  340. }
  341. else
  342. {
  343. LoginPasswordVisibility = Visibility.Visible;
  344. }
  345. }
  346. }
  347. public void DisplayPassword2(object e)
  348. {
  349. var chk = e as CheckBox;
  350. if (chk != null)
  351. {
  352. if (chk.IsChecked == true)
  353. {
  354. LoginPasswordVisibility2 = Visibility.Collapsed;
  355. }
  356. else
  357. {
  358. LoginPasswordVisibility2 = Visibility.Visible;
  359. }
  360. }
  361. }
  362. }
  363. }