New file |
| | |
| | | using System;
|
| | | using System.Collections.Generic;
|
| | | using System.Threading.Tasks;
|
| | |
|
| | | namespace Shared.Phone.UserCenter.Password
|
| | | {
|
| | | /// <summary>
|
| | | /// 验证新邮箱的画面
|
| | | /// </summary>
|
| | | public class CheckNewEmailForm : EditorCommonForm
|
| | | {
|
| | | #region ■ 变量声明___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 错误信息控件
|
| | | /// </summary>
|
| | | private NormalViewControl btnErrorMsg = null;
|
| | | /// <summary>
|
| | | /// 新邮箱(防止恶意变更)
|
| | | /// </summary>
|
| | | private string newEmail = string.Empty;
|
| | | /// <summary>
|
| | | /// 标记是否能够校验验证码了
|
| | | /// </summary>
|
| | | private bool canCheckCode = false;
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 初始化_____________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 画面显示(底层会固定调用此方法,借以完成画面创建)
|
| | | /// </summary>
|
| | | public void ShowForm()
|
| | | {
|
| | | //设置头部信息
|
| | | base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uEditorEmail));
|
| | |
|
| | | //初始化中部信息
|
| | | this.InitMiddleFrame();
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 初始化中部信息
|
| | | /// </summary>
|
| | | private void InitMiddleFrame()
|
| | | {
|
| | | //清空bodyFrame
|
| | | this.ClearBodyFrame();
|
| | |
|
| | | var frame = new FrameLayout();
|
| | | frame.Y = Application.GetRealHeight(161);
|
| | | frame.Gravity = Gravity.CenterHorizontal;
|
| | | frame.Width = Application.GetRealWidth(688);
|
| | | frame.Height = Application.GetRealHeight(127);
|
| | | bodyFrameLayout.AddChidren(frame);
|
| | | //输入框
|
| | | var txtValue = new TextInputControl(frame.Width - Application.GetRealWidth(20), frame.Height - ControlCommonResourse.BottomLineHeight, false);
|
| | | txtValue.X = Application.GetRealWidth(10);
|
| | | txtValue.PlaceholderText = Language.StringByID(R.MyInternationalizationString.uPleaseInputNewEmailAddress);
|
| | | frame.AddChidren(txtValue);
|
| | |
|
| | | //线
|
| | | var btnLine = new NormalViewControl(frame.Width, ControlCommonResourse.BottomLineHeight, false);
|
| | | btnLine.Y = txtValue.Bottom;
|
| | | btnLine.BackgroundColor = UserCenterColor.Current.ButtomLine;
|
| | | frame.AddChidren(btnLine);
|
| | | //联动线的状态
|
| | | txtValue.btnLine = btnLine;
|
| | |
|
| | | if (string.IsNullOrEmpty(UserCenterResourse.UserInfo.Email) == false)
|
| | | {
|
| | | //确认身份成功,请绑定新邮箱
|
| | | var btnMsg1 = new NormalViewControl(800, 49, false);
|
| | | btnMsg1.X = Application.GetRealWidth(196);
|
| | | btnMsg1.Y = frame.Bottom + Application.GetRealHeight(40);
|
| | | btnMsg1.TextSize = 12;
|
| | | btnMsg1.TextColor = UserCenterColor.Current.TextGrayColor1;
|
| | | btnMsg1.TextID = R.MyInternationalizationString.uAuthenticationSuccessAndBindNewEmail;
|
| | | bodyFrameLayout.AddChidren(btnMsg1);
|
| | | }
|
| | |
|
| | | //初始化验证码控件
|
| | | var btnCodeControl = new VerificationCodeControl(6);
|
| | | btnCodeControl.Y = Application.GetRealHeight(475);
|
| | | bodyFrameLayout.AddChidren(btnCodeControl);
|
| | | btnCodeControl.InitControl();
|
| | | btnCodeControl.TxtCodeChangeEvent += (sender, e) =>
|
| | | {
|
| | | if (btnErrorMsg.Visible == true)
|
| | | {
|
| | | btnErrorMsg.Visible = false;
|
| | | }
|
| | | };
|
| | | btnCodeControl.FinishInputEvent += (value) =>
|
| | | {
|
| | | //校验验证码
|
| | | if (this.CheckVerificationCode(value) == false)
|
| | | {
|
| | | //清空验证码
|
| | | btnCodeControl.ClearInputValue();
|
| | | }
|
| | | };
|
| | |
|
| | | //验证码错误,请重新输入
|
| | | this.btnErrorMsg = new NormalViewControl(bodyFrameLayout.Width, Application.GetRealHeight(58), false);
|
| | | btnErrorMsg.Y = Application.GetRealHeight(677);
|
| | | btnErrorMsg.TextAlignment = TextAlignment.Center;
|
| | | btnErrorMsg.TextColor = 0xfff75858;
|
| | | btnErrorMsg.TextID = R.MyInternationalizationString.uVerificationCodeErrorInputAgain;
|
| | | btnErrorMsg.IsBold = true;
|
| | | bodyFrameLayout.AddChidren(btnErrorMsg);
|
| | | btnErrorMsg.Visible = false;
|
| | |
|
| | | var btnOk = new BottomClickButton(688);
|
| | | btnOk.Y = Application.GetRealHeight(792);
|
| | | btnOk.TextID = R.MyInternationalizationString.uGetVerificationCode;
|
| | | bodyFrameLayout.AddChidren(btnOk);
|
| | | btnOk.oldBackgroundColor = UserCenterColor.Current.ClickButtonDefultColor;
|
| | | btnOk.CanClick = false;
|
| | | btnOk.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //清空输入的值
|
| | | btnCodeControl.ClearInputValue();
|
| | |
|
| | | this.btnErrorMsg.Visible = false;
|
| | | //检测邮箱的地址
|
| | | if (this.CheckEmail(txtValue.Text.Trim()) == false)
|
| | | {
|
| | | return;
|
| | | }
|
| | | //发送验证码到邮箱
|
| | | this.SendCodeToEmail(btnOk, txtValue.Text.Trim());
|
| | | };
|
| | |
|
| | | txtValue.TextChangeEventHandler += (sender, value) =>
|
| | | {
|
| | | if (value == string.Empty)
|
| | | {
|
| | | //按键不可用
|
| | | btnOk.CanClick = false;
|
| | | }
|
| | | else if (btnOk.CanClick == false)
|
| | | {
|
| | | //按键可用
|
| | | btnOk.CanClick = true;
|
| | | }
|
| | | };
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 发送验证码到邮箱___________________
|
| | |
|
| | | /// <summary>
|
| | | /// 发送验证码到邮箱
|
| | | /// </summary>
|
| | | private void SendCodeToEmail(BottomClickButton btnNext, string Email)
|
| | | {
|
| | | var sendCodePra = new SendCodePra();
|
| | | sendCodePra.Account = Email;
|
| | |
|
| | | bool falge = UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/RegisterSendVerCode", false, sendCodePra);
|
| | | if (falge == false)
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | //可以开始校验验证码了
|
| | | this.canCheckCode = true;
|
| | | //记录起这个邮箱,防止恶意变更
|
| | | this.newEmail = Email;
|
| | | //控件不能再次按下
|
| | | btnNext.CanClick = false;
|
| | | //?s后重发
|
| | | string repeat = Language.StringByID(R.MyInternationalizationString.RepeatSend1);
|
| | | //有效时间60秒
|
| | | int waitime = 60;
|
| | | btnNext.Text = waitime + "s" + repeat;
|
| | |
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | while (this.Parent != null)
|
| | | {
|
| | | waitime--;
|
| | | System.Threading.Thread.Sleep(1000);
|
| | | if (waitime == 0)
|
| | | {
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | if (btnNext != null)
|
| | | {
|
| | | //获取验证码
|
| | | btnNext.TextID = R.MyInternationalizationString.uGetVerificationCode;
|
| | | //按键可以按下
|
| | | btnNext.CanClick = true;
|
| | | }
|
| | | });
|
| | | break;
|
| | | }
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | if (btnNext != null)
|
| | | {
|
| | | btnNext.Text = waitime + "s" + repeat;
|
| | | }
|
| | | }, ShowErrorMode.NO);
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 校验验证码_________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 验证验证码
|
| | | /// </summary>
|
| | | /// <returns></returns>
|
| | | private bool CheckVerificationCode(string code)
|
| | | {
|
| | | if (this.canCheckCode == false)
|
| | | {
|
| | | //验证码错误,请重新输入
|
| | | this.btnErrorMsg.Visible = true;
|
| | | this.btnErrorMsg.TextID = R.MyInternationalizationString.uVerificationCodeErrorInputAgain;
|
| | | return false;
|
| | | }
|
| | | var checkCodePra = new CheckCodePra();
|
| | | checkCodePra.Code = code;
|
| | | checkCodePra.Account = newEmail;
|
| | |
|
| | | bool flage = UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/ValidatorCode", false, checkCodePra);
|
| | | if (flage == false)
|
| | | {
|
| | | //验证码错误,请重新输入
|
| | | this.btnErrorMsg.Visible = true;
|
| | | this.btnErrorMsg.TextID = R.MyInternationalizationString.uVerificationCodeErrorInputAgain;
|
| | | return false;
|
| | | }
|
| | |
|
| | | //变更邮箱
|
| | | this.SaveNewEmail();
|
| | | return true;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 变更邮箱
|
| | | /// </summary>
|
| | | private void SaveNewEmail()
|
| | | {
|
| | | var pra = new SaveNewEmailPra();
|
| | | pra.Account = this.newEmail;
|
| | |
|
| | | bool flage = UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/BindAccount", false, pra);
|
| | | if (flage == false)
|
| | | {
|
| | | //绑定邮箱失败
|
| | | this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.uBindEmailFail));
|
| | | return;
|
| | | }
|
| | |
|
| | | //成功绑定新邮箱
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uBindEmailSuccess);
|
| | | this.ShowMassage(ShowMsgType.Normal, msg, () =>
|
| | | {
|
| | | //刷新个人信息画面
|
| | | this.RefreshUserInfoForm();
|
| | | });
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 刷新个人信息画面
|
| | | /// </summary>
|
| | | private void RefreshUserInfoForm()
|
| | | {
|
| | | //如果修改的是账号的话,则重新登录
|
| | | if (UserCenterResourse.UserInfo.Email == Shared.Common.Config.Instance.Account)
|
| | | {
|
| | | UserCenterLogic.ReLoginAgain(this.newEmail);
|
| | | return;
|
| | | }
|
| | |
|
| | | UserCenterResourse.UserInfo.Email = this.newEmail;
|
| | | this.CloseForm();
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 一般方法___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 检查邮箱
|
| | | /// </summary>
|
| | | /// <param name="Email"></param>
|
| | | /// <returns></returns>
|
| | | private bool CheckEmail(string Email)
|
| | | {
|
| | | //输入为空
|
| | | if (Email == string.Empty)
|
| | | {
|
| | | this.btnErrorMsg.Visible = true;
|
| | | this.btnErrorMsg.TextID = R.MyInternationalizationString.uPleaseInputNewEmailAddress;
|
| | | return false;
|
| | | }
|
| | |
|
| | | //检测邮箱格式
|
| | | if (HdlCheckLogic.Current.CheckEmail(Email) == false)
|
| | | {
|
| | | this.btnErrorMsg.Visible = true;
|
| | | this.btnErrorMsg.TextID = R.MyInternationalizationString.uThisIsNotEmailType;
|
| | | return false;
|
| | | }
|
| | |
|
| | | return true;
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 结构体_____________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 发送验证码的启动参数
|
| | | /// </summary>
|
| | | private class SendCodePra
|
| | | {
|
| | | /// <summary>
|
| | | /// 用户账号
|
| | | /// </summary>
|
| | | public string Account = string.Empty;
|
| | | /// <summary>
|
| | | /// 公司编号,国内使用手机短信验证码时,此字段填入0,国外手机短信验证码,此字段填入4 |
| | | /// </summary>
|
| | | public int Company = Common.CommonPage.PhoneZoneStr == "86" ? 0 : 4;
|
| | | /// <summary>
|
| | | /// 语言
|
| | | /// </summary>
|
| | | public string Language = Shared.Language.CurrentLanguage;
|
| | | /// <summary>
|
| | | /// 国家地区代码,手机号发送验证码时使用
|
| | | /// </summary>
|
| | | public int AreaCode = 0;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 发送验证码的启动参数
|
| | | /// </summary>
|
| | | private class CheckCodePra
|
| | | {
|
| | | /// <summary>
|
| | | /// 用户账号
|
| | | /// </summary>
|
| | | public string Account = string.Empty;
|
| | | /// <summary>
|
| | | /// 验证码
|
| | | /// </summary>
|
| | | public string Code = "0";
|
| | | /// <summary>
|
| | | /// 语言
|
| | | /// </summary>
|
| | | public string Language = Shared.Language.CurrentLanguage;
|
| | | /// <summary>
|
| | | /// 国家地区代码,手机号发送验证码时使用
|
| | | /// </summary>
|
| | | public int AreaCode = 0;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 保存新邮箱的启动参数
|
| | | /// </summary>
|
| | | private class SaveNewEmailPra
|
| | | {
|
| | | /// <summary>
|
| | | /// 新用户账号
|
| | | /// </summary>
|
| | | public string Account = string.Empty;
|
| | | }
|
| | |
|
| | | #endregion
|
| | | }
|
| | | }
|