From 25429f085093d89d543a0b90e30d0d62d1b7dac9 Mon Sep 17 00:00:00 2001 From: hxb <hxb@hdlchina.com.cn> Date: 星期二, 30 八月 2022 09:37:38 +0800 Subject: [PATCH] 合并了IOS的代码 --- ZigbeeApp/Shared/Phone/Login/AccountForgetPWD.cs | 513 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 513 insertions(+), 0 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/Login/AccountForgetPWD.cs b/ZigbeeApp/Shared/Phone/Login/AccountForgetPWD.cs new file mode 100644 index 0000000..60b0ace --- /dev/null +++ b/ZigbeeApp/Shared/Phone/Login/AccountForgetPWD.cs @@ -0,0 +1,513 @@ +锘縰sing System; +using Shared.Common; +using Shared.Phone.Device.CommonForm; + +namespace Shared.Phone.Login +{ + public class AccountForgetPWD : FrameLayout + { + #region 鈼� 鍙橀噺____________________________ + /// <summary> + /// 鎵嬫満閭 + /// </summary> + private PhoneEmailForm phoneEmailForm; + /// <summary> + /// phoneRowForm + /// </summary> + private PhoneRowForm phoneRow; + /// <summary> + /// emailRow + /// </summary> + private EmailForgotRowForm emailRow; + /// <summary> + /// pwdRow + /// </summary> + private PwdForForgetRowForm pwdRow; + /// <summary> + /// pwdComfireRow + /// </summary> + private PwdForForgetRowForm pwdComfireRow; + /// <summary> + /// CodeForRegisterRowForm + /// </summary> + private CodeForForgetRowForm codeRow; + /// <summary> + /// bodyFrameLayout + /// </summary> + private FrameLayout bodyFrameLayout; + /// <summary> + /// 璐﹀彿楠岃瘉鐮乫l + /// </summary> + private FrameLayout accountCodeFL; + /// <summary> + /// 鐧诲綍閿欒鎻愮ず鎸夐挳 + /// </summary> + private Button errorBtn; + /// <summary> + /// 纭閲嶇疆 + /// </summary> + private Button resetBtn; + /// <summary> + /// 璐﹀彿 + /// </summary> + private string account; + + + #endregion + + #region 鈼� 鏋勯�犳柟娉昣________________________ + /// <summary> + /// AccountForgetPWD + /// </summary> + public AccountForgetPWD() + { + CommonPage.Instance.IsDrawerLockMode = true; + BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor; + Tag = "Forgot"; + } + #endregion + + #region 鈼� 鏄剧ず鐣岄潰_________________________ + /// <summary> + /// show + /// </summary> + public void Show() + { + //AddTop + AddTopFL(); + //AddBody + AddBodyView(); + + //bind + BindEvent(); + } + + #endregion + + #region 鈼� 娣诲姞____________________________ + /// <summary> + /// AddTop + /// </summary> + private void AddTopFL() + { + var top = new Device.CommonForm.TopFrameLayout(); + AddChidren(top); + top.InitTopview(); + top.SetTopTitle(Language.StringByID(R.MyInternationalizationString.ForgotPWD)); + top.backButton.MouseUpEventHandler += (sender, e) => + { + RemoveFromParent(); + }; + + } + /// <summary> + /// AddBodyView + /// </summary> + private void AddBodyView() + { + bodyFrameLayout = new FrameLayout() + { + Y = Application.GetRealHeight(184), + Height = Application.GetRealHeight(1737), + BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor, + }; + AddChidren(bodyFrameLayout); + + phoneEmailForm = new PhoneEmailForm(); + phoneEmailForm.Init(bodyFrameLayout, 127); + phoneEmailForm.SetSelectedColor(ZigbeeColor.Current.GXCButtonBlackSelectedColor); + + accountCodeFL = new FrameLayout() + { + Y = Application.GetRealHeight(334), + Height = Application.GetRealHeight(852), + Width = Application.GetRealWidth(942), + Gravity = Gravity.CenterHorizontal, + BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor, + Radius = (uint)Application.GetRealHeight(17) + }; + bodyFrameLayout.AddChidren(accountCodeFL); + + AddPhoneOrEmailFL(accountCodeFL, "Phone"); + + //閿欒鎻愮ずBtn + errorBtn = new Button() + { + X = Application.GetRealWidth(127), + Y = Application.GetRealHeight(1060), + Width = Application.GetRealWidth(700), + Height = Application.GetRealHeight(58), + TextColor = ZigbeeColor.Current.GXCTextRed, + TextAlignment = TextAlignment.CenterLeft, + TextSize = CommonFormResouce.TextSize, + IsBold = true + }; + bodyFrameLayout.AddChidren(errorBtn); + + resetBtn = new Button() + { + Y = Application.GetRealHeight(1281), + Width = Application.GetRealWidth(688), + Height = Application.GetRealHeight(127), + Gravity = Gravity.CenterHorizontal, + TextID = R.MyInternationalizationString.ComfirmReset, + TextColor = ZigbeeColor.Current.GXCTextGrayColor, + SelectedTextColor = ZigbeeColor.Current.GXCTextWhiteColor, + SelectedBackgroundColor = ZigbeeColor.Current.GXCButtonBlackSelectedColor, + BackgroundColor = ZigbeeColor.Current.GXCButtonUnSelectedColor, + Radius = (uint)Application.GetRealHeight(127 / 2), + Enable = !string.IsNullOrEmpty(codeRow.VerificationCodeET?.Text), + IsSelected = !string.IsNullOrEmpty(codeRow.VerificationCodeET?.Text), + TextSize = 16, + IsBold = true, + }; + bodyFrameLayout.AddChidren(resetBtn); + } + + #endregion + + #region 鈼� 閫夋嫨浜嬩欢_________________________ + /// <summary> + /// phone/email 閫夋嫨 + /// </summary> + /// <param name="sender"></param> + /// <param name="mouseEventArgs"></param> + private void SelectPhoneOrEmail_MouseUpEvent(object sender, MouseEventArgs mouseEventArgs) + { + phoneEmailForm.SelectedPhone.IsSelected = phoneEmailForm.SelectedEmail.IsSelected = false; + phoneEmailForm.SelectedPhone.IsBold = phoneEmailForm.SelectedEmail.IsBold = false; + resetBtn.Enable = resetBtn.IsSelected = false; + errorBtn.Text = string.Empty; + (sender as Button).IsSelected = (sender as Button).IsBold = true; + if ((sender as Button).Tag.ToString() == "Phone") + { + AddPhoneOrEmailFL(accountCodeFL, "Phone"); + } + else + { + AddPhoneOrEmailFL(accountCodeFL, "Email"); + } + } + + /// <summary> + /// AddPhoneOrEmailFL + /// </summary> + /// <param name="accountCodeFrameLayout"></param> + /// <param name="phoneOrEmail"></param> + private void AddPhoneOrEmailFL(FrameLayout accountCodeFrameLayout, string phoneOrEmail) + { + accountCodeFrameLayout.RemoveAll(); + account = string.Empty; + if (phoneOrEmail == "Phone") + { + phoneRow = new PhoneRowForm(); + phoneRow.Init(accountCodeFrameLayout, this, this.account, 29, 29); + phoneRow.AccountET.TextChangeEventHandler += Account_TextChange; + } + else + { + emailRow = new EmailForgotRowForm(); + emailRow.Init(accountCodeFrameLayout, this.account, 29, 29); + emailRow.AccountET.TextChangeEventHandler += Account_TextChange; + } + + codeRow = new CodeForForgetRowForm(); + codeRow.Init(accountCodeFrameLayout, 29, 196); + codeRow.VerificationCodeET.TextChangeEventHandler += Code_TextChange; + codeRow.SendCodeBtn.MouseUpEventHandler += SendCode_MouseUpEventAsync; + + pwdRow = new PwdForForgetRowForm(); + pwdRow.Init(accountCodeFrameLayout, 29, 363); + + pwdComfireRow = new PwdForForgetRowForm(); + pwdComfireRow.Init(accountCodeFrameLayout, 29, 530); + pwdComfireRow.SetPlaceholdText(Language.StringByID(R.MyInternationalizationString.PleaseComfirePWD)); + } + #endregion + + #region 鈼� 缁戝畾浜嬩欢_________________________ + + /// <summary> + /// 缁戝畾鎸夐挳浜嬩欢 + /// </summary> + private void BindEvent() + { + //閫夋嫨鎵嬫満閭 + phoneEmailForm.SelectedPhone.MouseUpEventHandler += SelectPhoneOrEmail_MouseUpEvent; + phoneEmailForm.SelectedEmail.MouseUpEventHandler += SelectPhoneOrEmail_MouseUpEvent; + resetBtn.MouseUpEventHandler += Reset; + } + #endregion + + #region 鈼� 璐﹀彿銆侀獙璇佺爜鐩戝惉__________________ + /// <summary> + /// 璐﹀彿鐩戝惉 + /// </summary> + /// <param name="sender">Sender.</param> + /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param> + private void Account_TextChange(object sender, string mouseEventArgs) + { + errorBtn.Text = string.Empty; + + if ((sender as EditText).Text.Trim().Length > 0) + { + codeRow.SendCodeBtn.Enable = codeRow.SendCodeBtn.IsSelected = true; + account = (sender as EditText).Text.Trim(); + } + else + { + codeRow.SendCodeBtn.Enable = codeRow.SendCodeBtn.IsSelected = false; + } + } + + /// <summary> + /// code鐩戝惉浜嬩欢 + /// </summary> + /// <param name="sender">Sender.</param> + /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param> + private void Code_TextChange(object sender, string mouseEventArgs) + { + errorBtn.Text = string.Empty; + if ((sender as EditText).Text.Trim().Length > 0) + { + resetBtn.Enable = resetBtn.IsSelected = true; + } + else + { + resetBtn.Enable = resetBtn.IsSelected = false; + } + } + + #endregion + + #region 鈼� 鍙戦�侀獙璇佺爜________________________ + /// <summary> + /// 鍙戦�侀獙璇佺爜 + /// </summary> + /// <param name="sender"></param> + /// <param name="mouseEventArgs"></param> + private void SendCode_MouseUpEventAsync(object sender, MouseEventArgs mouseEventArgs) + { + if (CheckAccount(account) == false) + { + return; + } + + (sender as Button).Enable = (sender as Button).IsSelected = false; + CommonPage.Loading.Start(); + try + { + int companyInt = 0; + if (CommonPage.PhoneZoneStr == "86") + { + companyInt = CommonPage.Company; + } + else + { + companyInt = CommonPage.CompanyForINTERNETION; + } + var reqDto = new SendDataToServer.LoginSendVerCodeObj() + { + Account = account, + Company = companyInt, + AreaCode = int.Parse(CommonPage.PhoneZoneStr), + Language = CommonPage.ZigBeeLanguage + }; + var requestRevertObj = CommonFormResouce.LoginSendVerCode(reqDto); + if (requestRevertObj == null) + { + errorBtn.TextID = R.MyInternationalizationString.RequestServerFailed; + return; + } + var stateCodeStr = requestRevertObj.StateCode.ToUpper(); + if (stateCodeStr == "SUCCESS") + { + codeRow.TimeBegin(); + } + else if (stateCodeStr == "PARAMETEROREMPTY") + { + //鎻愪緵鐨勫弬鏁伴敊璇� + errorBtn.TextID = R.MyInternationalizationString.PARAMETEROREMPTY; + (sender as Button).Enable = (sender as Button).IsSelected = true; + } + else if (stateCodeStr == "SENDFAIL") + { + //楠岃瘉鐮佸彂閫佸け璐� + errorBtn.TextID = R.MyInternationalizationString.SENDFAIL; + (sender as Button).Enable = (sender as Button).IsSelected = true; + } + else if (stateCodeStr == "ACCOUNTNOEXISTS") + { + //璐﹀彿涓嶅瓨鍦� + errorBtn.TextID = R.MyInternationalizationString.ACCOUNTNOEXISTS; + (sender as Button).Enable = (sender as Button).IsSelected = true; + } + else + { + errorBtn.TextID = R.MyInternationalizationString.RequestServerFailed; + (sender as Button).Enable = (sender as Button).IsSelected = true; + } + } + catch + { + errorBtn.TextID = R.MyInternationalizationString.RequestServerFailed; + (sender as Button).Enable = (sender as Button).IsSelected = true; + } + finally + { + CommonPage.Loading.Hide(); + } + } + + + /// <summary> + /// CheckAccount + /// </summary> + /// <param name="accountStr"></param> + /// <returns></returns> + private bool CheckAccount(string accountStr) + { + errorBtn.Text = string.Empty; + if (phoneEmailForm.SelectedEmail.IsSelected) + { + if (AccountLogic.Instance.CheckEmail(accountStr) == false) + { + errorBtn.TextID = R.MyInternationalizationString.TheEmailError; + return false; + } + } + else + { + if (AccountLogic.Instance.CheckPhoneWithZone(accountStr, CommonPage.PhoneZoneStr) == false) + { + errorBtn.TextID = R.MyInternationalizationString.ThePhoneError; + return false; + } + } + return true; + } + + #endregion + + #region 鈼� 纭淇敼__________________________ + + /// <summary> + /// Reset + /// </summary> + /// <param name="sender"></param> + /// <param name="mouseEventArgs"></param> + private void Reset(object sender,MouseEventArgs mouseEventArgs) + { + + if (CheckAccount(account) == false) + { + return; + } + //鍏堝垽鏂�2娆″瘑鐮佽緭鍏ユ槸鍚︿竴鑷� + if (pwdRow.PasswrodET.Text.Trim() != pwdComfireRow.PasswrodET.Text.Trim()) + { + errorBtn.TextID = R.MyInternationalizationString.TwoPasswordInconsistency; + return; + } + if (AccountLogic.Instance.CheckPwdLength(pwdRow.PasswrodET.Text.Trim()) == false) + { + errorBtn.TextID = R.MyInternationalizationString.ThePWDLengthError; + return; + } + + CommonPage.Loading.Start(); + try + { + var reqDto = new SendDataToServer.ValidatorCodeObj() + { + Account = account, + Code = codeRow.VerificationCodeET.Text.Trim(), + AreaCode = int.Parse(CommonPage.PhoneZoneStr), + Language = CommonPage.ZigBeeLanguage + }; + //楠岃瘉楠岃瘉鐮� + var requestRevertObj = CommonFormResouce.ValidatorCode(reqDto); + if (requestRevertObj == null) + { + CommonPage.Instance.FailureToServer(); + return; + } + var stateCodeStr = requestRevertObj.StateCode.ToUpper(); + if (stateCodeStr == "SUCCESS") + { + //閲嶇疆瀵嗙爜 + var reqREPWD = new SendDataToServer.ResetPasswordObj() + { + Account = account, + Password = pwdRow.PasswrodET.Text.Trim(), + AreaCode = int.Parse(CommonPage.PhoneZoneStr), + AgainPassword = pwdComfireRow.PasswrodET.Text.Trim() + }; + var revertObj = CommonFormResouce.ResetPassword(reqREPWD); + if (revertObj == null) + { + CommonPage.Instance.FailureToServer(); + return; + } + var stateStr = revertObj.StateCode.ToUpper(); + if (stateStr == "SUCCESS") + { + var success = new AccountResetPWDSuccess(); + CommonPage.Instance.AddChidren(success); + success.Show(); + } + else if (stateStr == "PARAMETEROREMPTY") + { + errorBtn.TextID = R.MyInternationalizationString.PARAMETEROREMPTY; + } + else if (stateStr == "ACCOUNTNOEXISTS") + { + errorBtn.TextID = R.MyInternationalizationString.ACCOUNTNOEXISTS; + } + else if (stateStr == "FAIL") + { + errorBtn.TextID = R.MyInternationalizationString.FAIL; + } + else if(stateStr == "NEWPASSWORDANDOLDPASSWORDEQUAL") + { + errorBtn.TextID = R.MyInternationalizationString.NEWPASSWORDANDOLDPASSWORDEQUAL; + } + else + { + errorBtn.TextID = R.MyInternationalizationString.RequestServerFailed; + } + } + else if (stateCodeStr == "PARAMETEROREMPTY") + { + //鎻愪緵鐨勫弬鏁伴敊璇� + errorBtn.TextID = R.MyInternationalizationString.PARAMETEROREMPTY; + } + else if (stateCodeStr == "VALIDCODEANDPHONENOEQUAL") + { + //楠岃瘉鐮侀敊璇� + errorBtn.TextID = R.MyInternationalizationString.VALIDCODEANDPHONENOEQUAL; + } + else if (stateCodeStr == "NORECORD") + { + errorBtn.TextID = R.MyInternationalizationString.NORECORD; + } + + else + { + errorBtn.TextID = R.MyInternationalizationString.RequestServerFailed; + } + } + catch + { + errorBtn.TextID = R.MyInternationalizationString.RequestServerFailed; + } + finally + { + CommonPage.Loading.Hide(); + } + + } + + #endregion + } +} -- Gitblit v1.8.0