From 6d73bf6e816570291865674bef8bce8972e4de3f Mon Sep 17 00:00:00 2001
From: xm <1271024303@qq.com>
Date: 星期三, 01 十二月 2021 16:32:57 +0800
Subject: [PATCH] 2021-12-01-01

---
 HDL_ON/UI/UI1-Login/RegisterPage.cs |  467 ++++++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 305 insertions(+), 162 deletions(-)

diff --git a/HDL_ON/UI/UI1-Login/RegisterPage.cs b/HDL_ON/UI/UI1-Login/RegisterPage.cs
index a8bd49a..e6225f9 100644
--- a/HDL_ON/UI/UI1-Login/RegisterPage.cs
+++ b/HDL_ON/UI/UI1-Login/RegisterPage.cs
@@ -27,6 +27,36 @@
         /// 閫夋嫨閭鐧诲綍鎸夐挳
         /// </summary>
         Button btnEmailLogin;
+        #region 鏈嶅姟鍣ㄩ�夋嫨
+        /// <summary>
+        /// 鏈嶅姟鍣ㄥ尯鍩�
+        /// </summary>
+        FrameLayout serverView;
+        /// <summary>
+        /// 鏈嶅姟鍣↖con鎸夐挳
+        /// </summary>
+        Button btnServerIcon;
+        /// <summary>
+        /// 鏈嶅姟鍣ㄦ枃鏈
+        /// </summary>
+        Button btnServerText;
+        ///// <summary>
+        ///// 鏈嶅姟鍣ㄦ枃鏈
+        ///// </summary>
+        //EditText etServer;
+        ///// <summary>
+        ///// 鏈嶅姟鍣ㄥ瓙鍖哄煙閲岄潰鐨勫垎鍓茬嚎1
+        ///// </summary>
+        //Button btnLineVertical_server;
+        /// <summary>
+        ///鏈嶅姟鍣╣o鎸夐挳
+        /// </summary>
+        Button btnServerGo;
+        /// <summary>
+        /// 鏈嶅姟鍣ㄥ瓙鍖哄煙搴曢儴妯嚎
+        /// </summary>
+        Button btnServerBottomLine;
+        #endregion
         /// <summary>
         /// 璐﹀彿瀛愬尯鍩�
         /// </summary>
@@ -119,7 +149,11 @@
         /// <summary>
         /// 鑾峰彇楠岃瘉鐮佹寜閽�
         /// </summary>
-        Button btnGetVerificationCode;
+        Button btnGetVerificationCode_Phone;
+        /// <summary>
+        /// 鑾峰彇楠岃瘉鐮佹寜閽�
+        /// </summary>
+        Button btnGetVerificationCode_Mail;
         /// <summary>
         /// 楠岃瘉鐮佸瓙鍖哄煙搴曢儴鍒嗗壊绾�
         /// </summary>
@@ -132,12 +166,12 @@
         #endregion
 
         #region  灞�閮ㄥ彉閲忓垪琛�
-        /// <summary>
-        /// 璐﹀彿绫诲瀷
-        /// 0:鎵嬫満
-        /// 1:閭
-        /// </summary>
-        int accountType = 0;
+        ///// <summary>
+        ///// 璐﹀彿绫诲瀷
+        ///// 0:鎵嬫満
+        ///// 1:閭
+        ///// </summary>
+        //int accountType = 0;
         /// <summary>
         /// 鎵嬫満鍙风爜鏄惁鏈夋晥
         /// </summary>
@@ -159,15 +193,49 @@
         /// 0:鎵嬫満
         /// 1:閭
         /// </summary>
-        int registerType;
+        int registerType = 0;
+        /// <summary>
+        /// 鎵嬫満鍖哄彿
+        /// </summary>
+        string phoneZoneCode = "86";
+        /// <summary>
+        /// 鏄惁閫夋嫨杩囨湇鍔″櫒
+        /// </summary>
+        bool isSelectServer;
+
+        string registerPhone;
+        string registerEmail;
+        /// <summary>
+        /// 鏄惁鐐瑰嚮浜嗚繑鍥烇紝鐢ㄤ簬灞忚斀EditText澶卞幓鐒︾偣妫�娴嬩簨浠�
+        /// </summary>
+        bool isHitBack;
         #endregion
-        public RegisterPage()
+
+        /// <summary>
+        /// 鍥炶皟浜嬩欢
+        /// 璐﹀彿锛屽瘑鐮侊紝鏄惁鎵嬫満
+        /// account锛宲assword锛宨sPhone
+        /// </summary>
+        Action<string, string, bool> AutoLoginAction;
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="autoLoginAction">娉ㄥ唽鎴愬姛鍥炶皟浜嬩欢</param>
+        public RegisterPage(Action<string, string, bool> autoLoginAction)
         {
+            AutoLoginAction = autoLoginAction;
+
             bodyView = new FrameLayout()
             {
-                BackgroundColor = CSS_Color.BackgroundColor,
+                BackgroundColor = CSS_Color.MainBackgroundColor,
             };
             AddChidren(bodyView);
+
+            //2020-12-22 澧炲姞鐐瑰嚮闅愯棌閿洏浜嬩欢
+            bodyView.MouseDownEventHandler += (sender, e) => {
+                Application.HideSoftInput();
+            };
 
             pm = new HttpServerRequest();
         }
@@ -185,7 +253,14 @@
 
         public void ShowDialog()
         {
-            new TopViewDiv(this, bodyView, Language.StringByID(StringId.Register)).LoadTopView();
+            Action backAction = () =>
+            {
+                isHitBack = true;
+                //2020-12-22 澧炲姞鐐瑰嚮闅愯棌閿洏浜嬩欢
+                Application.HideSoftInput();
+            };
+
+            new TopViewDiv(this, bodyView, Language.StringByID(StringId.Register)).LoadTopView(backAction);
             //new PublicAssmebly().LoadTopView(this, bodyView, Language.StringByID(StringId.Register));
 
             #region 娉ㄥ唽鏂瑰紡閫夋嫨
@@ -195,7 +270,7 @@
                 Y = Application.GetRealHeight(112),
                 Width = Application.GetRealWidth(120),
                 Height = Application.GetRealHeight(40),
-                TextID = StringId.LoginByPhone,
+                TextID = StringId.RegisterByPhone,
                 TextColor = CSS_Color.MainColor,
                 TextAlignment = TextAlignment.CenterLeft,
                 TextSize = CSS_FontSize.EmphasisFontSize_Secondary,
@@ -208,19 +283,79 @@
                 Y = Application.GetRealHeight(112),
                 Width = Application.GetRealWidth(100),
                 Height = Application.GetRealHeight(40),
-                TextID = StringId.LoginByEmail,
+                TextID = StringId.RegisterByEmail,
                 TextColor = CSS_Color.PromptingColor1,
                 TextAlignment = TextAlignment.Center,
                 TextSize = CSS_FontSize.TextFontSize,
             };
             bodyView.AddChidren(btnEmailLogin);
+            if(Language.CurrentLanguage!= "Chinese")
+            {
+                btnPhoneLogin.Width = Application.GetRealWidth(180);
+                btnEmailLogin.Width = Application.GetRealWidth(180);
+            }
             #endregion
 
+            #region 鏈嶅姟鍣ㄩ�夋嫨
+            serverView = new FrameLayout()
+            {
+                X = Application.GetRealWidth(28),
+                Y = Application.GetRealHeight(167),
+                Width = Application.GetRealWidth(319),
+                Height = Application.GetRealHeight(44),
+            };
+            bodyView.AddChidren(serverView);
+
+            btnServerIcon = new Button()
+            {
+                X = Application.GetRealWidth(9),
+                Gravity = Gravity.CenterVertical,
+                Width = Application.GetMinRealAverage(20),
+                Height = Application.GetMinRealAverage(20),
+                UnSelectedImagePath = "LoginIcon/Server.png",
+
+            };
+            serverView.AddChidren(btnServerIcon);
+
+            btnServerText = new Button()
+            {
+                X = Application.GetRealWidth(49),
+                Width = Application.GetRealWidth(319 - 78),
+                TextAlignment = TextAlignment.CenterLeft,
+                TextColor = CSS_Color.PromptingColor1,
+                TextSize = CSS_FontSize.TextFontSize,
+                TextID = StringId.PleaseSelectCountryOrRegion,
+            };
+            serverView.AddChidren(btnServerText);
+
+            #region 瀵嗙爜鐧诲綍-鎺т欢鍔犺浇
+            btnServerGo = new Button()
+            {
+                X = Application.GetRealWidth(303),
+                Gravity = Gravity.CenterVertical,
+                Width = Application.GetMinRealAverage(16),
+                Height = Application.GetMinRealAverage(16),
+                UnSelectedImagePath = "Public/Right.png",
+            };
+            serverView.AddChidren(btnServerGo);
+
+            #endregion
+            btnServerBottomLine = new Button()
+            {
+                Y = Application.GetRealHeight(42),
+                BackgroundColor = CSS_Color.DividingLineColor,
+                SelectedBackgroundColor = CSS_Color.MainColor,
+                Height = Application.GetRealHeight(1),
+            };
+            serverView.AddChidren(btnServerBottomLine);
+            #endregion
+
+            int topPadding = Application.GetRealHeight(12);
             #region 璐﹀彿濉啓
             accountView = new FrameLayout()
             {
                 X = Application.GetRealWidth(28),
-                Y = Application.GetRealHeight(167),
+                Y = serverView.Bottom + topPadding,
                 Width = Application.GetRealWidth(319),
                 Height = Application.GetRealHeight(44),
             };
@@ -232,10 +367,23 @@
                 X = Application.GetRealWidth(9),
                 TextAlignment = TextAlignment.CenterLeft,
                 TextColor = CSS_Color.FirstLevelTitleColor,
-                Text = "+86",
+                Text = "+" + phoneZoneCode,
                 TextSize = CSS_FontSize.TextFontSize,
             };
-            if (accountType == 0)
+
+            //璺宠浆鍥藉鍖哄彿閫夋嫨鐣岄潰
+            EventHandler<MouseEventArgs> eHandler = (sender, e) => {
+                JLCountrycode.CountryCodeView.Current.Show((countryName, code) => {
+                    if (!string.IsNullOrEmpty(code))
+                    {
+                        phoneZoneCode = code;
+                        btnGlobalRoaming.Text = "+" + phoneZoneCode;
+                    }
+                });
+            };
+            btnGlobalRoaming.MouseUpEventHandler += eHandler;
+
+            if (registerType == 0)
             {
                 accountView.AddChidren(btnGlobalRoaming);
             }
@@ -259,6 +407,7 @@
                 TextSize = CSS_FontSize.TextFontSize,
                 PlaceholderTextColor = CSS_Color.PromptingColor1,
                 PlaceholderText = Language.StringByID(StringId.PlsEntryPhoneNumber),
+                IsNumberKeyboardType = true
             };
             accountView.AddChidren(etAccount);
 
@@ -278,7 +427,7 @@
                 Height = Application.GetMinRealAverage(20),
                 UnSelectedImagePath = "LoginIcon/AccountIcon.png",
             };
-            if (accountType == 1)
+            if (registerType == 1)
             {
                 accountView.AddChidren(btnAccountIcon);
             }
@@ -288,7 +437,7 @@
             passwordView = new FrameLayout()
             {
                 X = Application.GetRealWidth(28),
-                Y = Application.GetRealHeight(223),
+                Y = accountView.Bottom + topPadding,
                 Width = Application.GetRealWidth(319),
                 Height = Application.GetRealHeight(44),
             };
@@ -354,7 +503,7 @@
             repeatPasswordView = new FrameLayout()
             {
                 X = Application.GetRealWidth(28),
-                Y = Application.GetRealHeight(279),
+                Y = passwordView.Bottom + topPadding,
                 Width = Application.GetRealWidth(319),
                 Height = Application.GetRealHeight(44),
             };
@@ -422,7 +571,8 @@
             verificationCodeView = new FrameLayout()
             {
                 X = Application.GetRealWidth(28),
-                Y = Application.GetRealHeight(335),
+                Y = repeatPasswordView.Bottom + topPadding,
+                //Y = Application.GetRealHeight(335),
                 Width = Application.GetRealWidth(319),
                 Height = Application.GetRealHeight(44),
             };
@@ -457,10 +607,11 @@
                 TextSize = CSS_FontSize.TextFontSize,
                 PlaceholderTextColor = CSS_Color.PromptingColor1,
                 PlaceholderText = Language.StringByID(StringId.PlsEntryVerificationCode),
+                IsNumberKeyboardType = true
             };
             verificationCodeView.AddChidren(etVerificationCode);
 
-            btnGetVerificationCode = new Button()
+            btnGetVerificationCode_Phone = new Button()
             {
                 X = Application.GetRealWidth(219),
                 Width = Application.GetRealWidth(100),
@@ -470,7 +621,20 @@
                 TextAlignment = TextAlignment.CenterRight,
                 TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
             };
-            verificationCodeView.AddChidren(btnGetVerificationCode);
+            verificationCodeView.AddChidren(btnGetVerificationCode_Phone);
+
+            btnGetVerificationCode_Mail = new Button()
+            {
+                X = Application.GetRealWidth(219),
+                Width = Application.GetRealWidth(100),
+                TextID = StringId.GetVerificationCode,
+                SelectedTextColor = CSS_Color.MainColor,
+                TextColor = CSS_Color.PromptingColor1,
+                TextAlignment = TextAlignment.CenterRight,
+                TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
+                Visible = false
+            };
+            verificationCodeView.AddChidren(btnGetVerificationCode_Mail);
 
             btnVerificationCodeViewBottomLine = new Button()
             {
@@ -486,10 +650,11 @@
             btnRegister = new Button()
             {
                 Gravity = Gravity.CenterHorizontal,
-                Y = Application.GetRealHeight(421),
+                Y = verificationCodeView.Bottom + Application.GetRealHeight(42),
+                //Y = Application.GetRealHeight(421),
                 Width = Application.GetRealWidth(220),
-                Height = Application.GetRealHeight(44),
-                Radius = (uint)Application.GetRealHeight(22),
+                Height = Application.GetRealWidth(44),
+                Radius = (uint)Application.GetRealWidth(22),
                 SelectedBackgroundColor = CSS_Color.MainColor,
                 BackgroundColor = CSS_Color.PromptingColor1,
                 TextID = StringId.Register,
@@ -580,152 +745,130 @@
                 Thread.Sleep(1500);
                 Application.RunOnMainThread(() =>
                 {
-                    //鍒涘缓鐧诲綍绾跨▼
-                    var loginThread = LoadThread_Login(account, password);
-                    waitPage = new Loading();
-                    new PublicAssmebly().LoadPage_WaitPage(loginThread, bodyView, waitPage);
+                    ////鍒涘缓鐧诲綍绾跨▼
+                    //var loginThread = LoadThread_Login(account, password);
+                    //waitPage = new Loading();
+                    //new PublicAssmebly().LoadPage_WaitPage(loginThread, bodyView, waitPage);
+                    dialog.Close();
+
+                    var isPhone = registerType == 0;
+                    AutoLoginAction?.Invoke(account, password, isPhone);
                 });
             })
             { IsBackground = true }.Start();
         }
 
-        #region 鐧诲綍绾跨▼閮ㄥ垎
-        /// <summary>
-        /// 鍔犺浇鐧诲綍绾跨▼
-        /// </summary>
-        Thread LoadThread_Login(string account,string password)
-        {
-            var loginThread = new Thread(() =>
-            {
-                try
-                {
-                    //鐧诲綍
-                    var loginResult = LoadMethod_Login(account,password);
-                    if (loginResult)
-                    {
-                        //鑾峰彇浣忓畢淇℃伅
-                        var getResidencesResult = LoadMethod_GetResidences();
-                        if (getResidencesResult)
-                        {
-                            /*
-                             * Wait : 鎺ㄩ�佹敞鍐�
-                             */
+        //#region 鐧诲綍绾跨▼閮ㄥ垎
+        ///// <summary>
+        ///// 鍔犺浇鐧诲綍绾跨▼
+        ///// </summary>
+        //Thread LoadThread_Login(string account,string password)
+        //{
+        //    var loginThread = new Thread(() =>
+        //    {
+        //        try
+        //        {
+        //            //鐧诲綍
+        //            var loginResult = LoadMethod_Login(account,password);
+        //            if (loginResult)
+        //            {
+        //                //鑾峰彇浣忓畢淇℃伅
+        //                var getResidencesResult = LoadMethod_GetResidences();
+        //                if (getResidencesResult)
+        //                {
+        //                    /*
+        //                     * Wait : 鎺ㄩ�佹敞鍐�
+        //                     */
 
-                            Application.RunOnMainThread(() =>
-                            {
-                                waitPage.RemoveFromParent();
-                                waitPage = null;
+        //                    Application.RunOnMainThread(() =>
+        //                    {
+        //                        waitPage.RemoveFromParent();
+        //                        waitPage = null;
 
-                                //璺宠浆椤甸潰----
-                                MainPage.GoUserPage();
-                            });
-                        }
-                    }
-                }
-                catch (Exception ex)
-                {
-                    MainPage.Log($"LoginPage : {ex.Message}");
-                }
-            })
-            { IsBackground = true };
-            return loginThread;
-        }
+        //                        //璺宠浆椤甸潰----
+        //                        MainPage.GoUserPage();
+        //                    });
+        //                }
+        //            }
+        //        }
+        //        catch (Exception ex)
+        //        {
+        //            MainPage.Log($"LoginPage : {ex.Message}");
+        //        }
+        //    })
+        //    { IsBackground = true };
+        //    return loginThread;
+        //}
 
-        /// <summary>
-        /// 璋冪敤鐧诲綍鎺ュ彛鐧诲綍
-        /// </summary>
-        bool LoadMethod_Login(string account, string password)
-        {
-            var result = false;
-            //璋冪敤鐧诲綍鎺ュ彛
-            var loginResult = pm.LoginByPassword(account, password);
-            if (loginResult.StateCode.ToUpper() == "SUCCESS")
-            {
-                var loginDataStr = Newtonsoft.Json.Linq.JObject.FromObject(loginResult.ResponseData);
+        ///// <summary>
+        ///// 璋冪敤鐧诲綍鎺ュ彛鐧诲綍
+        ///// </summary>
+        //bool LoadMethod_Login(string account, string password)
+        //{
+        //    var result = false;
+        //    //璋冪敤鐧诲綍鎺ュ彛
+        //    var loginResult = pm.LoginByPassword(account, password);
+        //    if (loginResult.Code == StateCode.SUCCESS)
+        //    {
+        //        var revertData = Newtonsoft.Json.JsonConvert.DeserializeObject<UserLoginRes>(loginResult.Data.ToString());
+        //        // UserInfo.Current = new UserInfo
+        //        //{
+        //        //    userType = revertData.userType,
+        //        //    accountString = account,
+        //        //    password = password,
+        //        //    lastTime = DateTime.Now,
+        //        //    ID = revertData.userId,
+        //        //    loginTokenString = revertData.headerPrefix + revertData.accessToken,
+        //        //    refreshToken = revertData.refreshToken,
+        //        //    userName = revertData.name
+        //        //};
+        //        UserInfo.Current.userType = revertData.userType;
+        //        UserInfo.Current.AccountString = account;
+        //        //UserInfo.Current.password = password;
+        //        UserInfo.Current.LastTime = DateTime.Now;
+        //        UserInfo.Current.ID = revertData.userId;
+        //        UserInfo.Current.LoginTokenString = revertData.headerPrefix + revertData.accessToken;
+        //        UserInfo.Current.RefreshToken = revertData.refreshToken;
+        //        UserInfo.Current.userName = revertData.name;
 
-                //璁板綍鐢ㄦ埛鏁版嵁
-                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,
-                    SIP_Account = loginDataStr.GetValue("AllVisionRegisterDevUserNameGuid").ToString(),
-                    userName = loginDataStr.GetValue("Remark").ToString(),
-                };
-                MainPage.LoginUser.SaveUserInfo();
-                MainPage.Log("鐧诲綍鎴愬姛銆�");
-                result = true;
+        //        UserInfo.Current.SaveUserInfo();
+        //        MainPage.Log("鐧诲綍鎴愬姛銆�");
+        //        result = true;
+        //    }
+        //    else
+        //    {
+        //        //鐧诲綍澶辫触
+        //        IMessageCommon.Current.ShowErrorInfoAlter(loginResult.Code);
+        //        Application.RunOnMainThread(() =>
+        //        {
+        //            btnPasswordViewBottomLine.BackgroundColor = CSS_Color.AuxiliaryColor2;
+        //            btnPasswordViewBottomLine.Height = Application.GetRealHeight(2);
+        //        });
+        //    }
+        //    return result;
+        //}
 
-
-            }
-            //鐧诲綍澶辫触
-            else
-            {
-                string tipStr = "Sever erorr";
-                switch (loginResult.StateCode)
-                {
-                    case "USERNAMEORPWDERROR":
-                        tipStr = Language.StringByID(StringId.LoginFailed_AccountOrPasswordError);
-                        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);
-                    btnPasswordViewBottomLine.BackgroundColor = CSS_Color.AuxiliaryColor2;
-                    btnPasswordViewBottomLine.Height = Application.GetRealHeight(2);
-                });
-            }
-            return result;
-        }
-
-        /// <summary>
-        /// 鑾峰彇浣忓畢鍒楄〃
-        /// </summary>
-        bool LoadMethod_GetResidences()
-        {
-            var result = false;
-            var responsePack = pm.GetHomePager();
-            if (responsePack == "Success")
-            {
-            }
-            else
-            {
-                var tipStr = "Server erorr";
-                switch (responsePack)
-                {
-                    case "NoLogin":
-                        tipStr = Language.StringByID(StringId.InvalidLoginCertificate);
-                        break;
-                }
-                Application.RunOnMainThread(() =>
-                {
-                    //鎻愮ず鍘熷洜
-                    var tip = new Tip()
-                    {
-                        Text = tipStr,
-                        CloseTime = 3,
-                        Direction = AMPopTipDirection.None
-                    };
-                    tip.Show(bodyView);
-                });
-
-            }
-            return result;
-        }
-        #endregion
+        ///// <summary>
+        ///// 鑾峰彇浣忓畢鍒楄〃
+        ///// </summary>
+        //bool LoadMethod_GetResidences()
+        //{
+        //    var result = false;
+        //    var responsePack = pm.GetHomePager();
+        //    if (responsePack == StateCode.SUCCESS)
+        //    {
+        //        //2020-11-13 寰呯‘璁わ紝娌℃湁浣忓畢锛屼笉绠楃櫥褰曟垚鍔�
+        //        if (UserInfo.Current.regionList != null && UserInfo.Current.regionList.Count > 0)
+        //        {
+        //            result = true;
+        //        }
+        //    }
+        //    else
+        //    {
+        //        IMessageCommon.Current.ShowErrorInfoAlter(responsePack);
+        //    }
+        //    return result;
+        //}
+        //#endregion
     }
 }
\ No newline at end of file

--
Gitblit v1.8.0