New file |
| | |
| | | using System;
|
| | | using System.Collections.Generic;
|
| | | using System.Text;
|
| | |
|
| | | namespace Shared.Phone.UserCenter.Safety
|
| | | {
|
| | | /// <summary>
|
| | | /// 新建用户密码的画面
|
| | | /// </summary>
|
| | | public class PasswordAddNewForm : EditorCommonForm
|
| | | {
|
| | | #region ■ 变量声明___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 密码改变事件
|
| | | /// </summary>
|
| | | public Action<string> PasswordChangedEvent = null;
|
| | | /// <summary>
|
| | | /// 用户账号
|
| | | /// </summary>
|
| | | private int pswNo = 0;
|
| | | /// <summary>
|
| | | /// 第一个密码
|
| | | /// </summary>
|
| | | private string firstPsw = string.Empty;
|
| | | /// <summary>
|
| | | /// 密码输入控件
|
| | | /// </summary>
|
| | | private PswNumberInputControl pswControl = null;
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 初始化_____________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 画面显示(底层会固定调用此方法,借以完成画面创建)
|
| | | /// </summary>
|
| | | /// <param name="i_pswNo">用户账号</param>
|
| | | /// <param name="i_titleText">头部标题信息</param>
|
| | | public void ShowForm(int i_pswNo, string i_titleText)
|
| | | {
|
| | | this.pswNo = i_pswNo;
|
| | | //设置头部信息
|
| | | base.SetTitleText(i_titleText);
|
| | |
|
| | | //初始化中部信息
|
| | | this.InitMiddleFrame(i_titleText);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 初始化中部信息
|
| | | /// </summary>
|
| | | /// <param name="i_titleText">头部标题信息</param>
|
| | | private void InitMiddleFrame(string i_titleText)
|
| | | {
|
| | | //清空bodyFrame
|
| | | this.ClearBodyFrame();
|
| | |
|
| | | //请输入新安防密码
|
| | | pswControl = new PswNumberInputControl(Language.StringByID(R.MyInternationalizationString.uPleaseInputNewSafetyPassword), 4);
|
| | | pswControl.NumberIconBackColor = UserCenterColor.Current.White;
|
| | | pswControl.Gravity = Gravity.CenterHorizontal;
|
| | | pswControl.Y = Application.GetRealHeight(102);
|
| | | bodyFrameLayout.AddChidren(pswControl);
|
| | | pswControl.InitControl();
|
| | |
|
| | | pswControl.FinishInputEvent += (pssword) =>
|
| | | {
|
| | | if (firstPsw != string.Empty)
|
| | | {
|
| | | //检测密码
|
| | | string msg = this.CheckPassword(firstPsw, pssword);
|
| | | if (msg != string.Empty)
|
| | | {
|
| | | //设置错误信息
|
| | | pswControl.SetErrorMsg(msg);
|
| | | return;
|
| | | }
|
| | | //执行修改用户密码
|
| | | this.ChangedAdminPassword(firstPsw, i_titleText);
|
| | | }
|
| | | else
|
| | | {
|
| | | firstPsw = pssword;
|
| | | //请重复输入新安防密码
|
| | | pswControl.ResetControlInfo(Language.StringByID(R.MyInternationalizationString.uPleaseRepeatInputNewSafetyPassword));
|
| | | }
|
| | | };
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 修改密码___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 执行修改用户密码
|
| | | /// </summary>
|
| | | /// <param name="pswValue1">新密码</param>
|
| | | private async void ChangedAdminPassword(string pswValue1, string i_titleText)
|
| | | {
|
| | | //执行修改
|
| | | bool result = await HdlSafeguardLogic.Current.ChangedUserPassword(this.pswNo, pswValue1, string.Empty);
|
| | | if (result == false)
|
| | | {
|
| | | firstPsw = string.Empty;
|
| | | //请输入新安防密码
|
| | | pswControl.ResetControlInfo(Language.StringByID(R.MyInternationalizationString.uPleaseInputNewSafetyPassword));
|
| | |
|
| | | return;
|
| | | }
|
| | |
|
| | | //安防密码设置成功
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uSetSafetyPasswordSuccess);
|
| | | this.ShowMassage(ShowMsgType.Tip, msg);
|
| | |
|
| | | //界面直接关闭
|
| | | this.CloseForm();
|
| | |
|
| | | if (UserCenterResourse.DicActionForm.ContainsKey("PasswordUserEditorForm") == false)
|
| | | {
|
| | | var form = new PasswordUserEditorForm();
|
| | | form.AddForm(this.pswNo, pswValue1, i_titleText);
|
| | | }
|
| | | else
|
| | | {
|
| | | //回调函数
|
| | | this.PasswordChangedEvent?.Invoke(pswValue1);
|
| | | this.PasswordChangedEvent = null;
|
| | |
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 一般方法___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 密码检查,返回错误信息,无错误信息(空字符串)则表示成功
|
| | | /// </summary>
|
| | | /// <param name="pswValue1"></param>
|
| | | /// <param name="pswValue2"></param>
|
| | | /// <returns></returns>
|
| | | private string CheckPassword(string pswValue1, string pswValue2)
|
| | | {
|
| | | if (pswValue1 == string.Empty)
|
| | | {
|
| | | //请输入新密码
|
| | | return Language.StringByID(R.MyInternationalizationString.uPleaseInputNewPassword);
|
| | | }
|
| | | if (pswValue2 == string.Empty)
|
| | | {
|
| | | //请输入确认密码
|
| | | return Language.StringByID(R.MyInternationalizationString.PleaseInputConfirmPsw);
|
| | | }
|
| | | if (pswValue1 != pswValue2)
|
| | | {
|
| | | //两次输入的密码不一致
|
| | | return Language.StringByID(R.MyInternationalizationString.SecondPswNotEqual1);
|
| | | }
|
| | | return string.Empty;
|
| | | }
|
| | | #endregion
|
| | | }
|
| | | }
|