123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261 |
- using PDF_Master.CustomControl;
- using PDF_Master.Helper;
- using PDF_Master.Model;
- using PDF_Master.Views.Dialog.ServiceDialog;
- using Prism.Commands;
- using Prism.Mvvm;
- using Prism.Regions;
- using Prism.Services.Dialogs;
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Linq;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Documents;
- using System.Windows.Navigation;
- namespace PDF_Master.ViewModels.Dialog.ServiceDialog
- {
- public class LoginRegionViewModel : BindableBase, INavigationAware
- {
- private LoginDialogViewModel LoginDialogViewModel;
- private ErrorCodeHelper ErrorCodeHelper = new ErrorCodeHelper();
- public IDialogService dialogs;
- public bool IsNavigationTarget(NavigationContext navigationContext)
- {
- return true;
- }
- public void OnNavigatedFrom(NavigationContext navigationContext)
- {
- }
- public void OnNavigatedTo(NavigationContext navigationContext)
- {
- navigationContext.Parameters.TryGetValue<LoginDialogViewModel>("LoginDialogViewModel", out LoginDialogViewModel);
- }
- #region 文案
- private string _Text_Login = "";
- public string Text_Login
- {
- get { return _Text_Login; }
- set
- {
- SetProperty(ref _Text_Login, value);
- }
- }
- private string _Text_emailac = "";
- public string Text_emailac
- {
- get { return _Text_emailac; }
- set
- {
- SetProperty(ref _Text_emailac, value);
- }
- }
- private string _Text_next = "";
- public string Text_next
- {
- get { return _Text_next; }
- set
- {
- SetProperty(ref _Text_next, value);
- }
- }
- private string _Text_noacc = "";
- public string Text_noacc
- {
- get { return _Text_noacc; }
- set
- {
- SetProperty(ref _Text_noacc, value);
- }
- }
- private string _Text_toregister = "";
- public string Text_toregister
- {
- get { return _Text_toregister; }
- set
- {
- SetProperty(ref _Text_toregister, value);
- }
- }
- private string _LoginEmailMsg = "";
- public string LoginEmailMsg
- {
- get { return _LoginEmailMsg; }
- set
- {
- SetProperty(ref _LoginEmailMsg, value);
- }
- }
-
- private string _Mailerr = "";
- public string Mailerr
- {
- get { return _Mailerr; }
- set
- {
- SetProperty(ref _Mailerr, value);
- }
- }
- private void InitString()
- {
- Text_Login = App.ServiceLoader.GetString("Text_Login");
- Text_emailac = App.ServiceLoader.GetString("Text_emailac");
- Text_next = App.ServiceLoader.GetString("RegisterNextStep");
- Text_noacc = App.ServiceLoader.GetString("Text_noacc");
- Text_toregister = App.ServiceLoader.GetString("Text_Signup");
- Mailerr = App.ServiceLoader.GetString("Mailerr");
- LoginEmailMsg = App.ServiceLoader.GetString("RegisterEmailMsg");
- }
- #endregion
- private bool enableNextStep = false;
- public bool EnableNextStep
- {
- get { return enableNextStep; }
- set { SetProperty(ref enableNextStep, value); }
- }
- private string _LoginEmaillook;
- public string LoginEmaillook
- {
- get { return _LoginEmaillook; }
- set { SetProperty(ref _LoginEmaillook, value);}
- }
-
- private string _LoginEmail = "";
- public string LoginEmail
- {
- get { return _LoginEmail; }
- set
- {
- SetProperty(ref _LoginEmail, value);
- if (LoginEmail == "")
- {
- LoginEmaillook = "";
- }
- else
- {
- CheckMail(LoginEmail);
- }
- CheckEnableNextStepEncrypt();
- }
- }
-
-
- public DelegateCommand LoginNextCommand { get; set; }
- public DelegateCommand GoLoginCommand { get; set; }
- LoginRegionViewModel(IRegionManager regionManager, IDialogService dialogService)
- {
- dialogs = dialogService;
-
- LoginNextCommand = new DelegateCommand(LoginNext);
- GoLoginCommand = new DelegateCommand(GoLogin);
- InitString();
- }
- private void LoginNext()
- {
-
-
- if (ServiceHelper.Ok_email(LoginEmail, "1") == "200")
- {
- LoginDialogViewModel.LoginEmail = LoginEmail;
- LoginDialogViewModel.RegionMan("LoginPasswordRegion");
- }
- else if (ServiceHelper.Ok_email(LoginEmail, "1") == "300")
- {
- LoginDialogViewModel.RegionMan("NOInternetRegion");
- }
- else if (ServiceHelper.Ok_email(LoginEmail, "1") == "318")
- {
-
- dialogs.ShowDialog(DialogNames.UserOutingLogin, new DialogParameters(""), r =>
- {
- });
-
- }
- else
- {
- LoginEmaillook = ErrorCodeHelper.Ercode(ServiceHelper.Ok_email(LoginEmail, "1"));
- }
- }
- private void CheckMail(string mail)
- {
- string str = "^([a-z0-9_\\.-]+)@([\\da-z\\.-]+)\\.([a-z\\.]{2,6})$";
- Regex mReg = new Regex(str);
- if (mReg.IsMatch(mail))
- {
- LoginEmaillook = "";
- }
- else
- {
- LoginEmaillook = Mailerr;
- }
- }
- private void GoLogin()
- {
- LoginDialogViewModel.Close();
- App.mainWindowViewModel.OpenRegister();
- }
- private void CheckEnableNextStepEncrypt()
- {
- EnableNextStep = true;
- if (string.IsNullOrEmpty(LoginEmail)||LoginEmaillook!="")
- {
- EnableNextStep = false;
- }
- }
- }
- }
|