wxr
2020-11-20 716d1b3b705e7d37e6edebd7f60b7613ab5aee87
HDL_ON/UI/UI1-Login/LoginPageBLL.cs
@@ -28,6 +28,25 @@
        }
        /// <summary>
        /// 检测当前配置域名是否一致,不一致则替换
        /// </summary>
        /// <param name="result"></param>
        void CheckAndSetUserRequestHost(ResponsePackNew result)
        {
            try
            {
                var mGlobalRegionListObj = Newtonsoft.Json.JsonConvert.DeserializeObject<GlobalRegionListRes>(result.Data.ToString());
                if (UserInfo.Current.RequestHttpsHost != mGlobalRegionListObj.regionUrl)
                {
                    UserInfo.Current.RequestHttpsHost = mGlobalRegionListObj.regionUrl;
                    UserInfo.Current.GlobalRegion = mGlobalRegionListObj;
                    UserInfo.Current.SaveUserInfo();
                }
            }
            catch { }
        }
        /// <summary>
        /// 点击按钮获取验证码
        /// </summary>
        void GetVerificationCode()
@@ -51,7 +70,7 @@
                        btnAccountViewBottomLine.Height = Application.GetRealHeight(2);
                        return;
                    }
                    if (!Regex.IsMatch(account, @"^[1]+\d{10}") || (account.Length != 11))
                    if (!Utlis.CheckPhoneNumber(phoneNumber, phoneZoneCode))
                    {
                        var tip = new Tip()
                        {
@@ -73,11 +92,14 @@
                        var result = pm.GetRegionByAccount(account);
                        if (result.Code != StateCode.SUCCESS)
                        {
                            IMessageCommon.Current.ShowErrorInfoAlter(NewAPI.API_POST_GetRegionByAccount, result.Code);
                            IMessageCommon.Current.ShowErrorInfoAlter(result.Code);
                            return;
                        }
                        else
                        {
                            //检测当前配置域名是否一致,不一致则替换
                            CheckAndSetUserRequestHost(result);
                            //
                            Application.RunOnMainThread(() =>
                            {
                                btnGetVerificationCode.IsSelected = false;
@@ -113,7 +135,7 @@
                                    btnPasswordViewBottomLine.Height = Application.GetRealHeight(2);
                                });
                                // 提示错误
                                IMessageCommon.Current.ShowErrorInfoAlter(NewAPI.API_POST_Verification_Send, resultObj.Code);
                                IMessageCommon.Current.ShowErrorInfoAlter(resultObj.Code);
                            }
                        }
@@ -395,7 +417,7 @@
                        return;
                    if (loginType == 0)
                    {
                        if (!Regex.IsMatch(account, @"^[1]+\d{10}") || (account.Length != 11))
                        if (!Utlis.CheckPhoneNumber(registerPhone, phoneZoneCode))
                        {
                            var tip = new Tip()
                            {
@@ -418,7 +440,7 @@
                    }
                    else
                    {
                        if (!Regex.IsMatch(account, "([a-zA-Z0-9_\\.\\-])+\\@(([a-zA-Z0-9\\-])+\\.)+([a-zA-Z0-9]{2,5})+"))
                        if (!Utlis.CheckEmail(registerEmail))
                        {
                            var tip = new Tip()
                            {
@@ -493,12 +515,15 @@
            {
                if (btnLogin.IsSelected)
                {
                    //判断是否同意了隐私政策
                    if (CheckPrivacyPolicy() == false) return;
                    account = etAccount.Text.Trim();
                    password = etPassword.Text.Trim();
                    if (loginType == 0)
                    {
                        if (!Regex.IsMatch(account, @"^[1]+\d{10}") && account.Length == 11)
                        if (!Utlis.CheckPhoneNumber(account, phoneZoneCode))
                        {
                            var tip = new Tip()
                            {
@@ -512,7 +537,7 @@
                    }
                    else
                    {
                        if (!Regex.IsMatch(account, "([a-zA-Z0-9_\\.\\-])+\\@(([a-zA-Z0-9\\-])+\\.)+([a-zA-Z0-9]{2,5})+"))
                        if (!Utlis.CheckEmail(account))
                        {
                            var tip = new Tip()
                            {
@@ -584,8 +609,13 @@
                        var result = pm.GetRegionByAccount(account);
                        if (result.Code != StateCode.SUCCESS)
                        {
                            IMessageCommon.Current.ShowErrorInfoAlter(NewAPI.API_POST_GetRegionByAccount, result.Code);
                            IMessageCommon.Current.ShowErrorInfoAlter(result.Code);
                            return;
                        }
                        else
                        {
                            //设置用户所注册地区的域名,用户相关操作都用这个域名
                            CheckAndSetUserRequestHost(result);
                        }
                    }
@@ -627,7 +657,7 @@
                                OnAppConfig.Instance.RefreshUserConfig();
                                DB_ResidenceData.InitRoomFunction();
                            }
                            if (MainPage.LoginUser.userEmailInfo == "464027401@qq.com")
                            if ( UserInfo.Current.userEmailInfo == "464027401@qq.com")
                            {
                                DB_ResidenceData.residenceData.floors.Add(new Floor() { name = "1F", sid = "09888" });
                                var r111 = new Room() { sid = "0001", name = "Room-1", floorId = "09888", backgroundImage = "Classification/Room/Roombg.png" };
@@ -901,7 +931,11 @@
                        else
                        {
                            //2020-11-13 待确认
                            MainPage.ShowAlertOnMainThread("登录失败,请先添加住宅。");
                            //获取住宅失败,重新标记为未登录状态
                             UserInfo.Current.lastTime = DateTime.MinValue;
                             UserInfo.Current.SaveUserInfo();
                            //登录失败,请先添加住宅!
                            Utlis.ShowAlertOnMainThread(Language.StringByID(StringId.FailedGetHomeList));
                        }
                    }
                }
@@ -945,18 +979,26 @@
            if (loginResult.Code == StateCode.SUCCESS)
            {
                var revertData = Newtonsoft.Json.JsonConvert.DeserializeObject<UserLoginRes>(loginResult.Data.ToString());
                MainPage.LoginUser = 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
                };
                MainPage.LoginUser.SaveUserInfo();
                // 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;
                UserInfo.Current.SaveUserInfo();
                MainPage.Log("登录成功。");
                result = true;
                //获取用户信息
@@ -1031,7 +1073,7 @@
            if (responsePack == StateCode.SUCCESS)
            {
                //2020-11-13 待确认,没有住宅,不算登录成功
                if (MainPage.LoginUser.regionList != null && MainPage.LoginUser.regionList.Count > 0){
                if ( UserInfo.Current.regionList != null &&  UserInfo.Current.regionList.Count > 0){
                    result = true;
                }
                //result = true;
@@ -1039,7 +1081,7 @@
            else
            {
                // 提示错误
                IMessageCommon.Current.ShowErrorInfoAlter(NewAPI.API_POST_Gethomepager, responsePack);
                IMessageCommon.Current.ShowErrorInfoAlter(responsePack);
            }
            return result;
        }