| | |
| | | using System; |
| | | using System.Text.RegularExpressions; |
| | | using System.Threading; |
| | | |
| | | namespace Shared.SimpleControl.Phone |
| | | { |
| | |
| | | /// </summary> |
| | | /// <param name="account">账号 邮箱或者手机号</param> |
| | | /// <param name="isPhone">是否是手机</param> |
| | | void SendVerificationCode (string account, bool isPhone = true) |
| | | void SendVerificationCode (string account, bool isPhone = true, bool isResend = false, Button btnResend = null) |
| | | { |
| | | MainPage.Loading.Start (Language.StringByID (R.MyInternationalizationString.load)); |
| | | System.Threading.Tasks.Task.Run (() => { |
| | |
| | | var requestRevertObj = HttpServerRequest.Current.VerificationCodeSend (VerifyType.FIND_PASSWORD, account); |
| | | if (requestRevertObj.Code.ToUpper () == StateCode.SUCCESS) { |
| | | Application.RunOnMainThread (() => { |
| | | |
| | | if (isResend) { |
| | | //如果是重发的 |
| | | StartCountdown (btnResend); |
| | | } else { |
| | | InitSMSView (account, false); |
| | | bodyPageView.PageIndex = bodyPageView.ChildrenCount - 1; |
| | | } |
| | | }); |
| | | } else { |
| | | //提示错误 |
| | |
| | | mobileChencView.AddChidren (btnTitle); |
| | | |
| | | EditText etCode = new EditText () { |
| | | Width = Application.GetRealWidth (500), |
| | | Width = Application.GetRealWidth (390), |
| | | Height = Application.GetRealWidth (85), |
| | | Gravity = Gravity.CenterHorizontal, |
| | | //Gravity = Gravity.CenterHorizontal, |
| | | X = Application.GetRealWidth (70), |
| | | Y = btnTitle.Bottom, |
| | | BorderWidth = 1, |
| | | Radius = 5, |
| | |
| | | TextColor = SkinStyle.Current.TextColor1 |
| | | }; |
| | | mobileChencView.AddChidren (etCode); |
| | | |
| | | Button btnResend = new Button () { |
| | | Y = btnTitle.Bottom, |
| | | X = etCode.Right + Application.GetRealWidth (10), |
| | | Width = Application.GetRealWidth (100), |
| | | Height = Application.GetRealWidth (85), |
| | | BackgroundColor = SkinStyle.Current.MainColor, |
| | | SelectedBackgroundColor = SkinStyle.Current.SelectedColor, |
| | | //TextID = R.MyInternationalizationString.Resend, |
| | | Text = "Resend", |
| | | TextColor = SkinStyle.Current.TextColor1, |
| | | Radius = 5, |
| | | BorderColor = SkinStyle.Current.Transparent, |
| | | BorderWidth = 0, |
| | | TextSize = 15, |
| | | TextAlignment = TextAlignment.Center, |
| | | }; |
| | | mobileChencView.AddChidren (btnResend); |
| | | btnResend.MouseDownEventHandler += (sender, e) => { |
| | | btnResend.IsSelected = true; |
| | | }; |
| | | btnResend.MouseUpEventHandler += (sender, e) => { |
| | | btnResend.IsSelected = false; |
| | | Resend (mAccount, btnResend); |
| | | }; |
| | | StartCountdown (btnResend); |
| | | |
| | | Button btnConfirem = new Button () { |
| | | Y = etCode.Bottom + Application.GetRealWidth (50), |
| | |
| | | |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 重发 |
| | | /// </summary> |
| | | void Resend (string account, Button btnResend) |
| | | { |
| | | SendVerificationCode (account, false, true, btnResend); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 开始计时 |
| | | /// </summary> |
| | | /// <param name="btnResend"></param> |
| | | void StartCountdown (Button btnResend) |
| | | { |
| | | if (btnResend == null) return; |
| | | |
| | | btnResend.Enable = false; |
| | | int time = 60; |
| | | |
| | | //2.1获取验证码倒计时 |
| | | new Thread (() => |
| | | { |
| | | while (time > 0) { |
| | | time--; |
| | | Application.RunOnMainThread (() => |
| | | { |
| | | btnResend.Text = time.ToString () + "s"; |
| | | }); |
| | | Thread.Sleep (1000); |
| | | } |
| | | Application.RunOnMainThread (() => |
| | | { |
| | | //回复获取短信按钮事件 |
| | | btnResend.Enable = true; |
| | | btnResend.TextID = R.MyInternationalizationString.Resend; |
| | | }); |
| | | }) { IsBackground = true }.Start (); |
| | | } |
| | | } |
| | | |
| | | |