New file |
| | |
| | | using System;
|
| | | using System.Collections.Generic;
|
| | | using System.Text;
|
| | |
|
| | | namespace Shared.Phone.UserCenter.Password
|
| | | {
|
| | | /// <summary>
|
| | | /// 编辑二次验证的密码验证界面
|
| | | /// </summary>
|
| | | public class EditorSecondaryPasswordForm : EditorCommonForm
|
| | | {
|
| | | #region ■ 变量声明___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 当前界面模式
|
| | | /// </summary>
|
| | | private FormMode formMode = FormMode.A新建密码;
|
| | | /// <summary>
|
| | | /// 第一次密码
|
| | | /// </summary>
|
| | | private string firstPssword = string.Empty;
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 初始化_____________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 画面显示(底层会固定调用此方法,借以完成画面创建)
|
| | | /// </summary>
|
| | | public void ShowForm()
|
| | | {
|
| | | //设置头部信息
|
| | | base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uPasswordAuthentication));
|
| | |
|
| | | if (string.IsNullOrEmpty(UserCenterResourse.AccountOption.PswAuthentication) == false)
|
| | | {
|
| | | formMode = FormMode.A验证前回密码;
|
| | | }
|
| | |
|
| | | //初始化中部信息
|
| | | this.InitMiddleFrame();
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 初始化中部信息
|
| | | /// </summary>
|
| | | private void InitMiddleFrame()
|
| | | {
|
| | | //清空bodyFrame
|
| | | this.ClearBodyFrame();
|
| | |
|
| | | string title = string.Empty;
|
| | | if (formMode == FormMode.A新建密码)
|
| | | {
|
| | | //请输入新密码
|
| | | title = Language.StringByID(R.MyInternationalizationString.uPleaseInputNewPassword);
|
| | | }
|
| | | else if (formMode == FormMode.A验证前回密码)
|
| | | {
|
| | | //请输入密码
|
| | | title = Language.StringByID(R.MyInternationalizationString.uPleaseInputPsw);
|
| | | }
|
| | | else if (formMode == FormMode.A确认新建密码
|
| | | || formMode == FormMode.A确认修改密码)
|
| | | {
|
| | | //请再次确认密码
|
| | | title = Language.StringByID(R.MyInternationalizationString.uPleaseConfirmPswAgain);
|
| | | }
|
| | | else if (formMode == FormMode.A修改密码)
|
| | | {
|
| | | //修改密码,请输入新密码
|
| | | title = Language.StringByID(R.MyInternationalizationString.uEditorPswPleaseInputNewPsw);
|
| | | }
|
| | |
|
| | | //密码控件
|
| | | var pswControl = new PswNumberInputControl(title);
|
| | | //变更数字表盘背景色
|
| | | pswControl.NumberIconBackColor = UserCenterColor.Current.White;
|
| | | pswControl.Y = Application.GetRealHeight(104);
|
| | | pswControl.Gravity = Gravity.CenterHorizontal;
|
| | | bodyFrameLayout.AddChidren(pswControl);
|
| | | pswControl.InitControl();
|
| | | pswControl.FinishInputEvent += (password) =>
|
| | | {
|
| | | //校验密码
|
| | | this.DoAdjustPssword(password, 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="pswControl"></param>
|
| | | private void DoAdjustPssword(string i_Psw, PswNumberInputControl pswControl)
|
| | | {
|
| | | if (formMode == FormMode.A新建密码)
|
| | | {
|
| | | //输入二次密码
|
| | | 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.SecondPswNotEqual2));
|
| | | return;
|
| | | }
|
| | | //保存密码
|
| | | this.SaveSecondaryPassword(pswControl, i_Psw);
|
| | | }
|
| | | else if (formMode == FormMode.A验证前回密码)
|
| | | {
|
| | | if (UserCenterResourse.AccountOption.PswAuthentication != i_Psw)
|
| | | {
|
| | | UserCenterResourse.AccountOption.PasswordInputCount--;
|
| | | if (UserCenterResourse.AccountOption.PasswordInputCount <= 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.uOldPsswordIsError));
|
| | | return;
|
| | | }
|
| | | //重置剩余密码次数
|
| | | UserCenterResourse.AccountOption.ResetPasswordCount();
|
| | |
|
| | | formMode = FormMode.A修改密码;
|
| | | this.InitMiddleFrame();
|
| | | }
|
| | | else if (formMode == FormMode.A修改密码)
|
| | | {
|
| | | if (i_Psw == UserCenterResourse.AccountOption.PswAuthentication)
|
| | | {
|
| | | //新密码和原密码一致,请重新输入
|
| | | pswControl.SetErrorMsg(Language.StringByID(R.MyInternationalizationString.uNewPswAndOldPswIsEqual));
|
| | | 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.SecondPswNotEqual2));
|
| | | 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(PswNumberInputControl contr, string psw)
|
| | | {
|
| | | HdlThreadLogic.Current.RunThread(async () =>
|
| | | {
|
| | | //打开进度条
|
| | | this.ShowProgressBar();
|
| | | var pra = new
|
| | | {
|
| | | RequestVersion = Common.CommonPage.RequestVersion,
|
| | | LoginAccessToken = Common.Config.Instance.Token,
|
| | | GesturePwd = UserCenterResourse.AccountOption.GestureAuthentication,
|
| | | StringPwd = psw
|
| | | };
|
| | | var result = await UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/UpdatEexpandPwd", false, pra);
|
| | | //关闭进度条
|
| | | this.CloseProgressBar();
|
| | |
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | if (result == false)
|
| | | {
|
| | | contr.SetErrorMsg(string.Empty);
|
| | | }
|
| | | else
|
| | | {
|
| | | UserCenterResourse.AccountOption.PswAuthentication = psw;
|
| | | UserCenterResourse.AccountOption.Save();
|
| | | //界面关闭
|
| | | this.CloseForm();
|
| | | }
|
| | | });
|
| | | });
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 结构体_____________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 界面模式
|
| | | /// </summary>
|
| | | private enum FormMode
|
| | | {
|
| | | A新建密码 = 1,
|
| | | A确认新建密码 = 2,
|
| | | A验证前回密码 = 3,
|
| | | A修改密码 = 4,
|
| | | A确认修改密码 = 5
|
| | | }
|
| | |
|
| | | #endregion
|
| | | }
|
| | | }
|