From b621c50182f42a095b75fc08584240905e22d944 Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期三, 24 三月 2021 15:24:20 +0800 Subject: [PATCH] 2021-03-24 1.修改时间选择控件不调用系统的时间选择器,实现自定义时间选择器。 2.优化注册和忘记密码页面,增加倒计时和重发按钮功能 --- Crabtree/SmartHome/UI/SimpleControl/Phone/Register/ForgotPassword.cs | 83 +++++++++++++++++++++++++++++++++++++++-- 1 files changed, 78 insertions(+), 5 deletions(-) diff --git a/Crabtree/SmartHome/UI/SimpleControl/Phone/Register/ForgotPassword.cs b/Crabtree/SmartHome/UI/SimpleControl/Phone/Register/ForgotPassword.cs index 4f5c8a7..f34c1b0 100644 --- a/Crabtree/SmartHome/UI/SimpleControl/Phone/Register/ForgotPassword.cs +++ b/Crabtree/SmartHome/UI/SimpleControl/Phone/Register/ForgotPassword.cs @@ -1,5 +1,6 @@ 锘縰sing System; using System.Text.RegularExpressions; +using System.Threading; namespace Shared.SimpleControl.Phone { @@ -160,7 +161,7 @@ /// </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 (() => { @@ -168,8 +169,14 @@ var requestRevertObj = HttpServerRequest.Current.VerificationCodeSend (VerifyType.FIND_PASSWORD, account); if (requestRevertObj.Code.ToUpper () == StateCode.SUCCESS) { Application.RunOnMainThread (() => { - InitSMSView (account, false); - bodyPageView.PageIndex = bodyPageView.ChildrenCount - 1; + + if (isResend) { + //濡傛灉鏄噸鍙戠殑 + StartCountdown (btnResend); + } else { + InitSMSView (account, false); + bodyPageView.PageIndex = bodyPageView.ChildrenCount - 1; + } }); } else { //鎻愮ず閿欒 @@ -271,9 +278,10 @@ 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, @@ -282,6 +290,32 @@ 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), @@ -366,6 +400,45 @@ } + + /// <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 (); + } } -- Gitblit v1.8.0