wxr
2024-09-24 691dbe24f5724f153e07947c7b75bdfea5f0b6d5
HDL_ON/UI/UI1-Login/RegisterPageBLL.cs
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Threading;
using HDL_ON.DAL.Server;
@@ -9,6 +10,9 @@
{
    public partial class RegisterPage
    {
        List<GlobalRegionListRes> serverList;
        /// <summary>
        /// 加载事件列表
        /// </summary>
@@ -197,6 +201,7 @@
                                btnGetVerificationCode_Phone.IsSelected = false;
                                new Tip()
                                {
                                    MaxWidth = Application.GetRealWidth(300),
                                    CloseTime = 1,
                                    Text = Language.StringByID(StringId.PlsEntryCorrectMobilNeumber),
                                    Direction = AMPopTipDirection.None,
@@ -225,6 +230,7 @@
                                btnGetVerificationCode_Mail.IsSelected = false;
                                new Tip()
                                {
                                    MaxWidth = Application.GetRealWidth(300),
                                    CloseTime = 1,
                                    Text = Language.StringByID(StringId.PlsEntryCorrectEmailAddress),
                                    Direction = AMPopTipDirection.None,
@@ -268,6 +274,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 +632,6 @@
            //判断之前是否选择过
            if (OnAppConfig.Instance.GlobalRegion != null && !string.IsNullOrEmpty(OnAppConfig.Instance.GlobalRegion.regionUrl))
            {
                SetServerText();
            }
@@ -653,7 +659,7 @@
            if (isSelectServer == false)
            {
                //请先选择国家/区域
                Utlis.ShowTip(Language.StringByID(StringId.PleaseSelectCountryOrRegion));
                Utlis.ShowTip(Language.StringByID(StringId.PlsSelectServer));
                ShowServerBottomLineState(true);
                return false;
            }
@@ -758,5 +764,83 @@
            }
            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
                {
                    Console.WriteLine("GetCountryByIP");
                    var ddd = JLCountrycode.CountryCodeView.Current.GetCountryByIP();
                    Console.WriteLine(ddd);
                    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")
                                    {
                                        var server = serverList.Find((obj) => obj.regionUrl.Contains("china-gateway"));
                                        if (server != null)
                                        {
                                            OnAppConfig.Instance.GlobalRegion.regionUrl = server.regionUrl;
                                            SetServerText();
                                        }
                                    }
                                    else
                                    {
                                        var server = serverList.Find((obj) => obj.regionUrl.Contains("bahrain-gateway"));
                                        if (server != null)
                                        {
                                            OnAppConfig.Instance.GlobalRegion.regionUrl = server.regionUrl;
                                            SetServerText();
                                        }
                                    }
                                }
                            }
                        });
                    }
                    else
                    {
                        //提示错误
                        IMessageCommon.Current.ShowErrorInfoAlter(revertObj.Code);
                    }
                }
                catch
                {
                }
                finally
                {
                    Application.RunOnMainThread(() =>
                    {
                        if (waitPage != null)
                        {
                            waitPage.RemoveFromParent();
                            waitPage = null;
                        }
                    });
                }
            });
        }
    }
}