CrabtreeOn,印度客户定制APP,迁移2.0平台版本
Crabtree/SmartHome/UI/SimpleControl/Phone/Register/AccountRegistration.cs
@@ -1,5 +1,6 @@
using 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 (() => {
                            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 ();
        }
    }
}