123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286 |
- using PDF_Office.CustomControl;
- using PDF_Office.Helper;
- using PDF_Office.Model;
- using PDF_Office.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.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Documents;
- using System.Windows.Navigation;
- namespace PDF_Office.ViewModels.Dialog.ServiceDialog
- {
- public class LoginPasswordRegionViewModel : BindableBase, INavigationAware
- {
- private static Guid myuuid = Guid.NewGuid();
- private string uuid = myuuid.ToString();
- private LoginDialogViewModel LoginDialogViewModel;
- 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);
- LoginEmail = LoginDialogViewModel.LoginEmail;
- }
- private bool enableNextStep = false;
- public bool EnableNextStep
- {
- get { return enableNextStep; }
- set { SetProperty(ref enableNextStep, value); }
- }
- private string _LoginEmail = "";
- public string LoginEmail
- {
- get { return _LoginEmail; }
- set
- {
- SetProperty(ref _LoginEmail, value);
- }
- }
- private string _LoginPasswordlook;
- public string LoginPasswordlook
- {
- get { return _LoginPasswordlook; }
- set { SetProperty(ref _LoginPasswordlook, value); }
- }
-
- private string _LoginPassword = "";
- public string LoginPassword
- {
- get { return _LoginPassword; }
- set
- {
- SetProperty(ref _LoginPassword, value);
- LoginPasswordmsglook = "";
- LoginPasswordlookVis = Visibility.Collapsed;
- if (string.IsNullOrEmpty(LoginPassword))
- {
- ChkVis = Visibility.Collapsed;
- }
- else
- {
- ChkVis = Visibility.Visible;
- }
- CheckEnableNextStepEncrypt();
- }
- }
-
- private string _LoginPasswordMsg = "Enter your password";
- public string LoginPasswordMsg
- {
- get { return _LoginPasswordMsg; }
- set
- {
- SetProperty(ref _LoginPasswordMsg, value);
- }
- }
- private string _LoginPasswordmsglook = "";
- public string LoginPasswordmsglook
- {
- get { return _LoginPasswordmsglook; }
- set
- {
- SetProperty(ref _LoginPasswordmsglook, value);
- }
- }
- private Visibility _LoginPasswordVisibility = Visibility.Visible;
- public Visibility LoginPasswordVisibility
- {
- get { return _LoginPasswordVisibility; }
- set
- {
- if (value == Visibility.Visible)
- {
- LoginTextVisibility = Visibility.Collapsed;
- }
- else
- {
- LoginTextVisibility = Visibility.Visible;
- }
- SetProperty(ref _LoginPasswordVisibility, value);
- }
- }
- private Visibility _ChkVis = Visibility.Collapsed;
- public Visibility ChkVis
- {
- get { return _ChkVis; }
- set { SetProperty(ref _ChkVis, value); }
- }
- private Visibility _LoginTextVisibility = Visibility.Collapsed;
- public Visibility LoginTextVisibility
- {
- get { return _LoginTextVisibility; }
- set { SetProperty(ref _LoginTextVisibility, value); }
- }
- private Visibility _LoginPasswordlookVis = Visibility.Collapsed;
- public Visibility LoginPasswordlookVis
- {
- get { return _LoginPasswordlookVis; }
- set { SetProperty(ref _LoginPasswordlookVis, value); }
- }
-
- public DelegateCommand<object> DisplayPasswordCommand { get; set; }
- public DelegateCommand ChangeEmailCommand { get; set; }
- public DelegateCommand GoCodeUpdataCommand { get; set; }
- public DelegateCommand LoginCommand { get; set; }
- public DelegateCommand LinkLicenseCommand { get; set; }
- public DelegateCommand LoginPasswordChangedCommand { get; set; }
- LoginPasswordRegionViewModel(IRegionManager regionManager, IDialogService dialogService)
- {
- dialogs = dialogService;
-
- DisplayPasswordCommand = new DelegateCommand<object>(DisplayPassword);
- LoginCommand = new DelegateCommand(Login);
- ChangeEmailCommand = new DelegateCommand(ChangeEmail);
- GoCodeUpdataCommand = new DelegateCommand(GoCodeUpdata);
- LoginPasswordChangedCommand = new DelegateCommand(LoginPasswordChanged);
- }
- //密码改变
- private void LoginPasswordChanged()
- {
- if (LoginPassword.Length < 6)
- {
- LoginPasswordlook = "At least 6 characters";
- }
- else if (LoginPassword.Length > 24)
- {
- LoginPasswordlook = "Up to 24 characters";
- }
- else
- {
- LoginPasswordlook = "";
- }
- }
- //获取忘记密码验证码
- private void GoCodeUpdata()
- {
- ServiceHelper.Get_code("user_reset_password", LoginEmail);
- LoginDialogViewModel.IsReset = true;
- LoginDialogViewModel.RegionMan("CodeRegion");
-
-
- }
-
- //登录
- private void Login()
- {
-
-
- if (ServiceHelper.Login(LoginEmail, LoginPassword, uuid) == "success")
- {
- LoginDialogViewModel.Close();
- App.mainWindowViewModel.UserVis = Visibility.Visible;
- App.mainWindowViewModel.RegisterVis = Visibility.Collapsed;
- App.mainWindowViewModel.LoginVis = Visibility.Collapsed;
- App.mainWindowViewModel.OphVis = Visibility.Collapsed;
- }
- else if(ServiceHelper.Login(LoginEmail, LoginPassword, uuid) == "网络不稳定请重试")
- {
- LoginDialogViewModel.RegionMan("NOInternetRegion");
- }
-
- else
- {
- LoginPasswordmsglook = ServiceHelper.Login(LoginEmail, LoginPassword, uuid);
- LoginPasswordlookVis = Visibility.Visible;
- }
- }
- private void ChangeEmail()
- {
- LoginDialogViewModel.RegionMan("LoginRegion");
- }
-
- private void CheckEnableNextStepEncrypt()
- {
- EnableNextStep = true;
- if (LoginPassword.Length < 6 || LoginPassword.Length > 24 )
- {
- EnableNextStep = false;
- }
- }
- public void DisplayPassword(object e)
- {
- var chk = e as CheckBox;
- if (chk != null)
- {
- if (chk.IsChecked == true)
- {
- LoginPasswordVisibility = Visibility.Collapsed;
- }
- else
- {
- LoginPasswordVisibility = Visibility.Visible;
- }
- }
- }
- }
- }
|