From 06696e6f225733a60b03eea4a7c6374053d92c1d Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期二, 14 四月 2020 14:15:35 +0800
Subject: [PATCH] 20200414

---
 HDL_ON/UI/UI1-Login/LoginPageBLL.cs |  231 ++++++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 193 insertions(+), 38 deletions(-)

diff --git a/HDL_ON/UI/UI1-Login/LoginPageBLL.cs b/HDL_ON/UI/UI1-Login/LoginPageBLL.cs
index 9653896..70526e5 100644
--- a/HDL_ON/UI/UI1-Login/LoginPageBLL.cs
+++ b/HDL_ON/UI/UI1-Login/LoginPageBLL.cs
@@ -4,6 +4,7 @@
 using System.Collections.Generic;
 using HDL_ON.UI.CSS;
 using Shared;
+using HDL_ON.Entity;
 
 namespace HDL_ON.UI.UI1Login
 {
@@ -32,10 +33,38 @@
         {
             btnGetVerificationCode.MouseUpEventHandler += (sender, e) =>
             {
-                if (btnGetVerificationCode.IsSelected)
+                if (!btnGetVerificationCode.IsSelected)
                 {
                     string phoneNumber = etAccount.Text.Trim();
-                    btnGetVerificationCode.IsSelected = false;
+                    if (string.IsNullOrEmpty(phoneNumber))
+                    {
+                        var tip = new Tip()
+                        {
+                            Text = Language.StringByID(StringId.PlsEntryPhoneNumber),
+                            CloseTime = 3,
+                            Direction = AMPopTipDirection.None
+                        };
+                        tip.Show(bodyView);
+
+                        btnAccountViewBottomLine.BackgroundColor = CSS_Color.AuxiliaryColor2;
+                        btnAccountViewBottomLine.Height = Application.GetRealHeight(2);
+                        return;
+                    }
+                    if (!Regex.IsMatch(account, @"^[1]+\d{10}"))
+                    {
+                        var tip = new Tip()
+                        {
+                            Text = Language.StringByID(StringId.PlsEntryCorrectMobilNeumber),
+                            CloseTime = 3,
+                            Direction = AMPopTipDirection.None
+                        };
+                        tip.Show(bodyView);
+
+                        btnAccountViewBottomLine.BackgroundColor = CSS_Color.AuxiliaryColor2;
+                        btnAccountViewBottomLine.Height = Application.GetRealHeight(2);
+                        return;
+                    }
+                    btnGetVerificationCode.IsSelected = true;
                     btnGetVerificationCode.TextColor = CSS_Color.PromptingColor1;
                     int time = 60;
                     new Thread(() =>
@@ -51,13 +80,73 @@
                         }
                         Application.RunOnMainThread(() =>
                         {
-                            btnGetVerificationCode.IsSelected = true;
+                            btnGetVerificationCode.IsSelected = false;
                             btnGetVerificationCode.TextID = StringId.GetVerificationCode;
                         });
                     })
                     { IsBackground = true }.Start();
-                    //鑾峰彇楠岃瘉鐮�
-                    pm.GetPhoneLoginVerCode(phoneNumber);
+                    new Thread(() =>
+                    {
+                        //鑾峰彇楠岃瘉鐮�
+                        var result = pm.GetPhoneLoginVerCode(phoneNumber);
+                        if (result.StateCode == "SUCCESS")
+                        {
+                        }
+                        //鐧诲綍澶辫触
+                        else
+                        {
+                            Application.RunOnMainThread(() =>
+                            {
+                                btnGetVerificationCode.IsSelected = false;
+                                btnGetVerificationCode.TextID = StringId.GetVerificationCode;
+                            });
+                            string tipStr = "Sever erorr";
+                            switch (result.StateCode.ToUpper())
+                            {
+                                case "USERNAMEORPWDERROR":
+                                    tipStr = Language.StringByID(StringId.LoginFailed_AccountOrPasswordError);
+                                    Application.RunOnMainThread(() =>
+                                    {
+                                        btnPasswordViewBottomLine.BackgroundColor = CSS_Color.AuxiliaryColor2;
+                                        btnPasswordViewBottomLine.Height = Application.GetRealHeight(2);
+                                    });
+                                    break;
+                                case "ACCOUNTNOEXISTS":
+                                    tipStr = Language.StringByID(StringId.ACCOUNTNOEXISTS);
+                                    Application.RunOnMainThread(() =>
+                                    {
+                                        btnAccountViewBottomLine.BackgroundColor = CSS_Color.AuxiliaryColor2;
+                                        btnAccountViewBottomLine.Height = Application.GetRealHeight(2);
+                                    });
+                                    break;
+                                case "SENDFAIL":
+                                    tipStr = Language.StringByID(StringId.FailedToSendVerificationCode);
+                                    Application.RunOnMainThread(() =>
+                                    {
+                                        btnAccountViewBottomLine.BackgroundColor = CSS_Color.AuxiliaryColor2;
+                                        btnAccountViewBottomLine.Height = Application.GetRealHeight(2);
+                                    });
+                                    break;
+                                case "Self:Net_Error":
+                                    tipStr = Language.StringByID(StringId.NetworkAnomaly);
+                                    break;
+                            }
+                            Application.RunOnMainThread(() =>
+                            {
+                                //鎻愮ず鍘熷洜
+                                var tip = new Tip()
+                                {
+
+                                    Text = tipStr,
+                                    CloseTime = 3,
+                                    Direction = AMPopTipDirection.None
+                                };
+                                tip.Show(bodyView);
+                                btnGetVerificationCode.IsSelected = false;
+                            });
+                        }
+                    })
+                    { IsBackground = true }.Start();
                 }
             };
         }
@@ -75,7 +164,7 @@
                 btnEmailLogin.TextSize = CSS_FontSize.TextFontSize;
                 btnPhoneLogin.TextColor = CSS_Color.MainColor;
                 btnPhoneLogin.TextSize = CSS_FontSize.EmphasisFontSize_Secondary;
-                etAccount.PlaceholderText = Language.StringByID(StringId.PlsEntryCorrectMobilNeumber);
+                etAccount.PlaceholderText = Language.StringByID(StringId.PlsEntryPhoneNumber);
                 #endregion
 
                 #region 鍒囨崲鐧诲綍鏂瑰紡鍙婂浘鏍�
@@ -161,6 +250,7 @@
                 {
                     btnSwitchLoginMode.TextID = StringId.PasswordLogin;
                     passwordView.AddChidren(btnGetVerificationCode);
+                    etPassword.PlaceholderText = Language.StringByID(StringId.PlsEntryVerificationCode);
                     btnPasswordIcon.IsSelected = true;
                     if (btnVisiblePassword.Parent != null)
                     {
@@ -181,7 +271,7 @@
         }
 
         /// <summary>
-        /// 鏂囨湰妗嗛�変腑浜嬩欢
+        /// 鏂囨湰妗嗙劍鐐瑰彉鍖栦簨浠�
         /// </summary>
         void LoadPage_SelectionEditText()
         {
@@ -197,6 +287,40 @@
                 {
                     btnAccountViewBottomLine.BackgroundColor = CSS_Color.DividingLineColor;
                     btnAccountViewBottomLine.Height = Application.GetRealHeight(1);
+                    account = etAccount.Text.Trim();
+                    if (account.Length == 0)
+                        return;
+                    if (logintType == 0)
+                    {
+                        if (!Regex.IsMatch(account, @"^[1]+\d{10}"))
+                        {
+                            var tip = new Tip()
+                            {
+                                Text = Language.StringByID(StringId.PlsEntryCorrectMobilNeumber),
+                                CloseTime = 3,
+                                Direction = AMPopTipDirection.None
+                            };
+                            tip.Show(bodyView);
+
+                            btnAccountViewBottomLine.BackgroundColor = CSS_Color.AuxiliaryColor2;
+                            btnAccountViewBottomLine.Height = Application.GetRealHeight(2);
+                        }
+                    }
+                    else
+                    {
+                        if (!Regex.IsMatch(account, "([a-zA-Z0-9_\\.\\-])+\\@(([a-zA-Z0-9\\-])+\\.)+([a-zA-Z0-9]{2,5})+"))
+                        {
+                            var tip = new Tip()
+                            {
+                                Text = Language.StringByID(StringId.PlsEntryCorrectEmailAddress),
+                                CloseTime = 3,
+                                Direction = AMPopTipDirection.None
+                            };
+                            tip.Show(bodyView);
+                            btnAccountViewBottomLine.BackgroundColor = CSS_Color.AuxiliaryColor2;
+                            btnAccountViewBottomLine.Height = Application.GetRealHeight(2);
+                        }
+                    }
                 }
             };
             //褰撶劍鐐瑰湪瀵嗙爜鏂囨湰妗嗘椂锛屾枃鏈搴曠嚎鐐逛寒
@@ -259,7 +383,7 @@
 
                     if (logintType == 0)
                     {
-                        if (!Regex.IsMatch(account, @"^[1]+\d{9}"))
+                        if (!Regex.IsMatch(account, @"^[1]+\d{10}"))
                         {
                             var tip = new Tip()
                             {
@@ -273,7 +397,7 @@
                     }
                     else
                     {
-                        if (!Regex.IsMatch(account, "^[\\w-]+@[\\w-]+\\.(com|net|org|edu|mil|tv|biz|info)$"))
+                        if (!Regex.IsMatch(account, "([a-zA-Z0-9_\\.\\-])+\\@(([a-zA-Z0-9\\-])+\\.)+([a-zA-Z0-9]{2,5})+"))
                         {
                             var tip = new Tip()
                             {
@@ -289,7 +413,7 @@
                     //鍒涘缓鐧诲綍绾跨▼
                     var loginThread = LoadThread_Login();
                     waitPage = new Loading();
-                    new WaitPageMothed().LoadPage_WaitPage(loginThread, bodyView, waitPage);
+                    new PublicAssmebly().LoadPage_WaitPage(loginThread, bodyView, waitPage);
 
                 }
             };
@@ -365,8 +489,17 @@
         bool LoadMethod_Login()
         {
             var result = false;
-            //璋冪敤鐧诲綍鎺ュ彛
-            var loginResult = pm.LoginByPassword(account, password);
+            ResponsePack loginResult;
+            if (logintMode == 0)
+            {
+                //璋冪敤鐧诲綍鎺ュ彛
+                loginResult = pm.LoginByPassword(account, password);
+            }
+            else
+            {
+                //璋冪敤鐧诲綍鎺ュ彛
+                loginResult = pm.LoginValidCode(account, password);
+            }
             if (loginResult.StateCode == "SUCCESS")
             {
                 var loginDataStr = Newtonsoft.Json.Linq.JObject.FromObject(loginResult.ResponseData);
@@ -375,16 +508,23 @@
                 MainPage.LoginUser = new UserInfo
                 {
                     ID = (int)loginDataStr.GetValue("UserID"),
-                    MasterID = (int)loginDataStr.GetValue("MainUserID"),
-                    AccountType = (int)loginDataStr.GetValue("UserType"),
-                    AccountString = account,
-                    Password = password,
-                    LastTime = DateTime.Now,
+                    masterID = (int)loginDataStr.GetValue("MainUserID"),
+                    accountType = (int)loginDataStr.GetValue("UserType"),
+                    accountString = account,
+                    password = password,
+                    lastTime = DateTime.Now,
                     SIP_Account = loginDataStr.GetValue("AllVisionRegisterDevUserNameGuid").ToString(),
+                    userName = loginDataStr.GetValue("Remark").ToString(),
                 };
                 MainPage.LoginUser.SaveUserInfo();
                 MainPage.Log("鐧诲綍鎴愬姛銆�");
                 result = true;
+                //鑾峰彇鐢ㄦ埛淇℃伅
+                new Thread(() =>
+                {
+                    pm.GetUserInfo();
+                })
+                { IsBackground = true }.Start();
             }
             //鐧诲綍澶辫触
             else
@@ -394,6 +534,22 @@
                 {
                     case "USERNAMEORPWDERROR":
                         tipStr = Language.StringByID(StringId.LoginFailed_AccountOrPasswordError);
+                        Application.RunOnMainThread(() =>
+                        {
+                            btnPasswordViewBottomLine.BackgroundColor = CSS_Color.AuxiliaryColor2;
+                            btnPasswordViewBottomLine.Height = Application.GetRealHeight(2);
+                        });
+                        break;
+                    case "ACCOUNTNOEXISTS":
+                        tipStr = Language.StringByID(StringId.ACCOUNTNOEXISTS);
+                        Application.RunOnMainThread(() =>
+                        {
+                            btnAccountViewBottomLine.BackgroundColor = CSS_Color.AuxiliaryColor2;
+                            btnAccountViewBottomLine.Height = Application.GetRealHeight(2);
+                        });
+                        break;
+                    case "NoRecord":
+                        tipStr = Language.StringByID(StringId.PlsGetTheVerificationCode);
                         break;
                     case "Self:Net_Error":
                         tipStr = Language.StringByID(StringId.NetworkAnomaly);
@@ -402,6 +558,7 @@
                 //璐﹀彿鎴栬�呭瘑鐮侀敊璇�
                 Application.RunOnMainThread(() =>
                 {
+                    waitPage.Hide();
                     //鎻愮ず鍘熷洜
                     var tip = new Tip()
                     {
@@ -410,8 +567,6 @@
                         Direction = AMPopTipDirection.None
                     };
                     tip.Show(bodyView);
-                    btnPasswordViewBottomLine.BackgroundColor = CSS_Color.AuxiliaryColor2;
-                    btnPasswordViewBottomLine.Height = Application.GetRealHeight(2);
                 });
             }
             return result;
@@ -434,7 +589,7 @@
                 }
                 else
                 {
-                    MainPage.LoginUser.HomeLists = new List<RegionInfoRes>();
+                    MainPage.LoginUser.regionList = new List<RegionInfoRes>();
                     foreach (var jsonData in dataStr.GetValue("PageData"))
                     {
                         var homeJsonStr = Newtonsoft.Json.Linq.JObject.FromObject(jsonData);
@@ -443,11 +598,12 @@
                             RegionID = homeJsonStr.GetValue("Id").ToString(),
                             RegionName = homeJsonStr.GetValue("RegionName").ToString(),
                             Name = homeJsonStr.GetValue("Name").ToString(),
+                            Address = homeJsonStr.GetValue("Address").ToString(),
                         };
-                        MainPage.LoginUser.HomeLists.Add(home);
+                        MainPage.LoginUser.regionList.Add(home);
                     }
-                    UserConfig.Instance.CurrentRegion = MainPage.LoginUser.HomeLists[0];
-                    UserConfig.Instance.SaveUserConfig();
+                    DB_ResidenceData.residenceData.residecenInfo = MainPage.LoginUser.regionList[0];
+                    DB_ResidenceData.residenceData.SaveResidenceData();
                     MainPage.LoginUser.SaveUserInfo();
                 }
                 result = true;
@@ -485,22 +641,21 @@
             btnRegister.MouseUpEventHandler += (sender, e) =>
             {
                 //鍥炶皟浜嬩欢
-                Action<string> callBackAction = (callBackPar_Action) =>
-                {
-                    Application.RunOnMainThread(() =>
-                    {
-                        try
-                        {
-                            etAccount.Text = callBackPar_Action;
-                        }
-                        catch (Exception ex)
-                        {
-                            MainPage.Log($"login callBackAction : {ex.Message}");
-                        }
-                    });
-                };
+                //Action callBackAction = () =>
+                //{
+                //    Application.RunOnMainThread(() =>
+                //    {
+                //        try
+                //        {
+                //        }
+                //        catch (Exception ex)
+                //        {
+                //            MainPage.Log($"login callBackAction : {ex.Message}");
+                //        }
+                //    });
+                //};
 
-                var registerPage = new RegisterPage(callBackAction);
+                var registerPage = new RegisterPage();
                 registerPage.Show();
                 registerPage.ShowDialog();
             };

--
Gitblit v1.8.0