New file |
| | |
| | | using System;
|
| | | using System.Collections.Generic;
|
| | | using System.Text;
|
| | |
|
| | | namespace Shared.Phone.UserCenter.Password
|
| | | {
|
| | | /// <summary>
|
| | | /// 编辑二次验证的手势验证界面
|
| | | /// </summary>
|
| | | public class EditorGesturePasswordForm : EditorCommonForm
|
| | | {
|
| | | #region ■ 变量声明___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 当前界面模式
|
| | | /// </summary>
|
| | | private FormMode formMode = FormMode.A新建密码;
|
| | | /// <summary>
|
| | | /// 第一次密码
|
| | | /// </summary>
|
| | | private string firstPssword = string.Empty;
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 初始化_____________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 画面显示(底层会固定调用此方法,借以完成画面创建)
|
| | | /// </summary>
|
| | | public void ShowForm()
|
| | | {
|
| | | //界面右划不可
|
| | | this.ScrollEnabled = false;
|
| | |
|
| | | //设置头部信息
|
| | | base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uGestureAuthentication));
|
| | |
|
| | | if (string.IsNullOrEmpty(UserCenterResourse.AccountOption.GestureAuthentication) == false)
|
| | | {
|
| | | formMode = FormMode.A验证前回密码;
|
| | | }
|
| | |
|
| | | //初始化中部信息
|
| | | this.InitMiddleFrame();
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 初始化中部信息
|
| | | /// </summary>
|
| | | private void InitMiddleFrame()
|
| | | {
|
| | | //清空bodyFrame
|
| | | this.ClearBodyFrame();
|
| | |
|
| | | string titleText = string.Empty;
|
| | | if (formMode == FormMode.A新建密码)
|
| | | {
|
| | | //请输入新手势
|
| | | titleText = Language.StringByID(R.MyInternationalizationString.uPleaseInputNewGesture);
|
| | | }
|
| | | else if (formMode == FormMode.A验证前回密码)
|
| | | {
|
| | | //请输入手势
|
| | | titleText = Language.StringByID(R.MyInternationalizationString.uPleaseInputGesture);
|
| | | }
|
| | | else if (formMode == FormMode.A确认新建密码
|
| | | || formMode == FormMode.A确认修改密码)
|
| | | {
|
| | | //请再次输入手势
|
| | | titleText = Language.StringByID(R.MyInternationalizationString.uPleaseConfirmPswAgain);
|
| | | }
|
| | | else if (formMode == FormMode.A修改密码)
|
| | | {
|
| | | //更改手势,请输入手势
|
| | | titleText = Language.StringByID(R.MyInternationalizationString.uEditorGesturePleaseInputNewGesture);
|
| | | }
|
| | |
|
| | | //手势控件
|
| | | var pswControl = new PswGestureInputControl(titleText);
|
| | | pswControl.Y = Application.GetRealHeight(173);
|
| | | pswControl.Gravity = Gravity.CenterHorizontal;
|
| | | bodyFrameLayout.AddChidren(pswControl);
|
| | | pswControl.InitControl();
|
| | | pswControl.FinishInputEvent += (password, pswleng) =>
|
| | | {
|
| | | //校验密码
|
| | | this.DoAdjustPssword(password, pswleng, pswControl);
|
| | | };
|
| | |
|
| | | if (formMode == FormMode.A验证前回密码)
|
| | | {
|
| | | //忘记手势?
|
| | | var btnForgotPsw = new NormalViewControl(bodyFrameLayout.Width, Application.GetRealHeight(49), false);
|
| | | btnForgotPsw.Y = Application.GetRealHeight(1492);
|
| | | btnForgotPsw.TextSize = 12;
|
| | | btnForgotPsw.TextColor = UserCenterColor.Current.TextOrangeColor;
|
| | | btnForgotPsw.TextID = R.MyInternationalizationString.ForgotPasswordMsg;
|
| | | btnForgotPsw.TextAlignment = TextAlignment.Center;
|
| | | bodyFrameLayout.AddChidren(btnForgotPsw);
|
| | | btnForgotPsw.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | var form = new ForgotSecondaryPasswordForm();
|
| | | form.AddForm();
|
| | | };
|
| | | //底线
|
| | | int lineWidth = btnForgotPsw.GetRealWidthByText();
|
| | | var btnLine = new NormalViewControl(lineWidth, ControlCommonResourse.BottomLineHeight, false);
|
| | | btnLine.BackgroundColor = UserCenterColor.Current.TextOrangeColor;
|
| | | btnLine.Gravity = Gravity.CenterHorizontal;
|
| | | btnLine.Y = btnForgotPsw.Bottom - Application.GetRealHeight(8);
|
| | | bodyFrameLayout.AddChidren(btnLine);
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 校验密码___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 校验密码
|
| | | /// </summary>
|
| | | /// <param name="i_Psw"></param>
|
| | | /// <param name="pswLength"></param>
|
| | | /// <param name="pswControl"></param>
|
| | | private void DoAdjustPssword(string i_Psw, int pswLength, PswGestureInputControl pswControl)
|
| | | {
|
| | | if (formMode == FormMode.A新建密码)
|
| | | {
|
| | | if (pswLength <= 4)
|
| | | {
|
| | | //手势密码长度必须大于4
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uGesturePswLenthError).Replace("{0}", "4");
|
| | | pswControl.SetErrorMsg(msg);
|
| | | return;
|
| | | }
|
| | | //输入二次密码
|
| | | this.firstPssword = i_Psw;
|
| | | formMode = FormMode.A确认新建密码;
|
| | | this.InitMiddleFrame();
|
| | | }
|
| | | else if (formMode == FormMode.A确认新建密码)
|
| | | {
|
| | | if (this.firstPssword != i_Psw)
|
| | | {
|
| | | //确认手势错误,请重新设置
|
| | | pswControl.SetErrorMsg(Language.StringByID(R.MyInternationalizationString.uGestureNotEqual));
|
| | | return;
|
| | | }
|
| | | //保存密码
|
| | | this.SaveSecondaryPassword(pswControl, i_Psw);
|
| | | }
|
| | | else if (formMode == FormMode.A验证前回密码)
|
| | | {
|
| | | if (UserCenterResourse.AccountOption.GestureAuthentication != i_Psw)
|
| | | {
|
| | | 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;
|
| | | }
|
| | | //手势错误,请重新输入
|
| | | pswControl.SetErrorMsg(Language.StringByID(R.MyInternationalizationString.uOldGestureIsError));
|
| | | return;
|
| | | }
|
| | | //重置剩余密码次数
|
| | | UserCenterResourse.AccountOption.ResetPasswordCount();
|
| | |
|
| | | formMode = FormMode.A修改密码;
|
| | | this.InitMiddleFrame();
|
| | | }
|
| | | else if (formMode == FormMode.A修改密码)
|
| | | {
|
| | | if (i_Psw == UserCenterResourse.AccountOption.GestureAuthentication)
|
| | | {
|
| | | //新密码和原密码一致,请重新输入
|
| | | pswControl.SetErrorMsg(Language.StringByID(R.MyInternationalizationString.uNewPswAndOldPswIsEqual));
|
| | | return;
|
| | | }
|
| | | if (pswLength <= 4)
|
| | | {
|
| | | //手势密码长度必须大于4
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uGesturePswLenthError).Replace("{0}", "4");
|
| | | pswControl.SetErrorMsg(msg);
|
| | | return;
|
| | | }
|
| | | //输入二次密码
|
| | | this.firstPssword = i_Psw;
|
| | | formMode = FormMode.A确认修改密码;
|
| | | this.InitMiddleFrame();
|
| | | }
|
| | | else if (formMode == FormMode.A确认修改密码)
|
| | | {
|
| | | if (this.firstPssword != i_Psw)
|
| | | {
|
| | | //确认手势错误,请重新设置
|
| | | pswControl.SetErrorMsg(Language.StringByID(R.MyInternationalizationString.uGestureNotEqual));
|
| | | return;
|
| | | }
|
| | | //保存密码
|
| | | this.SaveSecondaryPassword(pswControl, i_Psw);
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 外部指定模式_______________________
|
| | |
|
| | | /// <summary>
|
| | | /// 强制指定新密码模式(由外部调用)
|
| | | /// </summary>
|
| | | public void SetNewPasswordFormMode()
|
| | | {
|
| | | formMode = FormMode.A新建密码;
|
| | | this.InitMiddleFrame();
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 保存密码___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 保存密码
|
| | | /// </summary>
|
| | | /// <param name="contr">控件</param>
|
| | | /// <param name="psw">密码</param>
|
| | | private void SaveSecondaryPassword(PswGestureInputControl contr, string psw)
|
| | | {
|
| | | HdlThreadLogic.Current.RunThread(async () =>
|
| | | {
|
| | | //打开进度条
|
| | | this.ShowProgressBar();
|
| | | var pra = new
|
| | | {
|
| | | RequestVersion = Common.CommonPage.RequestVersion,
|
| | | LoginAccessToken = Common.Config.Instance.Token,
|
| | | GesturePwd = psw,
|
| | | StringPwd = UserCenterResourse.AccountOption.PswAuthentication
|
| | | };
|
| | | var result = await UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/UpdatEexpandPwd", false, pra);
|
| | | //关闭进度条
|
| | | this.CloseProgressBar();
|
| | |
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | if (result == false)
|
| | | {
|
| | | contr.SetErrorMsg(string.Empty);
|
| | | }
|
| | | else
|
| | | {
|
| | | UserCenterResourse.AccountOption.GestureAuthentication = psw;
|
| | | UserCenterResourse.AccountOption.Save();
|
| | | //界面关闭
|
| | | this.CloseForm();
|
| | | }
|
| | | });
|
| | | });
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 结构体_____________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 界面模式
|
| | | /// </summary>
|
| | | private enum FormMode
|
| | | {
|
| | | A新建密码 = 1,
|
| | | A确认新建密码 = 2,
|
| | | A验证前回密码 = 3,
|
| | | A修改密码 = 4,
|
| | | A确认修改密码 = 5
|
| | | }
|
| | |
|
| | | #endregion
|
| | | }
|
| | | }
|