| | |
| | | LoadEvent_EditTextFcousChange(); |
| | | LoadEvent_ChangeTextVisble(); |
| | | LoadEvent_GetVerificationCode(); |
| | | LoadEvent_Register(); |
| | | LoadEvent_Reset(); |
| | | LoadEvent_TextChange(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | btnEmailLogin.TextSize = CSS_FontSize.TextFontSize; |
| | | btnPhoneLogin.TextColor = CSS_Color.MainColor; |
| | | btnPhoneLogin.TextSize = CSS_FontSize.EmphasisFontSize_Secondary; |
| | | btnChooseBottomLine.X = btnPhoneLogin.X + Application.GetRealWidth(27); |
| | | etAccount.PlaceholderText = Language.StringByID(InternationalizationString.PlsEntryCorrectMobilNeumber); |
| | | #endregion |
| | | |
| | |
| | | btnPhoneLogin.TextSize = CSS_FontSize.TextFontSize; |
| | | btnEmailLogin.TextColor = CSS_Color.MainColor; |
| | | btnEmailLogin.TextSize = CSS_FontSize.EmphasisFontSize_Secondary; |
| | | btnChooseBottomLine.X = btnEmailLogin.X + Application.GetRealWidth(27); |
| | | etAccount.PlaceholderText = Language.StringByID(InternationalizationString.PlsEntryEmailAddress); |
| | | #endregion |
| | | |
| | |
| | | accountView.AddChidren(btnAccountIcon); |
| | | #endregion |
| | | |
| | | }; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 加载文本变化事件 |
| | | /// </summary> |
| | | void LoadEvent_TextChange() |
| | | { |
| | | etAccount.TextChangeEventHandler += (sender, e) => |
| | | { |
| | | Regex reg = new Regex(@"^[1]+\d{9}"); |
| | | var mFalg = reg.Match(etAccount.Text.Trim()); |
| | | if (!mFalg.Success || (btnGlobalRoaming.Text == "+86" && etAccount.Text.Trim().Length != 11)) |
| | | { |
| | | btnGetVerificationCode.IsSelected = false; |
| | | } |
| | | else |
| | | { |
| | | btnGetVerificationCode.IsSelected = true; |
| | | } |
| | | }; |
| | | } |
| | | |
| | |
| | | //手机方式-验证手机号码是否正确 |
| | | if (registerType == 0) |
| | | { |
| | | Regex reg = new Regex("^\\d+$"); |
| | | Regex reg = new Regex(@"^[1]+\d{9}"); |
| | | var mFalg = reg.Match(etAccount.Text.Trim()); |
| | | if (!mFalg.Success || (btnGlobalRoaming.Text == "+86" && etAccount.Text.Trim().Length != 11)) |
| | | { |
| | |
| | | } |
| | | else |
| | | { |
| | | //标记手机号码有效 |
| | | btnGetVerificationCode.IsSelected = true; |
| | | //账号有效、密码有效、验证码输入了,才能点击方式 |
| | | if (btnGetVerificationCode.IsSelected && ValidPassword && string.IsNullOrEmpty(etVerificationCode.Text.Trim())) |
| | | { |
| | | btnRegister.IsSelected = true; |
| | | } |
| | | LoadMothed_EnableResetButton(); |
| | | } |
| | | } |
| | | else if (registerType == 1) |
| | |
| | | } |
| | | else |
| | | { |
| | | //标记手机号码有效 |
| | | btnGetVerificationCode.IsSelected = true; |
| | | //账号有效、密码有效、验证码输入了,才能点击方式 |
| | | if (btnGetVerificationCode.IsSelected && ValidPassword && string.IsNullOrEmpty(etVerificationCode.Text.Trim())) |
| | | { |
| | | btnRegister.IsSelected = true; |
| | | } |
| | | LoadMothed_EnableResetButton(); |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | else |
| | | { |
| | | ValidPassword = true; |
| | | //账号有效、密码有效、验证码输入了,才能点击方式 |
| | | if (btnGetVerificationCode.IsSelected && ValidPassword && string.IsNullOrEmpty(etVerificationCode.Text.Trim())) |
| | | { |
| | | btnRegister.IsSelected = true; |
| | | } |
| | | LoadMothed_EnableResetButton(); |
| | | } |
| | | } |
| | | }; |
| | |
| | | btnVerificationCodeViewBottomLine.Height = Application.GetRealHeight(1); |
| | | if (etVerificationCode.Text.Length > 4) |
| | | { |
| | | //账号有效、密码有效、验证码输入了,才能点击方式 |
| | | if (btnGetVerificationCode.IsSelected && ValidPassword && string.IsNullOrEmpty(etVerificationCode.Text.Trim())) |
| | | { |
| | | btnRegister.IsSelected = true; |
| | | } |
| | | LoadMothed_EnableResetButton(); |
| | | } |
| | | } |
| | | }; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 更改密码可见性 |
| | |
| | | btnGetVerificationCode.MouseUpEventHandler += (sender, e) => { |
| | | if (btnGetVerificationCode.IsSelected) |
| | | { |
| | | //短信发送间隔60s |
| | | btnGetVerificationCode.IsSelected = false; |
| | | int time = 60; |
| | | new Thread(() => |
| | | //获取验证码 |
| | | var result = pm.SendSms(etAccount.Text.Trim()); |
| | | if (result.StateCode == "Success") |
| | | { |
| | | while (time == 0) |
| | | //短信发送间隔60s |
| | | btnGetVerificationCode.IsSelected = false; |
| | | etVerificationCode.Foucs = true; |
| | | int time = 60; |
| | | new Thread(() => |
| | | { |
| | | time--; |
| | | while (time > 0) |
| | | { |
| | | time--; |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | btnGetVerificationCode.Text = time.ToString() + "s"; |
| | | }); |
| | | Thread.Sleep(1000); |
| | | } |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | btnGetVerificationCode.Text = time.ToString() + "s"; |
| | | //回复获取短信按钮事件 |
| | | btnGetVerificationCode.IsSelected = true; |
| | | btnGetVerificationCode.TextID = InternationalizationString.GetVerificationCode; |
| | | }); |
| | | Thread.Sleep(1000); |
| | | } |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | //回复获取短信按钮事件 |
| | | btnGetVerificationCode.IsSelected = true; |
| | | }); |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | //检查手机是否已经被方式 |
| | | var checkPhoneResult = pm.IsExistingAccount(etAccount.Text.Trim()); |
| | | //手机未被方式 |
| | | if (checkPhoneResult.StateCode != HttpRequesResult.SUCCESS.ToString()) |
| | | { |
| | | //获取验证码 |
| | | pm.GetPhoneVerificationCode(etAccount.Text.Trim(), MainPage.Company); |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | } |
| | | else |
| | | { |
| | | //提示手机号码已经方式 |
| | | string tipString = "Server error"; |
| | | switch (result.StateCode) |
| | | { |
| | | case "Exist": |
| | | tipString = Language.StringByID(InternationalizationString.AccountAlreadyExists); |
| | | break; |
| | | case "SendFail": |
| | | tipString = Language.StringByID(InternationalizationString.FailedToSendVerificationCode); |
| | | break; |
| | | case "Self:Net_Error": |
| | | tipString = Language.StringByID(InternationalizationString.NetworkAnomaly); |
| | | break; |
| | | } |
| | | |
| | | new Tip() |
| | | { |
| | | CloseTime = 3, |
| | | Direction = AMPopTipDirection.None, |
| | | Text = Language.StringByID(InternationalizationString.AccountAlreadyExists) |
| | | Text = tipString |
| | | }.Show(bodyView); |
| | | } |
| | | } |
| | |
| | | /// <summary> |
| | | /// 加载方式按钮事件 |
| | | /// </summary> |
| | | void LoadEvent_Register() |
| | | void LoadEvent_Reset() |
| | | { |
| | | btnRegister.MouseUpEventHandler += (sender, e) => |
| | | btnReset.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | //手机方式 |
| | | if (registerType == 0) |
| | | if (btnReset.IsSelected) |
| | | { |
| | | //校验验证码 |
| | | var validateSmsResult = pm.ValidateSmsCode(etAccount.Text.Trim(), etVerificationCode.Text.Trim()); |
| | | //验证码校验成功 |
| | | if (validateSmsResult.StateCode == HttpRequesResult.SUCCESS.ToString()) |
| | | { |
| | | //验证账号 |
| | | var registerPhoneResult = pm.RegisterPhone(etAccount.Text.Trim(), etPassword.Text.Trim(), Language.CurrentLanguage); |
| | | if (registerPhoneResult.StateCode == HttpRequesResult.SUCCESS.ToString()) |
| | | { |
| | | //验证成功 |
| | | //执行回调事件 |
| | | callbackAction?.Invoke(etAccount.Text.Trim()); |
| | | } |
| | | else |
| | | { |
| | | //验证失败 |
| | | new Tip() |
| | | { |
| | | CloseTime = 3, |
| | | Text = registerPhoneResult.ErrorInfo, |
| | | Direction = AMPopTipDirection.None, |
| | | }.Show(bodyView); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //验证码校验失败 |
| | | new Tip() |
| | | { |
| | | CloseTime = 3, |
| | | Direction = AMPopTipDirection.None, |
| | | Text = Language.StringByID(InternationalizationString.VerificationCodeWrong) |
| | | }.Show(bodyView); |
| | | } |
| | | } |
| | | else if (registerType == 1) |
| | | { |
| | | //邮箱方式 |
| | | //校验验证码 |
| | | var validateSmsResult = pm.ValidateSmsCode(etAccount.Text.Trim(), etVerificationCode.Text.Trim()); |
| | | //验证码校验成功 |
| | | if (validateSmsResult.StateCode == HttpRequesResult.SUCCESS.ToString()) |
| | | { |
| | | //方式账号 |
| | | var registerPhoneResult = pm.RegisterPhone(etAccount.Text.Trim(), etPassword.Text.Trim(), Language.CurrentLanguage); |
| | | if (registerPhoneResult.StateCode == HttpRequesResult.SUCCESS.ToString()) |
| | | { |
| | | //方式成功 |
| | | //执行回调事件 |
| | | callbackAction?.Invoke(etAccount.Text.Trim()); |
| | | } |
| | | else |
| | | { |
| | | //方式失败 |
| | | new Tip() |
| | | { |
| | | CloseTime = 3, |
| | | Text = registerPhoneResult.ErrorInfo, |
| | | Direction = AMPopTipDirection.None, |
| | | }.Show(bodyView); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //验证码校验失败 |
| | | new Tip() |
| | | { |
| | | CloseTime = 3, |
| | | Direction = AMPopTipDirection.None, |
| | | Text = Language.StringByID(InternationalizationString.VerificationCodeWrong) |
| | | }.Show(bodyView); |
| | | } |
| | | //创建修改密码线程 |
| | | var loginThread = LoadMothed_ResetThread(); |
| | | waitPage = new Loading(); |
| | | new WaitPageMothed().LoadPage_WaitPage(loginThread, bodyView, waitPage); |
| | | } |
| | | }; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 加载重置密码方法 |
| | | /// </summary> |
| | | Thread LoadMothed_ResetThread() |
| | | { |
| | | string account = etAccount.Text.Trim(); |
| | | string password = etPassword.Text.Trim(); |
| | | string repeatPassword = etRepeatPassword.Text.Trim(); |
| | | string verCode = etVerificationCode.Text.Trim(); |
| | | int countryIndex = 0; |
| | | try |
| | | { |
| | | countryIndex = Convert.ToInt32(btnGlobalRoaming.Text.Trim().Remove('+')); |
| | | } |
| | | catch { } |
| | | |
| | | return new Thread(() => |
| | | { |
| | | var verResult = pm.ValidatorCode(account, verCode, countryIndex); |
| | | if (verResult.StateCode == "Success") |
| | | { |
| | | var resetResult = pm.ResetPassword(account, password, repeatPassword, countryIndex); |
| | | if(resetResult.StateCode == "Success") |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | waitPage.Hide(); |
| | | this.Close(); |
| | | callbackAction?.Invoke(account); |
| | | }); |
| | | } |
| | | else |
| | | { |
| | | string erorrInfo = ""; |
| | | switch (resetResult.StateCode) |
| | | { |
| | | case "PwdNoConfirm"://两次输入的密码不一致 |
| | | erorrInfo = Language.StringByID(InternationalizationString.IncorrectRepeatPassword); |
| | | break; |
| | | case "AccountNoExists"://两次输入的密码不一致 |
| | | erorrInfo = Language.StringByID(InternationalizationString.AccountNotExist); |
| | | break; |
| | | default: |
| | | erorrInfo = "Server error"; |
| | | break; |
| | | } |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | waitPage.Hide(); |
| | | new Tip() |
| | | { |
| | | CloseTime = 3, |
| | | Direction = AMPopTipDirection.None, |
| | | Text = erorrInfo, |
| | | }.Show(bodyView); |
| | | }); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | string erorrInfo = ""; |
| | | switch (verResult.StateCode) |
| | | { |
| | | case "ValidCodeAndPhoneNoEqual"://验证码错误 |
| | | erorrInfo = Language.StringByID(InternationalizationString.VerificationCodeWrong); |
| | | break; |
| | | default: |
| | | erorrInfo = "Server error"; |
| | | break; |
| | | } |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | waitPage.Hide(); |
| | | new Tip() |
| | | { |
| | | CloseTime = 3, |
| | | Direction = AMPopTipDirection.None, |
| | | Text = erorrInfo, |
| | | }.Show(bodyView); |
| | | }); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 使能修改确定按钮 |
| | | /// </summary> |
| | | void LoadMothed_EnableResetButton() |
| | | { |
| | | if(!string.IsNullOrEmpty( etAccount.Text)&&!string.IsNullOrEmpty(etPassword.Text)&& !string.IsNullOrEmpty( etVerificationCode.Text) && (etPassword.Text.Trim()== etRepeatPassword.Text.Trim())) |
| | | { |
| | | btnReset.IsSelected = true; |
| | | } |
| | | else |
| | | { |
| | | btnReset.IsSelected = false; |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |