using System; using System.Collections.Generic; using System.Text; namespace Shared.Phone.UserCenter { /// /// 手势密码验证界面 /// public class PswGestureSecirityForm : DialogCommonForm { #region ■ 变量声明___________________________ #endregion #region ■ 初始化_____________________________ /// /// 画面显示(底层会固定调用此方法,借以完成画面创建) /// /// Touch ID验证的显示文本 /// 密码验证的显示文本 /// 手势验证的显示文本 /// 验证成功后的回调函数,如果不成功,不会调用这个东西 public void ShowForm(string i_TouchText, string i_PasswordText, string i_GestureText, Action SuccessAction) { //初始化中部信息 this.InitMiddleFrame(i_TouchText, i_PasswordText, i_GestureText, SuccessAction); } /// /// 初始化中部信息 /// /// Touch ID验证的显示文本 /// 密码验证的显示文本 /// 手势验证的显示文本 /// 验证成功后的回调函数,如果不成功,不会调用这个东西 private void InitMiddleFrame(string i_TouchText, string i_PasswordText, string i_GestureText, Action SuccessAction) { var frameBack = new FrameLayout(); frameBack.Y = Application.GetRealHeight(239); frameBack.Gravity = Gravity.CenterHorizontal; frameBack.Width = Application.GetRealWidth(965); frameBack.Height = Application.GetRealHeight(1486); frameBack.BackgroundColor = UserCenterColor.Current.White; frameBack.Radius = (uint)Application.GetRealHeight(17); bodyFrameLayout.AddChidren(frameBack); //手势验证控件 var gestureControl = new PswGestureInputControl(i_GestureText); gestureControl.Y = Application.GetRealHeight(69); frameBack.AddChidren(gestureControl); gestureControl.InitControl(); //添加关闭按钮 var btnClose = gestureControl.AddCloseButton(); btnClose.ButtonClickEvent += (sender, e) => { this.CloseForm(); }; gestureControl.FinishInputEvent += (Password, pswLeng) => { if (UserCenterResourse.AccountOption.GestureAuthentication != Password) { UserCenterResourse.AccountOption.PasswordGestureInputCount--; if (UserCenterResourse.AccountOption.PasswordGestureInputCount <= 0) { //管理员身份验证失败,请重新登录 string msg2 = Language.StringByID(R.MyInternationalizationString.uCheckAdministratorFailAndReload); this.ShowMassage(ShowMsgType.Tip, msg2); UserCenterLogic.ReLoginAgain(Common.Config.Instance.Account); return; } //密码错误,请重新输入 gestureControl.SetErrorMsg(Language.StringByID(R.MyInternationalizationString.uOldPsswordIsError)); return; } //重置剩余密码次数 UserCenterResourse.AccountOption.ResetPasswordCount(); //界面关闭 this.CloseForm(); SuccessAction?.Invoke(); SuccessAction = null; }; //Touch ID开锁 var btnTouch = new BottomLeftClickButton(frameBack.Width / 2, Application.GetRealHeight(127)); frameBack.AddChidren(btnTouch); btnTouch.InitControl(i_TouchText); if (UserCenterResourse.AccountOption.FingerprintAuthentication == false) { //没有启用Touch ID btnTouch.CanClick = false; } btnTouch.ButtonClickEvent += (sender, e) => { //二次检测 TouchIDUtils.TouchIDSupperType type = TouchIDUtils.getTouchIDSupperType(); if (type != TouchIDUtils.TouchIDSupperType.TouchID) { return; } //界面关闭 this.CloseForm(); TouchIDUtils.Instance.OnHDLTouchIDStateBackEvent += (sender2, e2) => { if (e2 == TouchIDUtils.TouchIDState.Success) { TouchIDUtils.Instance.OnHDLTouchIDStateBackEvent = null; //TouchID验证成功 SuccessAction?.Invoke(); SuccessAction = null; } else if (e2 == TouchIDUtils.TouchIDState.InputPassword) { TouchIDUtils.Instance.OnHDLTouchIDStateBackEvent = null; //密码验证 if (string.IsNullOrEmpty(UserCenterResourse.AccountOption.PswAuthentication) == false) { var form = new PswSecondarySecurityForm(); this.AddFromAndRemoveNowForm(form, i_TouchText, i_PasswordText, i_GestureText, SuccessAction); } //手势验证 else if (string.IsNullOrEmpty(UserCenterResourse.AccountOption.GestureAuthentication) == false) { var form = new PswGestureSecirityForm(); this.AddFromAndRemoveNowForm(form, i_TouchText, i_PasswordText, i_GestureText, SuccessAction); } else { //没有设置密码验证 this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.uPasswordAuthenticationNotSettion)); } } }; TouchIDUtils.Instance.showTouchIDWithDescribe(null, null); }; //密码开锁 var btnPsw = new BottomRightClickButton(frameBack.Width - btnTouch.Width, btnTouch.Height); frameBack.AddChidren(btnPsw); btnPsw.InitControl(i_PasswordText); if (string.IsNullOrEmpty(UserCenterResourse.AccountOption.PswAuthentication) == true) { //没有启用密码开锁 btnPsw.CanClick = false; } btnPsw.ButtonClickEvent += (sender, e) => { var form = new PswSecondarySecurityForm(); this.AddFromAndRemoveNowForm(form, i_TouchText, i_PasswordText, i_GestureText, SuccessAction); }; } #endregion #region ■ 界面关闭___________________________ public override void CloseFormBefore() { //取消事件 TouchIDUtils.Instance.OnHDLTouchIDStateBackEvent = null; base.CloseFormBefore(); } #endregion } }