From acc8caee31c4be90bd38d1af18136b0e84f6fe94 Mon Sep 17 00:00:00 2001
From: wxr <wxr@hdlchina.com.cn>
Date: 星期五, 27 九月 2024 14:01:19 +0800
Subject: [PATCH] Merge branch 'feature/v2.7_迭代' into feature/V2.7_Google

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

diff --git a/HDL_ON/UI/UI1-Login/RegisterPageBLL.cs b/HDL_ON/UI/UI1-Login/RegisterPageBLL.cs
index 4e2b8ce..d055779 100644
--- a/HDL_ON/UI/UI1-Login/RegisterPageBLL.cs
+++ b/HDL_ON/UI/UI1-Login/RegisterPageBLL.cs
@@ -1,14 +1,20 @@
 锘縰sing System;
+using System.Collections.Generic;
+using System.Net.Http;
 using System.Text.RegularExpressions;
 using System.Threading;
 using HDL_ON.DAL.Server;
 using HDL_ON.UI.CSS;
+using Newtonsoft.Json.Linq;
 using Shared;
 
 namespace HDL_ON.UI.UI1Login
 {
     public partial class RegisterPage
     {
+
+        List<GlobalRegionListRes> serverList;
+
         /// <summary>
         /// 鍔犺浇浜嬩欢鍒楄〃
         /// </summary>
@@ -197,6 +203,7 @@
                                 btnGetVerificationCode_Phone.IsSelected = false;
                                 new Tip()
                                 {
+                                    MaxWidth = Application.GetRealWidth(300),
                                     CloseTime = 1,
                                     Text = Language.StringByID(StringId.PlsEntryCorrectMobilNeumber),
                                     Direction = AMPopTipDirection.None,
@@ -225,6 +232,7 @@
                                 btnGetVerificationCode_Mail.IsSelected = false;
                                 new Tip()
                                 {
+                                    MaxWidth = Application.GetRealWidth(300),
                                     CloseTime = 1,
                                     Text = Language.StringByID(StringId.PlsEntryCorrectEmailAddress),
                                     Direction = AMPopTipDirection.None,
@@ -268,6 +276,7 @@
                         HDLCommon.Current.BottomLineShowType(btnPasswordViewBottomLine, BottomLineType.Error);
                         new Tip()
                         {
+                            MaxWidth = Application.GetRealWidth(300),
                             CloseTime = 1,
                             Direction = AMPopTipDirection.None,
                             Text = Language.StringByID(StringId.PlsRegisterPassword)
@@ -625,7 +634,6 @@
             //鍒ゆ柇涔嬪墠鏄惁閫夋嫨杩�
             if (OnAppConfig.Instance.GlobalRegion != null && !string.IsNullOrEmpty(OnAppConfig.Instance.GlobalRegion.regionUrl))
             {
-
                 SetServerText();
             }
 
@@ -653,7 +661,7 @@
             if (isSelectServer == false)
             {
                 //璇峰厛閫夋嫨鍥藉/鍖哄煙
-                Utlis.ShowTip(Language.StringByID(StringId.PleaseSelectCountryOrRegion));
+                Utlis.ShowTip(Language.StringByID(StringId.PlsSelectServer));
                 ShowServerBottomLineState(true);
                 return false;
             }
@@ -758,5 +766,100 @@
             }
             return true;
         }
+
+
+        /// <summary>
+        /// 鑾峰彇鏈嶅姟鍣ㄥ垪琛�
+        /// </summary>
+        void getServerList()
+        {
+            var waitPage = new Loading();
+            bodyView.AddChidren(waitPage);
+            waitPage.Start(Language.StringByID(StringId.PleaseWait));
+
+
+            System.Threading.Tasks.Task.Run(() => {
+                try
+                {
+                    //string country = "CN";
+                    //try
+                    //{
+                    //    using (HttpClient client = new HttpClient())
+                    //    {
+                    //        // 浣跨敤 ipinfo.io 鑾峰彇浣嶇疆淇℃伅
+                    //        HttpResponseMessage response = await client.GetAsync("https://ipinfo.io/json");
+                    //        if (response.IsSuccessStatusCode)
+                    //        {
+                    //            string json = await response.Content.ReadAsStringAsync();
+                    //            JObject jsonObject = JObject.Parse(json);
+                    //            // 浠庤繑鍥炵殑 JSON 涓彁鍙栧浗瀹朵俊鎭�
+                    //            country = jsonObject["country"].ToString();
+                    //        }
+                    //    }
+                    //}
+                    //catch (Exception ex)
+                    //{
+                    //    MainPage.Log("Error",$"Error fetching IP info: {ex.StackTrace}");
+                    //}
+
+                    serverList = new List<GlobalRegionListRes>();
+                    var requestJson = HttpUtil.GetSignRequestJson(new GetRegionListObj() { regionMark = HttpUtil.RegionMark });
+                    var revertObj = HttpUtil.RequestHttpsPost(NewAPI.API_POST_GlobalRegionList, requestJson, HttpUtil.GlobalRequestHttpsHost);
+                    if (revertObj.Code == StateCode.SUCCESS)
+                    {
+                        Application.RunOnMainThread(() =>
+                        {
+                            var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<List<GlobalRegionListRes>>(revertObj.Data.ToString());
+                            if (responseDataObj != null)
+                            {
+                                serverList = responseDataObj;
+                                if (serverList.Count > 0)
+                                {
+                                    if (Language.CurrentLanguage == "Chinese")//if (country == "CN")//
+                                    {
+                                        var server = serverList.Find((obj) => obj.regionUrl.Contains("china-gateway"));
+                                        if (server != null)
+                                        {
+                                            OnAppConfig.Instance.GlobalRegion = server;
+                                            SetServerText();
+                                        }
+                                    }
+                                    else
+                                    {
+                                        var server = serverList.Find((obj) => obj.regionUrl.Contains("bahrain-gateway"));
+                                        if (server != null)
+                                        {
+                                            OnAppConfig.Instance.GlobalRegion = server;
+                                            SetServerText();
+                                        }
+                                    }
+                                }
+                            }
+                        });
+                    }
+                    else
+                    {
+                        //鎻愮ず閿欒
+                        IMessageCommon.Current.ShowErrorInfoAlter(revertObj.Code);
+                    }
+                }
+                catch (Exception ex)
+                {
+                    MainPage.Log("Error", $"鑾峰彇鏈嶅姟鍣ㄥ紓甯革細{ex.StackTrace}");
+                }
+                finally
+                {
+                    Application.RunOnMainThread(() =>
+                    {
+                        if (waitPage != null)
+                        {
+                            waitPage.RemoveFromParent();
+                            waitPage = null;
+                        }
+                    });
+                }
+            });
+
+        }
     }
 }
\ No newline at end of file

--
Gitblit v1.8.0