using System; using System.Collections.Generic; using System.Text; namespace Shared.Phone.UserCenter.Password { /// /// 验证原手机的画面 /// public class CheckOldPhoneForm : EditorCommonForm { #region ■ 变量声明___________________________ /// /// 错误信息控件 /// private NormalViewControl btnErrorMsg = null; /// /// 标记是否能够校验验证码了 /// private bool canCheckCode = false; #endregion #region ■ 初始化_____________________________ /// /// 画面显示(底层会固定调用此方法,借以完成画面创建) /// public void ShowForm() { //设定标题 base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uEditorPhoneNumber)); //初始化中部控件 this.InitMiddleFrame(); } /// /// 初始化中部控件 /// private void InitMiddleFrame() { //清空bodyFrame this.ClearBodyFrame(); //已绑定手机号 var btnMsg1 = new NormalViewControl(bodyFrameLayout.Width, Application.GetRealHeight(63), false); btnMsg1.Y = Application.GetRealHeight(167); btnMsg1.TextAlignment = TextAlignment.Center; btnMsg1.TextSize = 16; btnMsg1.TextColor = UserCenterColor.Current.TextGrayColor3; btnMsg1.TextID = R.MyInternationalizationString.uHadBindPhoneNumber; bodyFrameLayout.AddChidren(btnMsg1); //手机 var btnPhone = new NormalViewControl(bodyFrameLayout.Width, Application.GetRealHeight(55), false); btnPhone.TextColor = UserCenterColor.Current.TextGrayColor3; btnPhone.TextAlignment = TextAlignment.Center; btnPhone.TextSize = 16; btnPhone.Text = HdlUserCenterResourse.UserInfo.UserEmail; btnPhone.Y = btnMsg1.Bottom + Application.GetRealHeight(12); bodyFrameLayout.AddChidren(btnPhone); if (HdlUserCenterResourse.UserInfo.UserPhone.Length >= 11) { var phone = HdlUserCenterResourse.UserInfo.UserPhone; phone = phone.Substring(0, 3) + "".PadLeft(phone.Length - 7, '*') + phone.Substring(phone.Length - 4, 4); btnPhone.Text = "+" + HdlUserCenterResourse.UserInfo.PhoneAreaCode + " " + phone; } else { //或许这是国外的手机吧 var phone = HdlUserCenterResourse.UserInfo.UserPhone; phone = phone.Substring(0, 3) + "".PadLeft(phone.Length - 5, '*') + phone.Substring(phone.Length - 2, 2); btnPhone.Text = "+" + HdlUserCenterResourse.UserInfo.PhoneAreaCode + " " + phone; } //修改手机号前,请输入验证码确认您的身份 var btnMsg2 = new NormalViewControl(bodyFrameLayout.Width, Application.GetRealHeight(49), false); btnMsg2.Y = btnPhone.Bottom + Application.GetRealHeight(37); btnMsg2.TextAlignment = TextAlignment.Center; btnMsg2.TextSize = 12; btnMsg2.TextColor = UserCenterColor.Current.TextGrayColor1; btnMsg2.TextID = R.MyInternationalizationString.uCheckAuthenticationBeforeEditorPhoneNumber; bodyFrameLayout.AddChidren(btnMsg2); //初始化验证码控件 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 btnNext = new BottomClickButton(688); btnNext.Y = Application.GetRealHeight(792); btnNext.TextID = R.MyInternationalizationString.uGetVerificationCode; bodyFrameLayout.AddChidren(btnNext); btnNext.ButtonClickEvent += (sender, e) => { //清空输入的值 btnCodeControl.ClearInputValue(); //发送验证码到手机 this.SendCodeToPhone(btnNext); }; } #endregion #region ■ 发送验证码到手机___________________ /// /// 发送验证码到手机 /// private void SendCodeToPhone(BottomClickButton btnNext) { var errorMsg = HdlAccountLogic.Current.SendVeriCodeToEmail(HdlUserCenterResourse.UserInfo.UserPhone, VerCodeType.A其他); if (errorMsg != null) { HdlMessageLogic.Current.ShowMassage(ShowMsgType.Tip, errorMsg); return; } //可以开始校验验证码了 this.canCheckCode = true; //控件不能再次按下 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 ■ 校验验证码_________________________ /// /// 验证验证码 /// /// private bool CheckVerificationCode(string code) { if (this.canCheckCode == false) { //验证码错误,请重新输入 this.btnErrorMsg.Visible = true; return false; } var result = HdlAccountLogic.Current.CheckVeriCode(HdlUserCenterResourse.UserInfo.UserPhone, VerCodeType.A其他, code); if (result == false) { //验证码错误,请重新输入 this.btnErrorMsg.Visible = true; return false; } var from = new CheckNewPhoneForm(); base.AddFormAndCloseNowForm(from); return true; } #endregion } }