123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367 |
- using PDF_Master.CustomControl;
- using PDF_Master.Helper;
- using PDF_Master.Model;
- using PDF_Master.Properties;
- 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 string _Text_remsg = "";
- public string Text_remsg
- {
- get { return _Text_remsg; }
- set
- {
- SetProperty(ref _Text_remsg, value);
- }
- }
- private string _Text_privary = "";
- public string Text_privary
- {
- get { return _Text_privary; }
- set
- {
- SetProperty(ref _Text_privary, value);
- }
- }
- private string _Text_and = "";
- public string Text_and
- {
- get { return _Text_and; }
- set
- {
- SetProperty(ref _Text_and, value);
- }
- }
- private string _Text_licens = "";
- public string Text_licens
- {
- get { return _Text_licens; }
- set
- {
- SetProperty(ref _Text_licens, 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");
- Text_remsg = App.ServiceLoader.GetString("Text_remsg");
- Text_privary = App.ServiceLoader.GetString("Text_privary");
- Text_and = App.ServiceLoader.GetString("Text_and");
- Text_licens = App.ServiceLoader.GetString("Text_licens");
- }
- #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 = Settings.Default.UserDate.Email;
- public string LoginEmail
- {
- get { return _LoginEmail; }
- set
- {
- SetProperty(ref _LoginEmail, value);
- LoginEmaillook = "";
- //if (LoginEmail == "")
- //{
- // LoginEmaillook = "";
- //}
- //else
- //{
- // CheckMail(LoginEmail);
- //}
- CheckEnableNextStepEncrypt();
- }
- }
- private string _uriPolivy = "https://www.pdfreaderpro.com/privacy-policy";
- public string UriPolivy
- {
- get { return _uriPolivy; }
- set
- {
- SetProperty(ref _uriPolivy, value);
- }
- }
- private string _uriLicense = "https://www.pdfreaderpro.com/terms_of_service";
- public string UriLicense
- {
- get { return _uriLicense; }
- set
- {
- SetProperty(ref _uriLicense, value);
- }
- }
- public DelegateCommand LoginNextCommand { get; set; }
- public DelegateCommand GoLoginCommand { get; set; }
- public DelegateCommand LinkPolicyCommand { get; set; }
- public DelegateCommand LinkLicenseCommand { get; set; }
- LoginRegionViewModel(IRegionManager regionManager, IDialogService dialogService)
- {
- dialogs = dialogService;
- LinkPolicyCommand = new DelegateCommand(LinkPolicy);
- LinkLicenseCommand = new DelegateCommand(LinkLicense);
- LoginNextCommand = new DelegateCommand(LoginNext);
- GoLoginCommand = new DelegateCommand(GoLogin);
- InitString();
- CheckEnableNextStepEncrypt();
- }
- private void LoginNext()
- {
- //去掉前后空格
- LoginEmail = LoginEmail.Trim();
- if (CheckMail(LoginEmail)==true)
- {
- string code = ServiceHelper.Ok_email(LoginEmail, "1");
- if (code == "200")
- {
- LoginDialogViewModel.LoginEmail = LoginEmail;
- LoginDialogViewModel.RegionMan("LoginPasswordRegion");
- }
- else if (code == "318")
- {
- dialogs.ShowDialog(DialogNames.UserOutingLogin, new DialogParameters(""), r =>
- {
- });
- }
- else
- {
- LoginEmaillook = ErrorCodeHelper.Ercode(code);
- }
- }
-
- }
- private void LinkPolicy()
- {
- Process.Start(new ProcessStartInfo(UriPolivy));
- }
- private void LinkLicense()
- {
- Process.Start(new ProcessStartInfo(UriLicense));
- }
- private bool CheckMail(string mail)
- {
- string str = "^([a-z0-9_\\.-]+)@([\\da-z\\.-]+)\\.([a-z\\.]{2,6})$";
- Regex mReg = new Regex(str);
- if (mReg.IsMatch(mail))
- {
- LoginEmaillook = "";
- return true;
- }
- else
- {
- LoginEmaillook = Mailerr;
- return false;
- }
- }
- private void GoLogin()
- {
- LoginDialogViewModel.Close();
- Settings.Default.UserDate.TodayRegister = true;
- DateTime currentTime = DateTime.Now;
- Settings.Default.UserDate.TodayRegisterTime = currentTime.ToString();
- //此处异步处理,减少等待时间
- DefaultSave();
- App.mainWindowViewModel.OpenRegister();
- }
- private async void DefaultSave()
- {
- await Task.Run(() => { Settings.Default.Save(); });
- }
- private void CheckEnableNextStepEncrypt()
- {
- EnableNextStep = true;
- if (string.IsNullOrEmpty(LoginEmail) || LoginEmaillook != "")
- {
- EnableNextStep = false;
- }
-
- }
- }
- }
|