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