From a5ba89efa83d0a4afd0d25dbeba5989e4944b5b8 Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期二, 24 十一月 2020 18:57:56 +0800
Subject: [PATCH] 20201124;mqtt代码整理备份

---
 HDL_ON/UI/UI1-Login/RegisterPageBLL.cs |  150 +++++++++++++++++++++++++++++++++++--------------
 1 files changed, 107 insertions(+), 43 deletions(-)

diff --git a/HDL_ON/UI/UI1-Login/RegisterPageBLL.cs b/HDL_ON/UI/UI1-Login/RegisterPageBLL.cs
index 06d12ec..25fd27b 100644
--- a/HDL_ON/UI/UI1-Login/RegisterPageBLL.cs
+++ b/HDL_ON/UI/UI1-Login/RegisterPageBLL.cs
@@ -30,11 +30,11 @@
         {
             etAccount.TextChangeEventHandler = (sender, e) =>
             {
-                Regex reg = new Regex(@"^[1]+\d{10}");
-                var mFalg = reg.Match(etAccount.Text.Trim());
+                //Regex reg = new Regex(@"^[1]+\d{10}");
+                //var mFalg = reg.Match(etAccount.Text.Trim());
                 if (registerType == 0)//鎵嬫満娉ㄥ唽鑾峰彇楠岃瘉鐮佹寜閽敓鏁堟潯浠�
                 {
-                    if (btnGlobalRoaming.Text == "+86" && etAccount.Text.Trim().Length != 11)
+                    if (!Utlis.CheckPhoneNumber(etAccount.Text.Trim(), phoneZoneCode))
                     {
                         btnGetVerificationCode_Phone.IsSelected = false;
                     }
@@ -46,7 +46,7 @@
                 }
                 else//閭娉ㄥ唽鑾峰彇楠岃瘉鐮佹寜閽敓鏁堟潯浠�
                 {
-                    if (!mFalg.Success)
+                    if (!Utlis.CheckEmail(etAccount.Text.Trim()))
                     {
                         btnGetVerificationCode_Mail.IsSelected = false;
                     }
@@ -72,6 +72,7 @@
                 {
                     return;
                 }
+                etAccount.IsNumberKeyboardType = true;
                 etAccount.Text = registerPhone;
                 etPassword.Text = "";
                 etRepeatPassword.Text = "";
@@ -100,6 +101,8 @@
             {
                 if (registerType == 1)
                     return;
+
+                etAccount.IsNumberKeyboardType = false;
                 etAccount.Text = registerEmail;
                 etPassword.Text = "";
                 etRepeatPassword.Text = "";
@@ -148,9 +151,7 @@
                     {
                         if (registerType == 0)
                         {
-                            Regex reg = new Regex(@"^[1]+\d{10}");
-                            var mFalg = reg.Match(etAccount.Text.Trim());
-                            if (!mFalg.Success || (btnGlobalRoaming.Text == "+86" && etAccount.Text.Trim().Length != 11))
+                            if (!Utlis.CheckPhoneNumber(etAccount.Text.Trim(), phoneZoneCode))
                             {
                                 btnAccountViewBottomLine.BackgroundColor = CSS_Color.AuxiliaryColor2;
                                 btnAccountViewBottomLine.Height = Application.GetRealHeight(2);
@@ -179,10 +180,7 @@
                         else if (registerType == 1)
                         {
                             //閭娉ㄥ唽-楠岃瘉閭鏄惁姝g‘
-                            var reg = new Regex("^\\s*([A-Za-z0-9_-]+(\\.\\w+)*@(\\w+\\.)+\\w{2,5})\\s*$");
-                            //Regex.IsMatch(etAccount.Text.Trim(), "([a-zA-Z0-9_\\.\\-])+\\@(([a-zA-Z0-9\\-])+\\.)+([a-zA-Z0-9]{2,5})+");
-                            var mFalg = reg.Match(etAccount.Text.Trim());
-                            if (!mFalg.Success)
+                            if (!Utlis.CheckEmail(etAccount.Text.Trim()))
                             {
                                 btnAccountViewBottomLine.BackgroundColor = CSS_Color.AuxiliaryColor2;
                                 btnAccountViewBottomLine.Height = Application.GetRealHeight(2);
@@ -369,49 +367,115 @@
             {
                 if ((sender as Button).IsSelected)
                 {
-                    (sender as Button).IsSelected = false;
                     string account = etAccount.Text.Trim();
-                    //鐭俊鍙戦�侀棿闅�60s
                     int time = 60;
                     new Thread(() =>
                     {
-                        while (time > 0)
+                        //1.鍏堟鏌ヨ处鍙锋槸鍚︽敞鍐岃繃
+                        var result = pm.GetRegionByAccount(account);
+                        //2.璐﹀彿涓嶅瓨鍦紝鎵嶅厑璁哥户缁敞鍐�
+                        if (result.Code == StateCode.ACCOUNT_NOT_EXIST)
                         {
-                            time--;
+                            //璐﹀彿涓嶅瓨鍦� 鏈敞鍐屽厑璁稿彂閫侀獙璇佺爜娉ㄥ唽
                             Application.RunOnMainThread(() =>
                             {
-                                (sender as Button).Text = time.ToString() + "s";
+                                //鐭俊鍙戦�侀棿闅�60s
+                                (sender as Button).IsSelected = false;
+                             
                             });
-                            Thread.Sleep(1000);
-                        }
-                        Application.RunOnMainThread(() =>
-                        {
-                           //鍥炲鑾峰彇鐭俊鎸夐挳浜嬩欢
-                           (sender as Button).IsSelected = true;
-                            (sender as Button).TextID = StringId.GetVerificationCode;
-                        });
-                    })
-                    { IsBackground = true }.Start();
-                    new Thread(() =>
-                    {
-                        ResponsePackNew resultObj;
-                        // 鑾峰彇楠岃瘉鐮�
-                        if (registerType == 1)//閭
-                        {
-                             resultObj = pm.VerificationCodeSend(VerifyType.REGISTER, account);
-                        }
-                        else
-                        {
-                             resultObj = pm.VerificationCodeSend(VerifyType.REGISTER, account, true, phoneZoneCode);
-                        }
+                            //2.1 寮�濮嬪�掕鏃�
+                            new Thread(() =>
+                            {
+                                while (time > 0)
+                                {
+                                    time--;
+                                    Application.RunOnMainThread(() =>
+                                    {
+                                        (sender as Button).Text = time.ToString() + "s";
+                                    });
+                                    Thread.Sleep(1000);
+                                }
+                                Application.RunOnMainThread(() =>
+                                {
+                                    //鍥炲鑾峰彇鐭俊鎸夐挳浜嬩欢
+                                    (sender as Button).IsSelected = true;
+                                    (sender as Button).TextID = StringId.GetVerificationCode;
+                                });
+                            })
+                            { IsBackground = true }.Start();
 
-                        if (resultObj.Code != HttpUtil.SUCCESS_CODE)
+                            //2.2  鑾峰彇楠岃瘉鐮�
+                            ResponsePackNew resultObj;
+                            if (registerType == 1)//閭
+                            {
+                                resultObj = pm.VerificationCodeSend(VerifyType.REGISTER_USER, account);
+                            }
+                            else
+                            {
+                                resultObj = pm.VerificationCodeSend(VerifyType.REGISTER_USER, account, true, phoneZoneCode);
+                            }
+
+                            if (resultObj.Code != StateCode.SUCCESS)
+                            {
+                                // 鎻愮ず閿欒
+                                IMessageCommon.Current.ShowErrorInfoAlter(resultObj.Code);
+                            }
+
+                        }else if (result.Code.ToUpper() == StateCode.SUCCESS)
                         {
-                           // 鎻愮ず閿欒
-                           IMessageCommon.Current.ShowErrorInfoAlter(NewAPI.API_POST_Verification_Send, resultObj.Code);
+                            //3.鎻愮ず璐﹀彿宸插瓨鍦紝鏃犳硶閲嶅娉ㄥ唽
+                            Utlis.ShowAlertOnMainThread(Language.StringByID(StringId.AccountAlreadyUse));
+                        } else
+                        {
+                            //4.鎻愮ず鍏跺畠寮傚父閿欒
+                            IMessageCommon.Current.ShowErrorInfoAlter(result.Code);
                         }
                     })
                     { IsBackground = true }.Start();
+
+                    //(sender as Button).IsSelected = false;
+                    //string account = etAccount.Text.Trim();
+                    ////鐭俊鍙戦�侀棿闅�60s
+                    //int time = 60;
+                    //new Thread(() =>
+                    //{
+                    //    while (time > 0)
+                    //    {
+                    //        time--;
+                    //        Application.RunOnMainThread(() =>
+                    //        {
+                    //            (sender as Button).Text = time.ToString() + "s";
+                    //        });
+                    //        Thread.Sleep(1000);
+                    //    }
+                    //    Application.RunOnMainThread(() =>
+                    //    {
+                    //       //鍥炲鑾峰彇鐭俊鎸夐挳浜嬩欢
+                    //       (sender as Button).IsSelected = true;
+                    //        (sender as Button).TextID = StringId.GetVerificationCode;
+                    //    });
+                    //})
+                    //{ IsBackground = true }.Start();
+                    //new Thread(() =>
+                    //{
+                    //    ResponsePackNew resultObj;
+                    //    // 鑾峰彇楠岃瘉鐮�
+                    //    if (registerType == 1)//閭
+                    //    {
+                    //         resultObj = pm.VerificationCodeSend(VerifyType.REGISTER_USER, account);
+                    //    }
+                    //    else
+                    //    {
+                    //         resultObj = pm.VerificationCodeSend(VerifyType.REGISTER_USER, account, true, phoneZoneCode);
+                    //    }
+
+                    //    if (resultObj.Code != StateCode.SUCCESS_CODE)
+                    //    {
+                    //       // 鎻愮ず閿欒
+                    //       IMessageCommon.Current.ShowErrorInfoAlter(NewAPI.API_POST_Verification_Send, resultObj.Code);
+                    //    }
+                    //})
+                    //{ IsBackground = true }.Start();
                 }
             };
 
@@ -460,7 +524,7 @@
                     //鏍¢獙楠岃瘉鐮佸苟娉ㄥ唽璐﹀彿
                     var isPhone = registerType == 0;
                     var validateSmsResult = pm.ValidataCodeAndRegister(account, password, verCode, isPhone);
-                    if (validateSmsResult.Code == HttpUtil.SUCCESS_CODE)
+                    if (validateSmsResult.Code == StateCode.SUCCESS)
                     {
                         //娉ㄥ唽鎴愬姛
                         //鎵ц鍥炶皟浜嬩欢
@@ -474,7 +538,7 @@
                     else// 娉ㄥ唽澶辫触
                     {
                         // 鎻愮ず閿欒
-                        IMessageCommon.Current.ShowErrorInfoAlter(NewAPI.API_POST_Member_Register, validateSmsResult.Code);
+                        IMessageCommon.Current.ShowErrorInfoAlter(validateSmsResult.Code);
 
                         //2020-11-13 寰呬慨鏀�
                         //string erorrInfo = "";

--
Gitblit v1.8.0