wxr
2024-09-27 acc8caee31c4be90bd38d1af18136b0e84f6fe94
HDL_ON/UI/UI1-Login/LoginPageBLL.cs
@@ -42,7 +42,6 @@
                    OnAppConfig.Instance.GlobalRegion = mGlobalRegionListObj;
                    OnAppConfig.Instance.SaveConfig();
                }
                OnAppConfig.Instance.RequestHttpsHost = @"https://bahrain-gateway.hdlcontrol.com";
            }
            catch { }
        }
@@ -61,6 +60,7 @@
                    {
                        var tip = new Tip()
                        {
                            MaxWidth = Application.GetRealWidth(300),
                            Text = Language.StringByID(StringId.PlsEntryPhoneNumber),
                            CloseTime = 1,
                            Direction = AMPopTipDirection.None
@@ -75,6 +75,7 @@
                    {
                        var tip = new Tip()
                        {
                            MaxWidth = Application.GetRealWidth(300),
                            Text = Language.StringByID(StringId.PlsEntryCorrectMobilNeumber),
                            CloseTime = 1,
                            Direction = AMPopTipDirection.None
@@ -85,6 +86,9 @@
                        btnAccountViewBottomLine.Height = Application.GetRealHeight(2);
                        return;
                    }
#if __IOS__
                    etPassword.Foucs = true;
#endif
                    //加载Loading效果
                    var waitPage = new Loading();
                    bodyView.AddChidren(waitPage);
@@ -226,6 +230,9 @@
                    }
                    //验证码不需要隐藏
                    etPassword.SecureTextEntry = false;
#if __IOS__
                    etPassword.SetTextContentTypeToOneTimeCode();
#endif
                }
                #endregion
            }
@@ -314,6 +321,7 @@
                //}
                //隐藏密码
                etPassword.SecureTextEntry = true;
                //etPassword.IsNumberKeyboardType = false;
            }
            //验证码登录
            else if (logintMode == 1)
@@ -341,6 +349,9 @@
                }
                //验证码不需要隐藏
                etPassword.SecureTextEntry = false;
                etPassword.Text = smsCode;
                //etPassword.IsNumberKeyboardType = true;
            }
        }
@@ -391,6 +402,7 @@
                        {
                            var tip = new Tip()
                            {
                                MaxWidth = Application.GetRealWidth(300),
                                Text = Language.StringByID(StringId.PlsEntryCorrectMobilNeumber),
                                CloseTime = 1,
                                Direction = AMPopTipDirection.None
@@ -414,6 +426,7 @@
                        {
                            var tip = new Tip()
                            {
                                MaxWidth = Application.GetRealWidth(300),
                                Text = Language.StringByID(StringId.PlsEntryCorrectEmailAddress),
                                CloseTime = 1,
                                Direction = AMPopTipDirection.None
@@ -432,9 +445,27 @@
                {
                    btnPasswordViewBottomLine.BackgroundColor = CSS_Color.MainColor;
                    btnPasswordViewBottomLine.Height = Application.GetRealHeight(2);
#if __IOS__
      new Thread(() => {
                            for(var i = 0; i < 10; i++)
                            {
                                Application.RunOnMainThread(() =>
                                {
                                    this.Y = 0-Application.GetRealHeight(10 * i);
                                });
                                Thread.Sleep(10);
                            }
                        }) { IsBackground = true }.Start();
                    var sst = etPassword.MyTextContentType;
                    Console.WriteLine(sst);
                    etPassword.SetTextContentTypeToOneTimeCode();
#endif
                }
                else
                {
                    this.Y = 0;
                    btnPasswordViewBottomLine.BackgroundColor = CSS_Color.DividingLineColor;
                    btnPasswordViewBottomLine.Height = Application.GetRealHeight(1);
                }
@@ -449,12 +480,8 @@
            etPassword.EditorEnterAction += (obj) =>
            {
                Application.HideSoftInput();
                LoginEvent();
            };
            etPassword.MouseUpEventHandler = (sender, e) =>
            {
                etPassword.Foucs = true;
            };
        }
        /// <summary>
@@ -483,48 +510,7 @@
        {
            btnLogin.MouseUpEventHandler += (sender, e) =>
            {
                if (btnLogin.IsSelected)
                {
                    //判断是否同意了隐私政策
                    if (CheckPrivacyPolicy() == false) return;
                    account = etAccount.Text.Trim();
                    password = etPassword.Text.Trim();
                    if (loginType == 0)
                    {
                        if (!Utlis.CheckPhoneNumber(account, phoneZoneCode))
                        {
                            var tip = new Tip()
                            {
                                Text = Language.StringByID(StringId.PlsEntryCorrectMobilNeumber),
                                CloseTime = 1,
                                Direction = AMPopTipDirection.None
                            };
                            tip.Show(bodyView);
                            return;
                        }
                    }
                    else
                    {
                        if (!Utlis.CheckEmail(account))
                        {
                            var tip = new Tip()
                            {
                                Text = Language.StringByID(StringId.PlsEntryCorrectEmailAddress),
                                CloseTime = 1,
                                Direction = AMPopTipDirection.None
                            };
                            tip.Show(bodyView);
                            return;
                        }
                    }
                    //创建登录线程
                    var loginThread = LoadThread_Login();
                    waitPage = new Loading();
                    new PublicAssmebly().LoadPage_WaitPage(loginThread, bodyView, waitPage);
                }
                LoginEvent();
            };
            #region 当账号密码都输入时,才能点击登录按钮
            etAccount.TextChangeEventHandler = (sender, e) =>
@@ -562,7 +548,58 @@
            };
            #endregion
        }
        /// <summary>
        /// 登录事件
        /// </summary>
        void LoginEvent()
        {
            if (btnLogin.IsSelected)
            {
                //判断是否同意了隐私政策
                if (CheckPrivacyPolicy() == false)
                {
                    Application.HideSoftInput();
                    return;
                }
                account = etAccount.Text.Trim();
                password = etPassword.Text.Trim();
                if (loginType == 0)
                {
                    if (!Utlis.CheckPhoneNumber(account, phoneZoneCode))
                    {
                        var tip = new Tip()
                        {
                            MaxWidth = Application.GetRealWidth(300),
                            Text = Language.StringByID(StringId.PlsEntryCorrectMobilNeumber),
                            CloseTime = 1,
                            Direction = AMPopTipDirection.None
                        };
                        tip.Show(bodyView);
                        return;
                    }
                }
                else
                {
                    if (!Utlis.CheckEmail(account))
                    {
                        var tip = new Tip()
                        {
                            Text = Language.StringByID(StringId.PlsEntryCorrectEmailAddress),
                            CloseTime = 1,
                            Direction = AMPopTipDirection.None
                        };
                        tip.Show(bodyView);
                        return;
                    }
                }
                //创建登录线程
                var loginThread = LoadThread_Login();
                waitPage = new Loading();
                new PublicAssmebly().LoadPage_WaitPage(loginThread, bodyView, waitPage);
            }
        }
        /// <summary>
        /// 加载登录线程
        /// </summary>
@@ -600,6 +637,7 @@
                            {
                                //跳转页面----
                                MainPage.GoUserPage(true);
                                this.RemoveFromParent();
                                return;
                            }
                        });
@@ -610,46 +648,20 @@
                        var getResidencesResult = LoadMethod_GetResidences();
                        if (getResidencesResult)
                        {
                            /*
                             * Wait : 推送注册
                             */
                            /*
                             * 查看本地是否存在数据
                             * 存在则导出
                             */
                            //var isExis = FileUtils.IsExisFolder(DB_ResidenceData.residenceData.CurReginID);
                            //if (isExis)
                            //{
                            //    FileUtils.DeleteAllFile();
                            //    string regionRootPath = FileUtils.CreateRegionBackup(DB_ResidenceData.residenceData.CurReginID);
                            //    FileUtils.RestoreRegionFiles(regionRootPath);
                            //    DB_ResidenceData.residenceData.EixtAccount();
                            //    OnAppConfig.Instance.RefreshUserConfig();
                            //    SpatialInfo.CurrentSpatial.InitRoomFunction();
                            //}
                            Application.RunOnMainThread(() =>
                            {
                                //20201223-登录成功之后,将下载数据完成标记标记为false,防止主页提前加载
                                Common.ApiUtlis.Ins.DownloadDataComplete = false;
                                //跳转页面----
                                MainPage.GoUserPage(true);
                                this.RemoveFromParent();
                            });
                        }
                        else
                        {
                            //Application.RunOnMainThread(() =>
                            //{
                            //    BindingResidencePage page = new BindingResidencePage();
                            //    MainPage.BaseView.AddChidren(page);
                            //    page.LoadView();
                            //});
                            //2020-11-13 待确认
                            //获取住宅失败,重新标记为未登录状态
                            UserInfo.Current.LastTime = DateTime.MinValue;
                            UserInfo.Current.ValidToken = false;
                            UserInfo.Current.SaveUserInfo();
                            //登录失败,请先添加住宅!
                            //Utlis.ShowAlertOnMainThread(Language.StringByID(StringId.FailedGetHomeList));
@@ -693,20 +705,14 @@
                //调用验证码登录接口
                loginResult = pm.LoginValidCode(account, password);
            }
            if(loginResult == null)
            {
                return false;
            }
            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
                //};
                if (OnAppConfig.Instance.LastLoginUserId != revertData.userId)
                {
                    OnAppConfig.Instance.LastLoginUserId = revertData.userId;
@@ -715,16 +721,12 @@
                UserInfo.Current.ClearUserInfo();
                UserInfo.Current.userType = revertData.userType;
                UserInfo.Current.AccountString = account;
                //UserInfo.Current.password = password;
                UserInfo.Current.LastTime = DateTime.Now;
                UserInfo.Current.ValidToken = true;
                UserInfo.Current.ID = revertData.userId;
                UserInfo.Current.LoginTokenString = revertData.headerPrefix + revertData.accessToken;
                UserInfo.Current.AccessToken = revertData.accessToken;
                UserInfo.Current.RefreshToken = revertData.refreshToken;
                UserInfo.Current.userName = revertData.name;
                //UserInfo.Current.userMobileInfo = "";//重置用户手机
                //UserInfo.Current.userEmailInfo = "";//重置用户邮箱
                //UserInfo.Current.headImagePagePath = "LoginIcon/2.png";//
                //UserInfo.Current.CurrentRegion.RegionID = "";
                UserInfo.Current.SaveUserInfo();
                MainPage.Log("登录成功。");
#if __IOS__