New file |
| | |
| | | using System;
|
| | | using System.Collections.Generic;
|
| | | using System.Text;
|
| | |
|
| | | namespace Shared.Phone.UserCenter.Password
|
| | | {
|
| | | /// <summary>
|
| | | /// 忘记账号密码界面
|
| | | /// </summary>
|
| | | public class ForgotAccountPasswordForm : EditorCommonForm
|
| | | {
|
| | | #region ■ 变量声明___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 标记是否能够校验验证码了
|
| | | /// </summary>
|
| | | private bool canCheckCode = false;
|
| | | /// <summary>
|
| | | /// 手机或者邮箱
|
| | | /// </summary>
|
| | | private string strPhoneEmail = string.Empty;
|
| | | /// <summary>
|
| | | /// 错误信息控件
|
| | | /// </summary>
|
| | | private NormalViewControl btnMsgControl = null;
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 初始化_____________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 画面显示(底层会固定调用此方法,借以完成画面创建)
|
| | | /// </summary>
|
| | | public void ShowForm()
|
| | | {
|
| | | //设置头部信息
|
| | | base.SetTitleText(Language.StringByID(R.MyInternationalizationString.ForgotPassword));
|
| | |
|
| | | //初始化中部信息
|
| | | this.InitMiddleFrame();
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 初始化中部信息
|
| | | /// </summary>
|
| | | private void InitMiddleFrame()
|
| | | {
|
| | | //清空bodyFrame
|
| | | this.ClearBodyFrame();
|
| | |
|
| | | var frameBack = new FrameLayout();
|
| | | frameBack.Height = Application.GetRealHeight(323);
|
| | | frameBack.BackgroundColor = UserCenterColor.Current.White;
|
| | | bodyFrameLayout.AddChidren(frameBack);
|
| | |
|
| | | var rowPhone = new FrameRowControl();
|
| | | //右边偏移量->增加宽度
|
| | | rowPhone.RightOffset = -ControlCommonResourse.XXLeft;
|
| | | rowPhone.Y = Application.GetRealHeight(23);
|
| | | rowPhone.Width = this.GetPictrueRealSize(628);
|
| | | bodyFrameLayout.AddChidren(rowPhone);
|
| | | //请输入邮箱或手机号
|
| | | string phoneValue = string.IsNullOrEmpty(UserCenterResourse.UserInfo.Phone) == true ? string.Empty : "+" + UserCenterResourse.UserInfo.AreaCode + " " + UserCenterResourse.UserInfo.Phone;
|
| | | var txtPhone = rowPhone.AddLeftCaption(string.IsNullOrEmpty(phoneValue) == true ? UserCenterResourse.UserInfo.Email : phoneValue, 600);
|
| | | txtPhone.TextColor = UserCenterColor.Current.TextGrayColor2;
|
| | | //底线
|
| | | rowPhone.AddBottomLine();
|
| | | //当前选择的方式
|
| | | this.strPhoneEmail = txtPhone.Text;
|
| | |
|
| | | var rowCode = new FrameRowControl();
|
| | | rowCode.Y = rowPhone.Bottom + Application.GetRealHeight(20);
|
| | | rowCode.Width = this.GetPictrueRealSize(628);
|
| | | bodyFrameLayout.AddChidren(rowCode);
|
| | | //请输入验证码
|
| | | var txtCode = rowCode.AddLeftInput("", 600);
|
| | | txtCode.PlaceholderText = Language.StringByID(R.MyInternationalizationString.uPleaseInputVerificationCode);
|
| | | txtCode.TextChangeEventHandler += this.txtCodeValueChangedEvent;
|
| | |
|
| | | //获取验证码
|
| | | var btnCode = new NormalViewControl(302, 127, true);
|
| | | btnCode.X = rowPhone.Right + Application.GetRealWidth(35);
|
| | | btnCode.Y = Application.GetRealHeight(23);
|
| | | btnCode.RadiusEx = 12;
|
| | | btnCode.TextID = R.MyInternationalizationString.uGetVerificationCode;
|
| | | btnCode.TextColor = UserCenterColor.Current.White;
|
| | | btnCode.BackgroundColor = UserCenterColor.Current.TextOrangeColor;
|
| | | btnCode.TextAlignment = TextAlignment.Center;
|
| | | bodyFrameLayout.AddChidren(btnCode);
|
| | | btnCode.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //发送验证码
|
| | | this.SetVerificationCode(btnCode);
|
| | | };
|
| | |
|
| | | //错误信息控件
|
| | | btnMsgControl = new NormalViewControl(800, 58, true);
|
| | | btnMsgControl.X = ControlCommonResourse.XXLeft;
|
| | | btnMsgControl.Y = rowCode.Bottom + Application.GetRealHeight(46);
|
| | | btnMsgControl.TextColor = 0xfff75858;
|
| | | btnMsgControl.TextID = R.MyInternationalizationString.uVerificationCodeErrorInputAgain;
|
| | | bodyFrameLayout.AddChidren(btnMsgControl);
|
| | | btnMsgControl.Visible = false;
|
| | |
|
| | | if (string.IsNullOrEmpty(UserCenterResourse.UserInfo.Phone) == true
|
| | | || string.IsNullOrEmpty(UserCenterResourse.UserInfo.Email) == true)
|
| | | {
|
| | | rowPhone.UseClickStatu = false;
|
| | | return;
|
| | | }
|
| | |
|
| | | //显示可以切换邮箱->一个可以遮住Body的东西
|
| | | var frameTran = new FrameLayoutStatuControl();
|
| | | frameTran.UseClickStatu = false;
|
| | | frameTran.BackgroundColor = UserCenterColor.Current.Transparent;
|
| | | bodyFrameLayout.AddChidren(frameTran);
|
| | | frameTran.Visible = false;
|
| | | frameTran.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | frameTran.Visible = false;
|
| | | };
|
| | | var frameList = new FrameLayout();
|
| | | frameList.X = ControlCommonResourse.XXLeft - Application.GetRealWidth(17);
|
| | | frameList.Y = rowPhone.Bottom - ControlCommonResourse.BottomLineHeight - 1;
|
| | | frameList.Width = this.GetPictrueRealSize(628);
|
| | | frameList.Height = this.GetPictrueRealSize(176);
|
| | | frameTran.AddChidren(frameList);
|
| | | //动画用
|
| | | var frameAnimate = new FrameLayoutStatuControl();
|
| | | frameAnimate.UseClickStatu = false;
|
| | | frameList.AddChidren(frameAnimate);
|
| | |
|
| | | var btnPic = new PicViewControl(frameList.Width, frameList.Height, false);
|
| | | btnPic.UnSelectedImagePath = "Item/ForgotPswList.png";
|
| | | frameAnimate.AddChidren(btnPic);
|
| | | var btnEmail = new NormalViewControl(450, 58, true);
|
| | | btnEmail.X = this.GetPictrueRealSize(46);
|
| | | btnEmail.Y = this.GetPictrueRealSize(32);
|
| | | btnEmail.TextColor = UserCenterColor.Current.TextGrayColor3;
|
| | | btnEmail.Text = UserCenterResourse.UserInfo.Email;
|
| | | frameAnimate.AddChidren(btnEmail);
|
| | | frameAnimate.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | frameTran.Visible = false;
|
| | | string oldValue = txtPhone.Text;
|
| | | txtPhone.Text = btnEmail.Text;
|
| | | btnEmail.Text = oldValue;
|
| | |
|
| | | //当前选择的方式
|
| | | this.strPhoneEmail = txtPhone.Text;
|
| | | };
|
| | | rowPhone.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | if (frameTran.Visible == false)
|
| | | {
|
| | | frameTran.Visible = true;
|
| | | }
|
| | | };
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 发送验证码_________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 发送验证码
|
| | | /// </summary>
|
| | | /// <param name="btnCode"></param>
|
| | | private async void SetVerificationCode(NormalViewControl btnCode)
|
| | | {
|
| | | string account = this.strPhoneEmail.StartsWith("+") == true ? UserCenterResourse.UserInfo.Phone : UserCenterResourse.UserInfo.Email;
|
| | | var sendCodePra = new SendCodePra();
|
| | | sendCodePra.Account = account;
|
| | | sendCodePra.AreaCode = Convert.ToInt32(UserCenterResourse.UserInfo.AreaCode);
|
| | | bool flage = await UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/ForgetPassword", false, sendCodePra);
|
| | | if (flage == false)
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | //可以开始校验验证码了
|
| | | this.canCheckCode = true;
|
| | | //控件不能再次按下
|
| | | btnCode.CanClick = false;
|
| | | btnCode.BackgroundColor = 0xfffebca9;
|
| | | //?s后重发
|
| | | string repeat = Language.StringByID(R.MyInternationalizationString.RepeatSend1);
|
| | | //有效时间60秒
|
| | | int waitime = 60;
|
| | | btnCode.Text = waitime + "s" + repeat;
|
| | |
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | while (this.Parent != null)
|
| | | {
|
| | | waitime--;
|
| | | System.Threading.Thread.Sleep(1000);
|
| | | if (waitime == 0)
|
| | | {
|
| | | Application.RunOnMainThread(() =>
|
| | | {
|
| | | if (btnCode != null)
|
| | | {
|
| | | //获取验证码
|
| | | btnCode.TextID = R.MyInternationalizationString.uGetVerificationCode;
|
| | | //按键可以按下
|
| | | btnCode.CanClick = true;
|
| | | btnCode.BackgroundColor = UserCenterColor.Current.TextOrangeColor;
|
| | | }
|
| | | });
|
| | | break;
|
| | | }
|
| | | Application.RunOnMainThread(() =>
|
| | | {
|
| | | if (btnCode != null)
|
| | | {
|
| | | btnCode.Text = waitime + "s" + repeat;
|
| | | }
|
| | | });
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 验证码事件_________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 验证码事件
|
| | | /// </summary>
|
| | | /// <param name="control"></param>
|
| | | /// <param name="value"></param>
|
| | | private void txtCodeValueChangedEvent(View control, string value)
|
| | | {
|
| | | if (btnMsgControl.Visible == true)
|
| | | {
|
| | | btnMsgControl.Visible = false;
|
| | | }
|
| | |
|
| | | //验证码长度
|
| | | int CodeLength = 6;
|
| | | if (value.Length < CodeLength)
|
| | | {
|
| | | return;
|
| | | }
|
| | | if (value.Length == CodeLength)
|
| | | {
|
| | | //还不能检测验证码
|
| | | if (this.canCheckCode == false)
|
| | | {
|
| | | btnMsgControl.Visible = true;
|
| | | return;
|
| | | }
|
| | | var txtCode = (TextInputControl)control;
|
| | | //终止事件
|
| | | txtCode.TextChangeEventHandler -= this.txtCodeValueChangedEvent;
|
| | | //验证验证码
|
| | | this.CheckVerificationCode(txtCode, value);
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 校验验证码_________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 验证验证码
|
| | | /// </summary>
|
| | | /// <returns></returns>
|
| | | private async void CheckVerificationCode(TextInputControl txtCode, string code)
|
| | | {
|
| | | string account = this.strPhoneEmail.StartsWith("+") == true ? UserCenterResourse.UserInfo.Phone : UserCenterResourse.UserInfo.Email;
|
| | | var checkCodePra = new CheckCodePra();
|
| | | checkCodePra.Code = code;
|
| | | checkCodePra.Account = account;
|
| | |
|
| | | bool flage = await UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/ValidatorCode", false, checkCodePra);
|
| | | if (flage == false)
|
| | | {
|
| | | //验证码错误,请重新输入
|
| | | this.btnMsgControl.Visible = true;
|
| | | //事件还原
|
| | | txtCode.TextChangeEventHandler += this.txtCodeValueChangedEvent;
|
| | | return;
|
| | | }
|
| | |
|
| | | var from = new ResetAccountPasswordForm();
|
| | | base.AddFromAndRemoveNowForm(from);
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 结构体_____________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 发送验证码的启动参数
|
| | | /// </summary>
|
| | | private class SendCodePra
|
| | | {
|
| | | /// <summary>
|
| | | /// 用户账号
|
| | | /// </summary>
|
| | | public string Account = UserCenterResourse.UserInfo.Phone;
|
| | | /// <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 = UserCenterResourse.UserInfo.Phone;
|
| | | /// <summary>
|
| | | /// 验证码
|
| | | /// </summary>
|
| | | public string Code = "0";
|
| | | /// <summary>
|
| | | /// 语言
|
| | | /// </summary>
|
| | | public string Language = Shared.Language.CurrentLanguage;
|
| | | /// <summary>
|
| | | /// 国家地区代码,手机号发送验证码时使用
|
| | | /// </summary>
|
| | | public int AreaCode = Convert.ToInt32(UserCenterResourse.UserInfo.AreaCode);
|
| | | }
|
| | |
|
| | | #endregion
|
| | | }
|
| | | }
|