JLChen
2020-12-23 320d7cc8feb394d0ce3db2ec1d01593b554d990f
HDL_ON/UI/UI1-Login/LoginPageBLL.cs
@@ -635,6 +635,12 @@
                        }
                        else
                        {
                            BindingResidencePage page = new BindingResidencePage();
                            MainPage.BaseView.AddChidren(page);
                            page.LoadView();
                            //2020-11-13 待确认
                            //获取住宅失败,重新标记为未登录状态
                            UserInfo.Current.LastTime = DateTime.MinValue;
@@ -695,8 +701,11 @@
                //    refreshToken = revertData.refreshToken,
                //    userName = revertData.name
                //};
                OnAppConfig.Instance.LastLoginUserId = revertData.userId;
                OnAppConfig.Instance.SaveConfig();
                if (OnAppConfig.Instance.LastLoginUserId != revertData.userId)
                {
                    OnAppConfig.Instance.LastLoginUserId = revertData.userId;
                    OnAppConfig.Instance.SaveConfig();
                }
                UserInfo.Current.ClearUserInfo();
                UserInfo.Current.userType = revertData.userType;
                UserInfo.Current.AccountString = account;
@@ -706,18 +715,17 @@
                UserInfo.Current.LoginTokenString = revertData.headerPrefix + 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.CurReginID = "";
                //UserInfo.Current.userMobileInfo = "";//重置用户手机
                //UserInfo.Current.userEmailInfo = "";//重置用户邮箱
                //UserInfo.Current.headImagePagePath = "LoginIcon/2.png";//
                //UserInfo.Current.CurrentRegion.RegionID = "";
                UserInfo.Current.SaveUserInfo();
                MainPage.Log("登录成功。");
                result = true;
                //获取用户信息
                new Thread(() =>
                {
                    pm.GetUserHeadImage(revertData.userId);
                    pm.GetUserInfo(false);
                    pm.GetUserInfo();
                })
                { IsBackground = true }.Start();
            }
@@ -727,6 +735,8 @@
                //账号或者密码错误
                Application.RunOnMainThread(() =>
                {
                    waitPage.Hide();
                    if (loginResult.Code == "10008")
                    {
                        //用户名或密码错误
@@ -744,12 +754,53 @@
                        btnPasswordViewBottomLine.BackgroundColor = CSS_Color.AuxiliaryColor2;
                        btnPasswordViewBottomLine.Height = Application.GetRealHeight(2);
                    }
                    waitPage.Hide();
                    else if (loginResult.Code == StateCode.AccountLoginLock)
                    {
                        ShowAccountLoginLockTip(loginResult);
                        //var tipStr = Language.StringByID(StringId.AccountLoginLock) + "\r\n" + Language.StringByID(StringId.PleaseTryToForgetPassword);
                        //Utlis.ShowTip(tipStr);
                        return;
                    }
                    IMessageCommon.Current.ShowErrorInfoAlter(loginResult.Code);
                });
                IMessageCommon.Current.ShowErrorInfoAlter(loginResult.Code);
            }
            return result;
        }
        /// <summary>
        /// 解析提示用户解锁时间
        /// 密码错误次数过多,账号被锁定!请通过忘记密码找回密码或{0}分钟后重试.
        /// </summary>
        /// <param name="loginResult"></param>
        void ShowAccountLoginLockTip(ResponsePackNew loginResult)
        {
            //密码错误次数过多,账号被锁定!
            var tipStr = Language.StringByID(StringId.AccountLoginLock);
            try
            {
                if (loginResult.extra != null)
                {
                    //请通过忘记密码找回密码或{0}分钟后重试.
                    var revertData = Newtonsoft.Json.JsonConvert.DeserializeObject<AccountLoginLockExtraRes>(loginResult.extra.ToString());
                    string msg = Language.StringByID(StringId.PleaseTryToForgetPassword);
                    //var unlockTime = Utlis.UnixToDateTimeWithFormatMS(revertData.unlockTime, "HH:mm");
                    //msg = msg.Replace("{0}", unlockTime);
                    var unlockDatetime = Utlis.UnixToDateTimeMS(revertData.unlockTime);
                    var unlockTimeInt = unlockDatetime.Minute - DateTime.Now.Minute;
                    if(unlockTimeInt <= 0)
                    {
                        unlockTimeInt = 1;
                    }
                    msg = msg.Replace("{0}", unlockTimeInt.ToString());
                    tipStr = tipStr + "\r\n" + msg;
                }
            }
            catch { }
            Utlis.ShowTip(tipStr);
        }
        /// <summary>
@@ -784,6 +835,9 @@
        {
            btnRegister.MouseUpEventHandler += (sender, e) =>
            {
                //2020-12-22 增加点击隐藏键盘事件
                Application.HideSoftInput();
                //判断是否同意了隐私政策
                if (CheckPrivacyPolicy() == false) return;
@@ -798,6 +852,7 @@
                        MainPage.Log($"login callBackAction : {ex.Message}");
                    }
                };
                var registerPage = new RegisterPage(autoLoginAction);
                registerPage.Show();
@@ -812,6 +867,9 @@
        {
            btnForgetPassword.MouseUpEventHandler += (sender, e) =>
            {
                //2020-12-22 增加点击隐藏键盘事件
                Application.HideSoftInput();
                //判断是否同意了隐私政策
                if (CheckPrivacyPolicy() == false) return;
@@ -827,6 +885,7 @@
                        MainPage.Log($"login callBackAction : {ex.Message}");
                    }
                };
                var forgetPasswordDialog = new ForgetPasswordPage(autoLoginAction);
                forgetPasswordDialog.Show();
                forgetPasswordDialog.ShowDialog();