From d6fb0646531172f23648441c224cdcccd721b894 Mon Sep 17 00:00:00 2001 From: xm <1271024303@qq.com> Date: 星期一, 14 十二月 2020 09:59:01 +0800 Subject: [PATCH] 请合并代码,完成晾衣架最终功能。 --- ZigbeeApp/Shared/Phone/UserCenter/Password/EditorAccountPasswordForm.cs | 272 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 272 insertions(+), 0 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Password/EditorAccountPasswordForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Password/EditorAccountPasswordForm.cs new file mode 100755 index 0000000..093de67 --- /dev/null +++ b/ZigbeeApp/Shared/Phone/UserCenter/Password/EditorAccountPasswordForm.cs @@ -0,0 +1,272 @@ +锘縰sing System; + +namespace Shared.Phone.UserCenter.Password +{ + /// <summary> + /// 淇敼璐﹀彿瀵嗙爜鐢婚潰 + /// </summary> + public class EditorAccountPasswordForm : EditorCommonForm + { + #region 鈻� 鍙橀噺澹版槑___________________________ + + /// <summary> + /// 瀵嗙爜閿欒淇℃伅鎺т欢 + /// </summary> + private NormalViewControl msgControl = null; + + #endregion + + #region 鈻� 鍒濆鍖朹____________________________ + + /// <summary> + /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓) + /// </summary> + public void ShowForm() + { + //璁惧畾鏍囬 + base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uChangedPassword)); + + //鍒濆鍖栦腑閮ㄦ帶浠� + this.InitMiddleFrame(); + } + + /// <summary> + /// 鍒濆鍖栦腑閮ㄦ帶浠� + /// </summary> + private void InitMiddleFrame() + { + //娓呯┖bodyFrame + this.ClearBodyFrame(); + + var frameBackGroud = new FrameLayout(); + frameBackGroud.BackgroundColor = UserCenterColor.Current.White; + frameBackGroud.Height = Application.GetRealHeight(521); + bodyFrameLayout.AddChidren(frameBackGroud); + + //璇疯緭鍏ュ師瀵嗙爜 + var rowOldPsw = new FrameRowControl(); + //鍏抽棴鐘舵�佹彁绀� + rowOldPsw.UseClickStatu = false; + rowOldPsw.Y = Application.GetRealHeight(26); + frameBackGroud.AddChidren(rowOldPsw); + var txtoldPsw = new TextInputControl(Application.GetRealWidth(800), rowOldPsw.Height); + txtoldPsw.X = ControlCommonResourse.XXLeft; + txtoldPsw.SecureTextEntry = true; + txtoldPsw.PlaceholderText = Language.StringByID(R.MyInternationalizationString.PleaseInputOldPsw); + rowOldPsw.AddChidren(txtoldPsw); + //搴曠嚎 + var btnOldLine = rowOldPsw.AddBottomLine(); + //鑱斿姩绾跨殑鐘舵�� + txtoldPsw.btnLine = btnOldLine; + //鍥炬爣 + var btnoldPswIcon = rowOldPsw.AddMostRightEmptyIcon(58, 58); + btnoldPswIcon.UnSelectedImagePath = "Item/HidenPWD.png"; + btnoldPswIcon.SelectedImagePath = "Item/UnHidenPWD.png"; + btnoldPswIcon.ButtonClickEvent += (sender, e) => + { + btnoldPswIcon.IsSelected = !btnoldPswIcon.IsSelected; + txtoldPsw.SecureTextEntry = !txtoldPsw.SecureTextEntry; + }; + + //蹇樿瀵嗙爜锛� + var btnForgotPsw = new NormalViewControl(300, 49, true); + btnForgotPsw.Y = rowOldPsw.Bottom + Application.GetRealHeight(23); + btnForgotPsw.TextSize = 12; + btnForgotPsw.TextColor = UserCenterColor.Current.TextOrangeColor; + btnForgotPsw.TextID = R.MyInternationalizationString.ForgotPasswordMsg; + btnForgotPsw.TextAlignment = TextAlignment.CenterRight; + frameBackGroud.AddChidren(btnForgotPsw); + btnForgotPsw.X = bodyFrameLayout.Width - ControlCommonResourse.XXLeft - btnForgotPsw.Width; + btnForgotPsw.ButtonClickEvent += (sender, e) => + { + var form = new ForgotAccountPasswordForm(); + form.AddForm(); + }; + + //璇疯緭鍏ユ柊瀵嗙爜 + var rowNewPsw = new FrameRowControl(); + //鍏抽棴鐘舵�佹彁绀� + rowNewPsw.UseClickStatu = false; + rowNewPsw.Y = Application.GetRealHeight(236); + frameBackGroud.AddChidren(rowNewPsw); + var txtNewPsw = new TextInputControl(Application.GetRealWidth(800), rowNewPsw.Height); + txtNewPsw.X = ControlCommonResourse.XXLeft; + txtNewPsw.SecureTextEntry = true; + txtNewPsw.PlaceholderText = Language.StringByID(R.MyInternationalizationString.uPleaseInputNewPassword); + rowNewPsw.AddChidren(txtNewPsw); + //搴曠嚎 + var btnNewLine = rowNewPsw.AddBottomLine(); + //鑱斿姩绾跨殑鐘舵�� + txtNewPsw.btnLine = btnNewLine; + //鍥炬爣 + 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; + }; + + //璇烽噸澶嶈緭鍏ユ柊瀵嗙爜 + var rowConfirmPsw = new FrameRowControl(); + //鍏抽棴鐘舵�佹彁绀� + rowConfirmPsw.UseClickStatu = false; + rowConfirmPsw.Y = rowNewPsw.Bottom + Application.GetRealHeight(10); + frameBackGroud.AddChidren(rowConfirmPsw); + var txtConfirmPsw = new TextInputControl(Application.GetRealWidth(800), rowConfirmPsw.Height); + txtConfirmPsw.X = ControlCommonResourse.XXLeft; + txtConfirmPsw.SecureTextEntry = true; + txtConfirmPsw.PlaceholderText = Language.StringByID(R.MyInternationalizationString.uPleaseRepeatInputNewPassword); + rowConfirmPsw.AddChidren(txtConfirmPsw); + //鍥炬爣 + 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; + }; + + //閿欒淇℃伅 + this.msgControl = new NormalViewControl(bodyFrameLayout.Width, Application.GetRealHeight(58), false); + msgControl.Y = Application.GetRealHeight(582); + msgControl.TextAlignment = TextAlignment.Center; + msgControl.TextColor = 0xfff75858; + msgControl.IsBold = true; + bodyFrameLayout.AddChidren(msgControl); + + //纭淇敼 + var btnfinish = new BottomClickButton(688); + btnfinish.Y = Application.GetRealHeight(708); + btnfinish.TextID = R.MyInternationalizationString.DoEditor; + bodyFrameLayout.AddChidren(btnfinish); + btnfinish.ButtonClickEvent += (sender, e) => + { + msgControl.Text = string.Empty; + //瀵嗙爜妫�娴� + bool flage = this.CheckPassword(txtoldPsw.Text, txtNewPsw.Text, txtConfirmPsw.Text); + if (flage == false) + { + return; + } + //淇濆瓨瀵嗙爜 + this.SavePassword(txtConfirmPsw.Text); + }; + } + + #endregion + + #region 鈻� 淇濆瓨瀵嗙爜___________________________ + + /// <summary> + /// 淇濆瓨瀵嗙爜 + /// </summary> + /// <param name="newPassword"></param> + private void SavePassword(string newPassword) + { + var pra = new SavePasswordPra(); + pra.NewPassword = newPassword; + + //鏇存敼瀵嗙爜 + bool flage = UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/UpdatePassword", false, pra); + if (flage == false) + { + return; + } + //瀵嗙爜宸茬粡淇敼锛岃閲嶆柊鐧诲綍 + string msg = Language.StringByID(R.MyInternationalizationString.uPasswordIsHadChangedAndLoginAgain); + this.ShowMassage(ShowMsgType.Remind, msg, () => + { + //浠庢柊鐧诲綍 + UserCenterLogic.ReLoginAgain(Common.Config.Instance.Account); + }, Language.StringByID(R.MyInternationalizationString.Login)); + } + + #endregion + + #region 鈻� 涓�鑸柟娉昣__________________________ + + /// <summary> + /// 瀵嗙爜妫�娴� + /// </summary> + /// <param name="oldPsw">杈撳叆鐨勬棫瀵嗙爜</param> + /// <param name="newPsw">杈撳叆鐨勬柊瀵嗙爜</param> + /// <param name="newPsw2">杈撳叆鐨勭‘璁ゅ瘑鐮�</param> + /// <returns></returns> + private bool CheckPassword(string oldPsw, string newPsw, string newPsw2) + { + if (oldPsw == string.Empty) + { + //璇疯緭鍏ュ師瀵嗙爜 + this.msgControl.TextID = R.MyInternationalizationString.PleaseInputOldPsw; + return false; + } + if (newPsw == string.Empty) + { + //璇疯緭鍏ユ柊瀵嗙爜 + this.msgControl.TextID = R.MyInternationalizationString.uPleaseInputNewPassword; + return false; + } + if (newPsw2 == string.Empty) + { + //璇烽噸澶嶈緭鍏ユ柊瀵嗙爜 + this.msgControl.TextID = R.MyInternationalizationString.uPleaseRepeatInputNewPassword; + return false; + } + if (oldPsw != Common.Config.Instance.Password) + { + //瀵嗙爜閿欒锛岃閲嶆柊杈撳叆 + this.msgControl.TextID = R.MyInternationalizationString.uOldPsswordIsError; + return false; + } + if (newPsw != newPsw2) + { + //纭瀵嗙爜涓嶄竴鑷达紝璇烽噸鏂拌緭鍏� + this.msgControl.TextID = R.MyInternationalizationString.SecondPswNotEqual1; + return false; + } + if (newPsw == oldPsw) + { + //鏂板瘑鐮佸拰鍘熷瘑鐮佷竴鑷达紝璇烽噸鏂拌緭鍏� + this.msgControl.TextID = R.MyInternationalizationString.uNewPswAndOldPswIsEqual; + 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"); + } + this.msgControl.Text = textValue; + return false; + } + + return true; + } + + #endregion + + #region 鈻� 缁撴瀯浣揰____________________________ + + /// <summary> + /// 淇濆瓨瀵嗙爜鐨勫惎鍔ㄥ弬鏁扮被 + /// </summary> + private class SavePasswordPra + { + /// <summary> + /// 鏃у瘑鐮� + /// </summary> + public string OldPassword = Common.Config.Instance.Password; + /// <summary> + /// 鏂板瘑鐮� + /// </summary> + public string NewPassword = string.Empty; + } + + #endregion + } +} -- Gitblit v1.8.0