New file |
| | |
| | | using 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> |
| | | /// 账号验证码fl |
| | | /// </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 |
| | | } |
| | | } |