gxc
2019-12-13 eb424d24e39bab4a245725f35deab3f234ea0f13
ZigbeeApp/Shared/Phone/Device/Account/AccountLoginByCode.cs
old mode 100755 new mode 100644
@@ -87,6 +87,7 @@
        /// </summary>
        public AccountLoginByCode()
        {
            CommonPage.Instance.IsDrawerLockMode = true;
            Tag = "Login";
            BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor;
            t = new Timer();
@@ -176,7 +177,7 @@
                Width = Application.GetRealWidth(942),
                Gravity = Gravity.CenterHorizontal,
                BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor,
                Radius = (uint)Application.GetRealHeight(30)
                Radius = (uint)Application.GetRealHeight(17)
            };
            midFrameLayout.AddChidren(accountCodeFL);
@@ -216,7 +217,7 @@
            LoginByAccountPWDBtn = new Button()
            {
                X = Application.GetRealWidth(98),
                Y = Application.GetRealHeight(1446),
                Y = Application.GetRealHeight(1466),
                Width = Application.GetRealWidth(300),
                Height = Application.GetRealHeight(49),
                TextID = R.MyInternationalizationString.LoginByAccountPWD,
@@ -229,7 +230,7 @@
            registerBtn = new Button()
            {
                X = Application.GetRealWidth(738),
                Y = Application.GetRealHeight(1446),
                Y = Application.GetRealHeight(1466),
                Width = Application.GetRealWidth(244),
                Height = Application.GetRealHeight(49),
                TextID = R.MyInternationalizationString.Register,
@@ -298,26 +299,19 @@
                    {
                        return;
                    }
                    this.RemoveFromParent();
                    Application.MainPage?.RemoveViewByTag("Login");
                    UserPage.Instance.Fresh();
                    HomePage.Instance.ShowLoginLoadView();
                    new System.Threading.Thread(async () =>
                    {
                        //启动ZigBee
                        ZigBee.Common.Application.Init();
                        var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<Shared.Common.ResponseEntity.UserLoginRes>(requestRevetLoginCodeOBJ.ResponseData.ToString());
                        var revertData = responseDataObj;
                        Config.ReFresh();
                        Config.Instance.Password = string.Empty;
                        Config.Instance.Account = revertData.Account;
                        Config.Instance.MqttKey = revertData.MqttKey;
                        Config.Instance.Guid = revertData.Guid;
                        Config.Instance.MD5PWD = revertData.MD5PWD;
                        Config.Instance.LoginDateTime = DateTime.Now;
                        Config.Instance.ConnectZigbeeMqttBrokerPwd = revertData.ConnectZigbeeMqttBrokerPwd;
                        Config.Instance.ConnectZigbeeMqttClientId = revertData.ConnectZigbeeMqttClientId;
                        Config.Instance.ZigbeeMqttBrokerLoadSubDomain = revertData.ZigbeeMqttBrokerLoadSubDomain;
                        Config.Instance.LoginToken = revertData.Token;
                        if (Config.Instance.AccountList.Find((obj) => obj == revertData.Account) == null)
                        {
                            Config.Instance.AccountList.Add(revertData.Account);
@@ -326,15 +320,17 @@
                        Config.Instance.MD5PWD = revertData.MD5PWD;
                        Config.Instance.Save();
                        var resultRegID = await CommonPage.Instance.PushRegID();
                        var homes = await House.GetHomeLists();
                        var homes = await House.GetHomeLists();
                        //启动ZigBee
                        ZigBee.Common.Application.Init();
                        //刷新个人中心的内存及线程
                        await UserCenter.UserCenterLogic.InitUserCenterMenmoryAndThread();
                        Shared.Common.Room.CanInitAllRoom = true;
                        Shared.Common.Room.InitAllRoom();
                        Application.RunOnMainThread(() =>
                        {
                            this.RemoveFromParent();
                            CommonPage.Instance.RemoveViewByTag("Login");
                            UserPage.Instance.Fresh();
                            CommonPage.Loading.Hide();
                        });
@@ -437,7 +433,8 @@
        private void AddPhoneOrEmailFL(FrameLayout accountCodeFrameLayout, string phoneOrEmail)
        {
            accountCodeFrameLayout.RemoveAll();
            account = string.Empty;
            loginErrorBtn.Text = string.Empty;
            if (phoneOrEmail == "Phone")
            {
                phoneRow = new PhoneRowForm();
@@ -466,18 +463,18 @@
        /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param>
        private void Account_TextChange(object sender, string mouseEventArgs)
        {
            loginErrorBtn.Text = "";
            loginErrorBtn.Text = string.Empty;
            if ((sender as EditText).Text.Trim().Length > 0)
            {
                IsRightAccount = true;
                codeRow.SendCodeBtn.Enable = codeRow.SendCodeBtn.IsSelected = true;
                account= (sender as EditText).Text.Trim();
            }
            else
            {
                IsRightAccount = false;
                codeRow.SendCodeBtn.Enable = codeRow.SendCodeBtn.IsSelected = false;
            }
            account = (sender as EditText).Text.Trim();
        }
        /// <summary>
@@ -546,9 +543,9 @@
        private void Register(object sender, MouseEventArgs mouseEventArgs)
        {
            this.RemoveFromParent();
            var login = new AccountLogin();
            CommonPage.Instance.AddChidren(login);
            login.Show();
            var registerPage = new AccountRegister();
            CommonPage.Instance.AddChidren(registerPage);
            registerPage.Show();
        }
        #endregion
@@ -575,6 +572,11 @@
        /// <param name="mouseEventArgs"></param>
        private async void SendCode_MouseUpEventAsync(object sender, MouseEventArgs mouseEventArgs)
        {
            if (CheckAccount(account) == false)
            {
                return;
            }
            (sender as Button).Enable = (sender as Button).IsSelected = false;
            CommonPage.Loading.Start();
            try
@@ -643,6 +645,34 @@
                CommonPage.Loading.Hide();
            }
        }
        /// <summary>
        /// CheckAccount
        /// </summary>
        /// <param name="accountStr"></param>
        /// <returns></returns>
        private bool CheckAccount(string accountStr)
        {
            loginErrorBtn.Text = string.Empty;
            if (phoneEmailForm.SelectedEmail.IsSelected)
            {
                if (AccountLogic.Instance.CheckEmail(accountStr) == false)
                {
                    loginErrorBtn.TextID = R.MyInternationalizationString.TheEmailError;
                    return false;
                }
            }
            else
            {
                if (AccountLogic.Instance.CheckPhoneWithZone(accountStr, CommonPage.PhoneZoneStr) == false)
                {
                    loginErrorBtn.TextID = R.MyInternationalizationString.ThePhoneError;
                    return false;
                }
            }
            return true;
        }
        #endregion
        #region ◆ 验证验证码________________________