JLChen
2020-01-15 454ac814944cf956ff02b84b70ba2ec68e5e5ea1
Crabtree/SmartHome/UI/SimpleControl/Phone/Register/AccountLogin.cs
@@ -74,12 +74,14 @@
                TextAlignment = TextAlignment.CenterLeft,
                Radius = (uint)Application.GetRealHeight (0),
                TextColor = SkinStyle.Current.TextColor1,
                //Text = account,
#if DEBUG
                Text = "18926269190@189.cn"
                //Text = "721343314@qq.com"
#endif
                Text = account,
            };
#if DEBUG
            //Text = "18926269190@189.cn"
            etAccount.Text = "721343314@qq.com";
#endif
            accountView.AddChidren (etAccount);
            var userConfigBytes = IO.FileUtils.ReadFile ("AccountListDB");
@@ -92,6 +94,8 @@
                accountListDB = new AccountListDB ();
            }
            var accountList = accountListDB.account;
            var accountListView = new VerticalScrolViewLayout () {
                Width = Application.GetRealWidth (500),
@@ -119,11 +123,12 @@
                TextAlignment = TextAlignment.CenterLeft,
                SecureTextEntry = true,
                TextColor = SkinStyle.Current.TextColor1,
#if DEBUG
                Text = "123456"
#endif
                //Text = password,
                Text = password,
            };
#if DEBUG
            etPasswrod.Text = "123456";
#endif
            passwrodView.AddChidren (etPasswrod);
            Button btnShowPassword = new Button () {
@@ -156,6 +161,10 @@
                NigelLoginPass++;
            };
#endif
            //if (accountList.Count > 0) {
            //    etAccount.Text = accountList [accountList.Count-1];
            //}
            etAccount.EditorEnterAction += (obj) => {
                Application.HideSoftInput ();
                etPasswrod.Foucs = true;
@@ -384,31 +393,31 @@
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="stateCodeStr"></param>
        void ShowGetAllBindGatewarysPaggerErrorInfo (string stateCodeStr)
        {
            string mes = "";
            //2020-01-06 待补充
            if (stateCodeStr == ErrorCode.NetworkError) {
                mes = ErrorCode.NetworkError;
            } else {
                mes = ErrorCode.OperationFailed + ErrorCode.Reason + stateCodeStr;
        ///// <summary>
        /////
        ///// </summary>
        ///// <param name="stateCodeStr"></param>
        //void ShowGetAllBindGatewarysPaggerErrorInfo (string stateCodeStr)
        //{
        //    string mes = "";
        //    //2020-01-06 待补充
        //    if (stateCodeStr == ErrorCode.NetworkError) {
        //        mes = ErrorCode.NetworkError;
        //    } else {
        //        mes = ErrorCode.OperationFailed + ErrorCode.Reason + stateCodeStr;
            }
            if (!string.IsNullOrEmpty (mes)) {
                Application.RunOnMainThread (() => {
                    new Alert ("", mes, Language.StringByID (R.MyInternationalizationString.Close)).Show ();
                });
            }
        //    }
        //    if (!string.IsNullOrEmpty (mes)) {
        //        Application.RunOnMainThread (() => {
        //            new Alert ("", mes, Language.StringByID (R.MyInternationalizationString.Close)).Show ();
        //        });
        //    }
        }
        //}
        /// <summary>
        /// 登录
        /// 登录 2020-01-11
        /// </summary>
        /// <param name="account">Account.</param>
        /// <param name="password">Password.</param>
@@ -455,20 +464,50 @@
                    //    //当住宅为空时先提示用户新建住宅
                    //} else {
                    var revertRoomData = mResidenceRes.PageData;
                    if (revertRoomData.Find ((obj) => obj.Id == UserConfig.Instance.CurrentRegion.Id) == null) {
                    if (UserConfig.Instance.CurrentRegion == null) {
                        if (revertRoomData != null && revertRoomData.Count > 0) {
                            UserConfig.Instance.CurrentRegion = revertRoomData [0];
                            //if (UserConfig.Instance.CheckHomeGateways ()) {
                            //    UserConfig.Instance.GatewayMAC = revertRoomData [0].HomeGateways [0].GatewayUniqueId;
                            //}
                            //CheckIfNeedGetMasterAccountToken ();
                            var bFind = false;
                            foreach (var mHome in revertRoomData) {
                                if (UserConfig.Instance.CheckThisHomeGatewaysNotEmpty (mHome)) {
                                    bFind = true;
                                    UserConfig.Instance.CurrentRegion = mHome;
                                    break;
                                }
                            }
                            if (!bFind) {
                                UserConfig.Instance.CurrentRegion = revertRoomData [0];
                            }
                            IO.FileUtils.DeleteAllFile ();
                        }
                    } else {
                        Room.InitAllRoom ();
                    }
                    } else {
                        //2020-01-11
                        var findRoom = revertRoomData.Find ((obj) => obj.Id == UserConfig.Instance.CurrentRegion.Id);
                        if (findRoom == null) {
                            if (revertRoomData != null && revertRoomData.Count > 0) {
                                var bFind = false;
                                foreach (var mHome in revertRoomData) {
                                    if (UserConfig.Instance.CheckThisHomeGatewaysNotEmpty (mHome)) {
                                        bFind = true;
                                        UserConfig.Instance.CurrentRegion = mHome;
                                        break;
                                    }
                                }
                                if (!bFind) {
                                    UserConfig.Instance.CurrentRegion = revertRoomData [0];
                                }
                                IO.FileUtils.DeleteAllFile ();
                            }
                        } else {
                            //刷新住宅 解决子账号问题
                            UserConfig.Instance.CurrentRegion = findRoom;
                            Room.InitAllRoom ();
                        }
                    }
                    ////原方案
                    //GetAllBindGatewarysPagger (revertRoomData);
                    ////获取当前住宅网关方案
@@ -545,6 +584,7 @@
        {
            UserConfig.Instance.SaveUserConfig ();
            MainPage.LoginUser.LastTime = DateTime.Now;
            //MainPage.IsOtherDevicesLogin = false;
            if (UserConfig.Instance.CheckHomeGatewaysNotEmpty ()) {
                UserConfig.Instance.HomeLists = revertRoomData;
@@ -554,13 +594,13 @@
                A31MusicModel.Refresh ();
                Application.RunOnMainThread (() => {
                    Close ();
                    UserMiddle.Init ();
                    UserMiddle.Init (false,true);
                    EquipmentPublicClass.CheckLinkRemote (2);
                });
            } else {
                Application.RunOnMainThread (() => {
                    UserMiddle.Init ();
                    UserMiddle.Init (false, true);
                    Close ();
                });
            }