From d53e6af2c5f17838fa79659614b15a2a1f383399 Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期五, 31 三月 2023 10:04:58 +0800
Subject: [PATCH] 1
---
Crabtree/SmartHome/UI/SimpleControl/Phone/Register/AccountRegistration.cs | 85 +++++++++++++++++++++++++++++++++++++++---
1 files changed, 79 insertions(+), 6 deletions(-)
diff --git a/Crabtree/SmartHome/UI/SimpleControl/Phone/Register/AccountRegistration.cs b/Crabtree/SmartHome/UI/SimpleControl/Phone/Register/AccountRegistration.cs
index 27137d9..c6686a3 100644
--- a/Crabtree/SmartHome/UI/SimpleControl/Phone/Register/AccountRegistration.cs
+++ b/Crabtree/SmartHome/UI/SimpleControl/Phone/Register/AccountRegistration.cs
@@ -1,5 +1,6 @@
锘縰sing System;
using System.Text.RegularExpressions;
+using System.Threading;
namespace Shared.SimpleControl.Phone
{
@@ -157,7 +158,9 @@
/// </summary>
/// <param name="account">璐﹀彿 閭鎴栬�呮墜鏈哄彿</param>
/// <param name="isPhone">鏄惁鏄墜鏈�</param>
- void SendVerificationCode (string account, bool isPhone = true)
+ /// <param name="isResend"></param>
+ /// <param name="btnResend"></param>
+ 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 (() => {
@@ -165,9 +168,14 @@
var requestRevertObj = HttpServerRequest.Current.VerificationCodeSend (VerifyType.REGISTER_USER, account);
if (requestRevertObj.Code == StateCode.SUCCESS) {
Application.RunOnMainThread (() => {
- // isPhone 鏄惁鏄墜鏈�
- InitSMSView (account, false);
- bodyPageView.PageIndex = bodyPageView.ChildrenCount - 1;
+ if (isResend) {
+ //濡傛灉鏄噸鍙戠殑
+ StartCountdown (btnResend);
+ } else {
+ // isPhone 鏄惁鏄墜鏈�
+ InitSMSView (account, false);
+ bodyPageView.PageIndex = bodyPageView.ChildrenCount - 1;
+ }
});
} else {
//鎻愮ず閿欒
@@ -328,9 +336,12 @@
mobileChencView.AddChidren (btnTitle);
EditText etCode = new EditText () {
- Width = Application.GetRealWidth (500),
+ //Width = Application.GetRealWidth (500),
+ //Height = Application.GetRealWidth (85),
+ //Gravity = Gravity.CenterHorizontal,
+ Width = Application.GetRealWidth (390),
Height = Application.GetRealWidth (85),
- Gravity = Gravity.CenterHorizontal,
+ X = Application.GetRealWidth (70),
Y = btnTitle.Bottom,
BorderWidth = 1,
Radius = 5,
@@ -339,6 +350,33 @@
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 () {
Gravity = Gravity.CenterHorizontal,
@@ -442,6 +480,41 @@
}
+ /// <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 ();
+ }
}
+
}
\ No newline at end of file
--
Gitblit v1.8.0