using System; using System.Collections.Generic; using System.Text; namespace Shared.Phone.UserCenter.Password { /// /// 重置账号密码的界面 /// public class ResetAccountPasswordForm : EditorCommonForm { #region ■ 变量声明___________________________ #endregion #region ■ 初始化_____________________________ /// /// 画面显示(底层会固定调用此方法,借以完成画面创建) /// public void ShowForm() { //设置头部信息 base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uResetPassword)); //初始化中部信息 this.InitMiddleFrame(); } /// /// 初始化中部信息 /// private void InitMiddleFrame() { //清空bodyFrame this.ClearBodyFrame(); var frameRow1 = new FrameLayout(); frameRow1.Height = Application.GetRealHeight(23) + ControlCommonResourse.ListViewRowHeight; frameRow1.BackgroundColor = UserCenterColor.Current.White; bodyFrameLayout.AddChidren(frameRow1); //请输入新密码 var rowNewPsw = new FrameRowControl(Application.GetRealHeight(5) / 2); //关闭状态提示 rowNewPsw.UseClickStatu = false; rowNewPsw.Y = Application.GetRealHeight(23); frameRow1.AddChidren(rowNewPsw); var txtNewPsw = rowNewPsw.AddLeftInput("", 800); txtNewPsw.SecureTextEntry = true; txtNewPsw.PlaceholderText = Language.StringByID(R.MyInternationalizationString.uPleaseInputNewPassword); //底线 rowNewPsw.AddBottomLine(); //图标 var btnNewPswIcon = rowNewPsw.AddMostRightEmptyIcon(58, 58); btnNewPswIcon.UnSelectedImagePath = "Item/HidenPWD.png"; btnNewPswIcon.SelectedImagePath = "Item/UnHidenPWD.png"; btnNewPswIcon.ButtonClickEvent += (sender, e) => { btnNewPswIcon.IsSelected = !btnNewPswIcon.IsSelected; txtNewPsw.SecureTextEntry = !txtNewPsw.SecureTextEntry; }; //Row1的错误信息 var btnErrorRow1 = new NormalViewControl(800, 58, true); btnErrorRow1.X = ControlCommonResourse.XXLeft; btnErrorRow1.Y = rowNewPsw.Bottom + Application.GetRealHeight(29); btnErrorRow1.TextColor = 0xfff75858; frameRow1.AddChidren(btnErrorRow1); var frameRow2 = new FrameLayout(); frameRow2.Y = frameRow1.Bottom; frameRow2.Height = Application.GetRealHeight(150) + ControlCommonResourse.ListViewRowHeight; bodyFrameLayout.AddChidren(frameRow2); var frameTemp = new FrameLayout(); frameTemp.Height = Application.GetRealHeight(161); frameTemp.BackgroundColor = UserCenterColor.Current.White; frameRow2.AddChidren(frameTemp); //请重复输入新密码 var rowConfirmPsw = new FrameRowControl(Application.GetRealHeight(5) / 2); //关闭状态提示 rowConfirmPsw.UseClickStatu = false; rowConfirmPsw.Y = Application.GetRealHeight(10); frameTemp.AddChidren(rowConfirmPsw); var txtConfirmPsw = rowConfirmPsw.AddLeftInput("", 800); txtConfirmPsw.SecureTextEntry = true; txtConfirmPsw.PlaceholderText = Language.StringByID(R.MyInternationalizationString.uPleaseRepeatInputNewPassword); //图标 var btnConfirmPswIcon = rowConfirmPsw.AddMostRightEmptyIcon(58, 58); btnConfirmPswIcon.UnSelectedImagePath = "Item/HidenPWD.png"; btnConfirmPswIcon.SelectedImagePath = "Item/UnHidenPWD.png"; btnConfirmPswIcon.ButtonClickEvent += (sender, e) => { btnConfirmPswIcon.IsSelected = !btnConfirmPswIcon.IsSelected; txtConfirmPsw.SecureTextEntry = !txtConfirmPsw.SecureTextEntry; }; //Row2的错误信息 var btnErrorRow2 = new NormalViewControl(800, 58, true); btnErrorRow2.X = ControlCommonResourse.XXLeft; btnErrorRow2.Y = frameTemp.Bottom + Application.GetRealHeight(29); btnErrorRow2.TextColor = 0xfff75858; frameRow2.AddChidren(btnErrorRow2); //重置密码 var btnReset = new BottomClickButton(688); btnReset.TextID = R.MyInternationalizationString.uResetPassword; btnReset.Y = Application.GetRealHeight(706); bodyFrameLayout.AddChidren(btnReset); btnReset.ButtonClickEvent += (sender, e) => { //密码检测 var flage = this.CheckPassword(frameRow1, frameRow2, btnErrorRow1, btnErrorRow2, txtNewPsw.Text, txtConfirmPsw.Text); if (flage == false) { return; } //重置密码 this.ResetPassword(txtNewPsw.Text, txtConfirmPsw.Text); }; } #endregion #region ■ 重置密码___________________________ /// /// 重置密码 /// /// 新密码 /// 二次确认密码 private void ResetPassword(string newPsw, string newPsw2) { var pra = new ResetPswPra(); pra.Password = newPsw; pra.AgainPassword = newPsw2; //更改密码 bool flage = UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/ResetPassword", false, pra); if (flage == false) { return; } //密码已经修改,请重新登录 string msg = Language.StringByID(R.MyInternationalizationString.uPasswordIsHadChangedAndLoginAgain); this.ShowMassage(ShowMsgType.Normal, msg, () => { //从新登录 UserCenterLogic.ReLoginAgain(Common.Config.Instance.Account); }, Language.StringByID(R.MyInternationalizationString.Login)); } #endregion #region ■ 一般方法___________________________ /// /// 密码检测 /// /// /// /// /// /// 输入的新密码 /// 输入的确认密码 /// private bool CheckPassword(FrameLayout frameRow1,FrameLayout frameRow2, NormalViewControl btnError1, NormalViewControl btnError2, string newPsw, string newPsw2) { //还原 frameRow1.Height = Application.GetRealHeight(23) + ControlCommonResourse.ListViewRowHeight; frameRow2.Y = frameRow1.Bottom; btnError2.Text = string.Empty; if (newPsw == string.Empty) { //请输入新密码 btnError1.TextID = R.MyInternationalizationString.uPleaseInputNewPassword; frameRow1.Height += Application.GetRealHeight(133); frameRow2.Y = frameRow1.Bottom; return false; } if (newPsw2 == string.Empty) { //请重复输入新密码 btnError2.TextID = R.MyInternationalizationString.uPleaseRepeatInputNewPassword; return false; } if (newPsw != newPsw2) { //确认密码不一致,请重新输入 btnError2.TextID = R.MyInternationalizationString.SecondPswNotEqual1; return false; } if (newPsw.Length < 6 || newPsw.Length > 13) { //密码长度为6-13个字符 string textValue = Language.StringByID(R.MyInternationalizationString.PswLengthMsg); if (textValue.Contains("{0}") == true) { textValue = string.Format(textValue, "6-13"); } btnError1.Text = textValue; frameRow1.Height += Application.GetRealHeight(133); frameRow2.Y = frameRow1.Bottom; return false; } return true; } #endregion #region ■ 结构体_____________________________ /// /// 重置密码的启动参数 /// private class ResetPswPra { /// /// 用户账号 /// public string Account = UserCenterResourse.UserInfo.Account; /// /// 国家地区代码,手机号发送验证码时使用 /// public int AreaCode = Convert.ToInt32(UserCenterResourse.UserInfo.AreaCode); /// /// 新密码 /// public string Password = string.Empty; /// /// 二次确认密码 /// public string AgainPassword = string.Empty; } #endregion } }