WJC
2019-12-30 f1c3921b08bb22ac6f5db22d620e01d7e8e5c49f
ZigbeeApp/Shared/Phone/Device/Account/AccountLogin.cs
@@ -1,12 +1,7 @@
using System;
using System.Collections.Generic;
using System.Net;
using System.Text;
using uPLibrary.Networking.M2Mqtt;
using Shared.Common;
using Shared.IO;
using Shared.Phone.UserView;
using System.Net.Http;
using Shared.Phone.Device.CommonForm;
namespace Shared.Phone.Device.Account
{
@@ -21,25 +16,26 @@
        /// </summary>
        private FrameLayout midFrameLayout;
        /// <summary>
        /// 注册按钮
        /// 手机邮箱
        /// </summary>
        private Button registerBtn;
        private PhoneEmailForm phoneEmailForm;
        /// <summary>
        /// 账号输入控件
        /// phoneRowForm
        /// </summary>
        private EditText accountET;
        private PhoneLoginRowForm phoneRow;
        /// <summary>
        /// 密码输入控件
        /// emailRow
        /// </summary>
        private EditText passwrodET;
        private EmailLoginRowForm emailRow;
        /// <summary>
        /// 登录按钮
        /// pwdRow
        /// </summary>
        private Button loginBtn;
        private PwdLoginRowForm pwdRow;
        /// <summary>
        /// 隐藏密码
        /// 账号密码fl
        /// </summary>
        private Button hidenPWDbtn;
        private FrameLayout accountPwdFL;
        /// <summary>
        /// 登录错误提示按钮
        /// </summary>
@@ -49,9 +45,34 @@
        /// </summary>
        private Button forgotPasswordBtn;
        /// <summary>
        /// 登录按钮
        /// </summary>
        private Button loginBtn;
        /// <summary>
        /// 验证码登录按钮
        /// </summary>
        private Button loginByCodeBtn;
        /// <summary>
        /// 注册按钮
        /// </summary>
        private Button registerBtn;
        /// <summary>
        /// 账号
        /// </summary>
        private string account;
        /// <summary>
        /// 密码
        /// </summary>
        private string password;
        /// <summary>
        /// wechat
        /// </summary>
        private Button wechatBtn;
        /// <summary>
        /// qq
        /// </summary>
        private Button qqBtn;
        #endregion
@@ -62,7 +83,13 @@
        /// </summary>
        public AccountLogin()
        {
             BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor;
            BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor;
            Tag = "Login";
        }
        public override void RemoveFromParent()
        {
            base.RemoveFromParent();
        }
        #endregion
@@ -93,165 +120,165 @@
        /// <param name="password">Password.</param>
        public void LoginViewShow(string account = "", string password = "")
        {
            this.account = account;
            this.password = password;
            #region midFrameLayout
            midFrameLayout = new FrameLayout()
            {
                Width = LayoutParams.MatchParent,
                Height = Application.GetRealHeight(CommonPage.AppRealHeight),
                //Y = Application.GetRealHeight(36),
                BackgroundColor =ZigbeeColor.Current.GXCBackgroundColor
            };
            AddChidren(midFrameLayout);
            #endregion
            #region 布局账户,密码,忘记密码,注册  手机验证码登录
            registerBtn = new Button()
            {
                Width = Application.GetRealWidth(250),
                Height = Application.GetRealHeight(80),
                X = Application.GetRealWidth(CommonPage.AppRealWidth-250-50),
                Y = Application.GetRealHeight(100),
                TextID = R.MyInternationalizationString.Register,
                TextSize = 15,
                TextColor = ZigbeeColor.Current.GXCTextBlueColor,
                TextAlignment = TextAlignment.CenterRight
            };
            midFrameLayout.AddChidren(registerBtn);
             var logoBtn = new Button()
            var logoBG = new Button()
            {
                Width = Application.GetMinRealAverage(270),
                Height = Application.GetMinRealAverage(270),
                Y = Application.GetRealHeight(150)+registerBtn.Bottom,
                UnSelectedImagePath = "Logo/Logo.png",
                Gravity=Gravity.CenterHorizontal
                Height = Application.GetRealHeight(619),
                UnSelectedImagePath = "Account/Logo_loginBG.png"
            };
            midFrameLayout.AddChidren(logoBtn);
            midFrameLayout.AddChidren(logoBG);
            var accountFL = new FrameLayout()
            var phoneEmailBGFL = new FrameLayout()
            {
                Width = Application.GetRealWidth(700),
                Height = Application.GetRealHeight(110),
                Y = Application.GetRealHeight(200) + logoBtn.Bottom,
                Radius = (uint)Application.GetRealHeight(55),
                BorderColor = ZigbeeColor.Current.GXCBorderColor,
                BorderWidth = 1,
                Y = logoBG.Bottom,
                Height = Application.GetRealHeight(1921),
                BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor
            };
            midFrameLayout.AddChidren(phoneEmailBGFL);
            var logo = new Button()
            {
                Width = Application.GetMinRealAverage(184),
                Height = Application.GetMinRealAverage(184),
                Y = Application.GetRealHeight(230),
                UnSelectedImagePath = "Account/Logo_White.png",
                Gravity = Gravity.CenterHorizontal
            };
            midFrameLayout.AddChidren(accountFL);
            midFrameLayout.AddChidren(logo);
            accountET = new EditText()
            var logoName = new Button()
            {
                X=Application.GetRealWidth(20),
                Width = Application.GetRealWidth(660),
                PlaceholderText = Language.StringByID(R.MyInternationalizationString.PleaseInputPhoneNumberOrEmail),
                TextAlignment = TextAlignment.Center,
                PlaceholderTextColor = ZigbeeColor.Current.GXCPlaceHolderTextColor,
                TextColor = ZigbeeColor.Current.GXCTextBlackColor,
                Text=account
                Y = logo.Bottom,
                Height = Application.GetRealHeight(69),
                Width = Application.GetRealWidth(300),
                Gravity = Gravity.CenterHorizontal,
                TextID = R.MyInternationalizationString.AppName,
                TextColor = ZigbeeColor.Current.GXCTextWhiteColor
            };
            accountFL.AddChidren(accountET);
            midFrameLayout.AddChidren(logoName);
            var passwordFL = new FrameLayout()
            phoneEmailForm = new PhoneEmailForm();
            phoneEmailForm.Init(midFrameLayout);
            //错误提示Btn
            loginErrorBtn = new Button()
            {
                X = Application.GetRealWidth(242),
                Y = Application.GetRealHeight(740),
                Width = Application.GetRealWidth(700),
                Height = Application.GetRealHeight(110),
                Y = accountFL.Bottom + Application.GetRealHeight(100),
                Radius = (uint)Application.GetRealHeight(55),
                BorderColor = ZigbeeColor.Current.GXCBorderColor,
                BorderWidth = 1,
                Gravity = Gravity.CenterHorizontal
                Height = Application.GetRealHeight(58),
                TextColor = ZigbeeColor.Current.GXCTextRed,
                TextAlignment = TextAlignment.CenterLeft,
            };
            midFrameLayout.AddChidren(passwordFL);
            midFrameLayout.AddChidren(loginErrorBtn);
            passwrodET = new EditText()
            accountPwdFL = new FrameLayout()
            {
                Width = Application.GetRealWidth(450),
                PlaceholderText = Language.StringByID(R.MyInternationalizationString.PleaseInputPWD),
                TextAlignment = TextAlignment.Center,
                SecureTextEntry = true,
                PlaceholderTextColor = ZigbeeColor.Current.GXCPlaceHolderTextColor,
                TextColor = ZigbeeColor.Current.GXCTextBlackColor,
                Text=password,
                Gravity=Gravity.CenterHorizontal
                Y = Application.GetRealHeight(801),
                Height = Application.GetRealHeight(553),
                Width = Application.GetRealWidth(942),
                Gravity = Gravity.CenterHorizontal,
                BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor,
                Radius = (uint)Application.GetRealHeight(17)
            };
            passwordFL.AddChidren(passwrodET);
            midFrameLayout.AddChidren(accountPwdFL);
            hidenPWDbtn = new Button()
            {
                X = passwrodET.Right + Application.GetRealWidth(20),
                Width = Application.GetMinReal(72),
                Height = Application.GetMinReal(72),
                UnSelectedImagePath = "Account/HidenPWD.png",
                SelectedImagePath = "Account/UnHidenPWD.png",
                Gravity=Gravity.CenterVertical
            };
            passwordFL.AddChidren(hidenPWDbtn);
            AddPhoneOrEmailFL(accountPwdFL, "Phone");
            forgotPasswordBtn = new Button()
            {
                Width = Application.GetRealWidth(400),
                Height = Application.GetRealHeight(110),
                Y = passwordFL.Bottom + Application.GetRealHeight(100),
                TextID = R.MyInternationalizationString.ForgotPassword,
                TextSize = 15,
                TextColor = Shared.Common.ZigbeeColor.Current.GXCTextBlackColor,
                TextAlignment = TextAlignment.Center,
                Gravity=Gravity.CenterHorizontal
                X = Application.GetRealWidth(CommonPage.AppRealWidth - 115 - 250),
                Y = Application.GetRealHeight(1198),
                Width = Application.GetRealWidth(250),
                Height = Application.GetRealHeight(58),
                TextID = R.MyInternationalizationString.ForgotPWD,
                TextSize = CommonFormResouce.loginTextSize,
                TextColor = Shared.Common.ZigbeeColor.Current.GXCTextGrayColor,
                TextAlignment = TextAlignment.CenterRight
            };
            midFrameLayout.AddChidren(forgotPasswordBtn);
            loginBtn = new Button()
            {
                Width = Application.GetRealWidth(700),
                Height = Application.GetRealHeight(110),
                Y = Application.GetRealHeight(100) + forgotPasswordBtn.Bottom,
                Y = Application.GetRealHeight(1293),
                Width = Application.GetRealWidth(688),
                Height = Application.GetRealHeight(127),
                Gravity = Gravity.CenterHorizontal,
                TextID = R.MyInternationalizationString.Login,
                TextSize = 15,
                TextColor = Shared.Common.ZigbeeColor.Current.GXCTextWhiteColor,
                Radius = (uint)Application.GetRealHeight(55),
                BorderWidth = 0,
                BackgroundColor = ZigbeeColor.Current.GXCButtonUnselectedColor,
                SelectedBackgroundColor = ZigbeeColor.Current.GXCButtonBlueColor,
                Gravity = Gravity.CenterHorizontal,
                Enable = !string.IsNullOrEmpty(passwrodET.Text),
                IsSelected = !string.IsNullOrEmpty(passwrodET.Text)
                TextColor = ZigbeeColor.Current.GXCTextGrayColor,
                SelectedTextColor = ZigbeeColor.Current.GXCTextWhiteColor,
                SelectedBackgroundColor = ZigbeeColor.Current.GXCButtonBlackSelectedColor,
                BackgroundColor = ZigbeeColor.Current.GXCButtonUnSelectedColor,
                Radius = (uint)Application.GetRealHeight(127 / 2),
                Enable = !string.IsNullOrEmpty(pwdRow.PasswrodET?.Text),
                IsSelected = !string.IsNullOrEmpty(pwdRow.PasswrodET?.Text)
            };
            midFrameLayout.AddChidren(loginBtn);
            //错误提示Btn
            loginErrorBtn = new Button()
            {
                Y=loginBtn.Bottom+Application.GetRealHeight(50),
                Width=Application.GetRealWidth(1080-100),
                Height=Application.GetRealHeight(110),
                TextColor=ZigbeeColor.Current.GXCRedColor,
                Gravity=Gravity.CenterHorizontal
            };
            midFrameLayout.AddChidren(loginErrorBtn);
            loginByCodeBtn = new Button()
            {
                X=Application.GetRealWidth(98),
                Y = Application.GetRealHeight(1466),
                Width = Application.GetRealWidth(300),
                Height = Application.GetRealHeight(110),
                Y = midFrameLayout.Bottom - Application.GetRealHeight(100+110),
                Height = Application.GetRealHeight(49),
                TextID = R.MyInternationalizationString.LoginByCode,
                TextColor = ZigbeeColor.Current.GXCTextBlueColor,
                TextAlignment = TextAlignment.Center,
                TextSize = 15,
                Gravity = Gravity.CenterHorizontal
                TextColor = ZigbeeColor.Current.GXCTextGrayColor,
                TextAlignment = TextAlignment.CenterLeft,
                TextSize = CommonFormResouce.loginTextSize
            };
            midFrameLayout.AddChidren(loginByCodeBtn);
            #endregion
            #region event
            passwrodET.EditorEnterAction = (ae) =>
            registerBtn = new Button()
            {
                Application.HideSoftInput();
                X = Application.GetRealWidth(738),
                Y = Application.GetRealHeight(1466),
                Width = Application.GetRealWidth(244),
                Height = Application.GetRealHeight(49),
                TextID = R.MyInternationalizationString.Register,
                TextColor = ZigbeeColor.Current.GXCTextGrayColor,
                TextAlignment = TextAlignment.CenterRight,
                TextSize = CommonFormResouce.loginTextSize
            };
            midFrameLayout.AddChidren(registerBtn);
            wechatBtn = new Button
            {
                X = Application.GetRealWidth(395),
                Y = Application.GetRealHeight(1737),
                Width = Application.GetMinRealAverage(115),
                Height = Application.GetMinRealAverage(115),
                UnSelectedImagePath = "Account/Wechat.png",
                Gravity=Gravity.CenterHorizontal
            };
            midFrameLayout.AddChidren(wechatBtn);
            qqBtn = new Button
            {
                X = Application.GetRealWidth(567),
                Y = Application.GetRealHeight(1737),
                Width = Application.GetMinRealAverage(115),
                Height = Application.GetMinRealAverage(115),
                UnSelectedImagePath = "Account/QQ.png"
            };
            //midFrameLayout.AddChidren(qqBtn);
            #endregion
            BindEvent();
            #endregion
        }
        #endregion
@@ -263,21 +290,21 @@
        /// </summary>
        private void BindEvent()
        {
            //选择手机邮箱
            phoneEmailForm.SelectedPhone.MouseUpEventHandler += SelectPhoneOrEmail_MouseUpEvent;
            phoneEmailForm.SelectedEmail.MouseUpEventHandler += SelectPhoneOrEmail_MouseUpEvent;
            //登录事件
            loginBtn.MouseUpEventHandler += LoginBtnEvent;
            //短信登录
            loginByCodeBtn.MouseUpEventHandler += LoginByCode;
            //忘记密码
            forgotPasswordBtn.MouseUpEventHandler += ForgetPWD;
            //注册事件
            registerBtn.MouseUpEventHandler += Register;
            //账号监听
            accountET.TextChangeEventHandler += Account_TextChange;
            //密码监听事件
            passwrodET.TextChangeEventHandler += Pwd_TextChange;
            //隐藏密码
            hidenPWDbtn.MouseUpEventHandler += HidePWD;
            //忘记密码
            forgotPasswordBtn.MouseUpEventHandler += ForgetPWD_MouseUpEvent;
            //wechat
            wechatBtn.MouseUpEventHandler += LoginByWechat;
            //qq
            qqBtn.MouseUpEventHandler += LoginByQQ;
        }
        #endregion
@@ -291,15 +318,23 @@
        /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param>
        private void LoginBtnEvent(object sender,MouseEventArgs mouseEventArgs)
        {
            Login(accountET.Text.Trim(), passwrodET.Text.Trim());
            if (phoneEmailForm.SelectedPhone.IsSelected)
            {
                Login(phoneRow.AccountET.Text.Trim(), pwdRow.PasswrodET.Text.Trim());
            }
            else
            {
                Login(emailRow.AccountET.Text.Trim(), pwdRow.PasswrodET.Text.Trim());
            }
        }
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="account">Account.</param>
        /// <param name="password">Password.</param>
        private void Login(string account, string password)
        /// <param name="accountStr">Account.</param>
        /// <param name="passwordStr">Password.</param>
        private void Login(string accountStr, string passwordStr)
        {
            //Application.RunOnMainThread( () =>
            //{
@@ -311,8 +346,8 @@
                    var requestObj = new SendDataToServer.LoginObj
                    {
                        Account = account,
                        Password = password,
                        Account = accountStr,
                        Password = passwordStr,
                        Source = CommonPage.Source,
                        Company = CommonPage.Company
                    };
@@ -321,6 +356,7 @@
                    if (revertObj == null)
                    {
                        CommonPage.Instance.FailureToServer();
                        CommonPage.Loading.Hide();
                        return;
                    }
                    var stateCodeStr = revertObj.StateCode.ToUpper();
@@ -331,29 +367,20 @@
                        {
                            return;
                        }
                        this.RemoveFromParent();
                        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>(revertObj.ResponseData.ToString());
                            var revertData = responseDataObj;
                            Config.ReFresh();
                            Config.Instance.UserID = revertData.UserID;
                            Config.Instance.MasterID = revertData.MainUserID;
                            Config.Instance.AccountType = revertData.UserType;
                            Config.Instance.Account = revertData.Account;
                            Config.Instance.MqttKey = revertData.MqttKey;
                            Config.Instance.Password = password;
                            Config.Instance.Password = passwordStr;
                            Config.Instance.MD5PWD = revertData.MD5PWD;
                            Config.Instance.Guid = revertData.Guid;
                            Config.Instance.LoginDateTime = DateTime.Now;
                            Config.Instance.ConnectZigbeeMqttBrokerPwd = revertData.ConnectZigbeeMqttBrokerPwd;
                            Config.Instance.ConnectZigbeeMqttClientId = revertData.ConnectZigbeeMqttClientId;
                            Config.Instance.ZigbeeMqttBrokerLoadSubDomain = revertData.ZigbeeMqttBrokerLoadSubDomain;
                            if (Config.Instance.AccountList.Find((obj) => obj == revertData.Account) == null)
                            {
                                Config.Instance.AccountList.Add(revertData.Account);
@@ -361,15 +388,18 @@
                            Config.Instance.Save();
                            var resultRegID = await Shared.Common.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(() =>
                            {
                                UserPage.Instance.Fresh();
                                CommonPage.Loading.Hide();
                                this.RemoveFromParent();
                                CommonPage.Instance.RemoveViewByTag("Login");
                                UserPage.Instance.Fresh();
                            });
                        })
                        { IsBackground = true }.Start();
@@ -379,28 +409,24 @@
                        CommonPage.Loading.Hide();
                        //未激活
                        loginErrorBtn.TextID = R.MyInternationalizationString.NOTVERIFY;
                        CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.NOTVERIFY);
                    }
                    else if (stateCodeStr == "NOTENABLE")
                    {
                        CommonPage.Loading.Hide();
                        //该用户属于调试账号,并未启用
                        loginErrorBtn.TextID = R.MyInternationalizationString.NOTENABLE;
                        CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.NOTENABLE);
                    }
                    else if (stateCodeStr == "USERNAMEORPWDERROR")
                    {
                        CommonPage.Loading.Hide();
                        //账号或密码错误
                        loginErrorBtn.TextID = R.MyInternationalizationString.USERNAMEORPWDERROR;
                        CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.USERNAMEORPWDERROR);
                    }
                    else if (stateCodeStr == "ACCOUNTNOEXISTS")
                    {
                        CommonPage.Loading.Hide();
                        //账号不存在
                        loginErrorBtn.TextID = R.MyInternationalizationString.ACCOUNTNOEXISTS;
                        CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.ACCOUNTNOEXISTS);
                    }
                    else if (stateCodeStr == "YOUDATANOISLOCALREGION")
                    {
@@ -413,12 +439,11 @@
                        var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<Shared.Common.ResponseEntity.UserLoginLocalRegionRes>(revertObj.ResponseData.ToString());
                        CommonPage.RequestHttpsHost = responseDataObj.RegionServer;
                        //再次登录
                        Login(account, password);
                        Login(accountStr, passwordStr);
                    }
                    else
                    {
                        loginErrorBtn.TextID = R.MyInternationalizationString.RequestServerFailed;
                        CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.RequestServerFailed);
                    }
                }
                catch (Exception ex)
@@ -443,97 +468,248 @@
        /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param>
        private void LoginByCode(object sender,MouseEventArgs mouseEventArgs)
        {
            this.RemoveFromParent();
            //this.RemoveFromParent();
            var loginByCodePage = new AccountLoginByCode();
            CommonPage.Instance.AddChidren(loginByCodePage);
            loginByCodePage.Show();
        }
        /// <summary>
        /// wechat登录
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="mouseEventArgs"></param>
        private void LoginByWechat(object sender, MouseEventArgs mouseEventArgs)
        {
#if Android
            //var alert = new Alert(Language.StringByID(R.MyInternationalizationString.TIP),
            //    Language.StringByID(R.MyInternationalizationString.LoginByWechat),
            //    Language.StringByID(R.MyInternationalizationString.Cancel),
            //    Language.StringByID(R.MyInternationalizationString.Confrim));
            //alert.Show();
            //alert.ResultEventHandler += (send, e) =>
            //{
                //if (e)
                //{
                    com.hdl.home.Application.WXLogin();
                    com.hdl.home.WXEntryActivity.RespAction = (authStr) =>
                    {
                        if (authStr == null)
                        {
                        }
                        else
                        {
                            new System.Threading.Thread(async () =>
                            {
                                var re = await isBindAuthAsync(authStr);
                                if (re)
                                {
                                    Application.RunOnMainThread(() =>
                                    {
                                        //直接登录
                                        HomePage.Instance.ShowLoginLoadView();
                                    });
                                    var resultRegID = await Shared.Common.CommonPage.Instance.PushRegID();
                                    var homes = await House.GetHomeLists();
                                    //启动ZigBee
                                    ZigBee.Common.Application.Init();
                                    //刷新个人中心的内存及线程
                                    await UserCenter.UserCenterLogic.InitUserCenterMenmoryAndThread();
                                    Shared.Common.Room.InitAllRoom();
                                    Application.RunOnMainThread(() =>
                                    {
                                        this.RemoveFromParent();
                                        CommonPage.Instance.RemoveViewByTag("Login");
                                        UserPage.Instance.Fresh();
                                    });
                                }
                                else
                                {
                                    var authRes = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.ResponseEntity.AuthUserRes>(authStr);
                                    Application.RunOnMainThread(() =>
                                    {
                                        var registerPage = new AccountRegister();
                                        Shared.Common.CommonPage.Instance.AddChidren(registerPage);
                                        registerPage.OpenID = authRes.openid;
                                        registerPage.Show();
                                    });
                                }
                            })
                            { IsBackground = true }.Start();
                        }
                    };
            //}
            //};
#endif
#if iOS
            Home.IOS.AppDelegate.WXLogin();
            Home.IOS.AppDelegate.RespAction = (authStr) =>
            {
                if (authStr == null)
                {
                }
                else
                {
                    new System.Threading.Thread(async () =>
                    {
                        var re = await isBindAuthAsync(authStr);
                        if (re)
                        {
                            //直接登录
                            //this.RemoveFromParent();
                            //UserPage.Instance.Fresh();
                            var resultRegID = await Shared.Common.CommonPage.Instance.PushRegID();
                            var homes = await House.GetHomeLists();
                            //启动ZigBee
                            ZigBee.Common.Application.Init();
                            //刷新个人中心的内存及线程
                            await UserCenter.UserCenterLogic.InitUserCenterMenmoryAndThread();
                            Shared.Common.Room.InitAllRoom();
                            Application.RunOnMainThread(() =>
                            {
                                this.RemoveFromParent();
                                UserPage.Instance.Fresh();
                            });
                        }
                        else
                        {
                            var authRes = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.ResponseEntity.AuthUserRes>(authStr);
                            Application.RunOnMainThread(() =>
                            {
                                var registerPage = new AccountRegister();
                                Shared.Common.CommonPage.Instance.AddChidren(registerPage);
                                registerPage.OpenID = authRes.openid;
                                registerPage.Show();
                            });
                        }
                    })
                    { IsBackground = true }.Start();
                }
            };
#endif
        }
        /// <summary>
        /// qq登录
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="mouseEventArgs"></param>
        private void LoginByQQ(object sender, MouseEventArgs mouseEventArgs)
        {
        }
        /// <summary>
        /// 是否已绑定
        /// </summary>
        /// <param name="authStr"></param>
        /// <returns></returns>
        private async System.Threading.Tasks.Task<bool> isBindAuthAsync(string authStr)
        {
            var authRes = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.ResponseEntity.AuthUserRes>(authStr);
            var auth = new SendDataToServer.AuthUser()
            {
                AccessToken = authRes.access_token,
                RefreshToken = authRes.refresh_token,
                OpenID = authRes.openid
            };
            var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(auth);
            var revertObj = await CommonPage.Instance.RequestHttpsZigbeeAsync("ZigbeeUsers/InsertOrUpdateAuthUser", System.Text.Encoding.UTF8.GetBytes(requestJson));
            if (revertObj == null)
            {
                return false;
            }
            var stateCodeStr = revertObj.StateCode.ToUpper();
            if (stateCodeStr == "SUCCESS")
            {
                var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<Shared.Common.ResponseEntity.UserLoginRes>(revertObj.ResponseData.ToString());
                var revertData = responseDataObj;
                Config.Instance.Account = revertData.Account;
                Config.Instance.MD5PWD = revertData.MD5PWD;
                Config.Instance.Guid = revertData.Guid;
                Config.Instance.LoginDateTime = DateTime.Now;
                if (Config.Instance.AccountList.Find((obj) => obj == revertData.Account) == null)
                {
                    Config.Instance.AccountList.Add(revertData.Account);
                }
                Config.Instance.Save();
                return true;
            }
            else
            {
                return false;
            }
        }
        /// <summary>
        /// phone/email 选择
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="mouseEventArgs"></param>
        private void SelectPhoneOrEmail_MouseUpEvent(object sender, MouseEventArgs mouseEventArgs)
        {
            phoneEmailForm.SelectedPhone.IsSelected = phoneEmailForm.SelectedEmail.IsSelected = false;
            loginBtn.Enable = loginBtn.IsSelected = false;
            (sender as Button).IsSelected = true;
            if((sender as Button).Tag.ToString()=="Phone")
            {
                AddPhoneOrEmailFL(accountPwdFL, "Phone");
            }
            else
            {
                AddPhoneOrEmailFL(accountPwdFL, "Email");
            }
        }
        /// <summary>
        /// AddPhoneOrEmailFL
        /// </summary>
        /// <param name="accountPwdFrameLayout"></param>
        /// <param name="phoneOrEmail"></param>
        private void AddPhoneOrEmailFL(FrameLayout accountPwdFrameLayout,string phoneOrEmail)
        {
            accountPwdFrameLayout.RemoveAll();
            if (phoneOrEmail == "Phone")
            {
                phoneRow = new PhoneLoginRowForm();
                phoneRow.Init(accountPwdFrameLayout, this, this.account, 29, 29);
                phoneRow.AccountET.TextChangeEventHandler += Account_TextChange;
            }
            else
            {
                emailRow = new EmailLoginRowForm();
                emailRow.Init(accountPwdFrameLayout, this.account, 29, 29);
                emailRow.AccountET.TextChangeEventHandler += Account_TextChange;
            }
            pwdRow = new PwdLoginRowForm();
            pwdRow.Init(accountPwdFrameLayout, 29, 225);
            pwdRow.PasswrodET.TextChangeEventHandler += Pwd_TextChange;
        }
        #endregion
        #region ◆ 忘记密码________________________
        /// <summary>
        /// 忘记密码
        /// </summary>
        private void ForgetPWD(object sender, MouseEventArgs mouseEventArgs)
        private void ForgetPWD_MouseUpEvent(object sender, MouseEventArgs mouseEventArgs)
        {
            var forgetWPDDialog = new Dialog()
            {
                BackgroundColor = ZigbeeColor.Current.GXCDailogBackGroundColor
            };
            forgetWPDDialog.Show();
            var forgetSelectedView = new FrameLayout()
            {
                BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor,
                Gravity = Gravity.Center,
                Width = Application.GetRealWidth(700),
                Height = Application.GetRealHeight(700),
                Radius = (uint)Application.GetRealHeight(30),
            };
            forgetWPDDialog.AddChidren(forgetSelectedView);
            var forgetByPhone = new Button()
            {
                Y = Application.GetRealHeight(100),
                Width = Application.GetRealWidth(600),
                Height = Application.GetRealHeight(100),
                TextID = R.MyInternationalizationString.FindPWDByPhone,
                TextColor = ZigbeeColor.Current.GXCTextWhiteColor,
                TextAlignment = TextAlignment.Center,
                BackgroundColor = ZigbeeColor.Current.GXCButtonBlueColor,
                Radius = (uint)Application.GetRealHeight(50),
                Gravity = Gravity.CenterHorizontal
            };
            forgetSelectedView.AddChidren(forgetByPhone);
            var forgetByEmail = new Button()
            {
                Y = Application.GetRealHeight(100) + forgetByPhone.Bottom,
                Width = Application.GetRealWidth(600),
                Height = Application.GetRealHeight(100),
                TextID = R.MyInternationalizationString.FindPWDByEmail,
                TextColor = ZigbeeColor.Current.GXCTextWhiteColor,
                TextAlignment = TextAlignment.Center,
                BackgroundColor = ZigbeeColor.Current.GXCButtonBlueColor,
                Radius = (uint)Application.GetRealHeight(50),
                Gravity = Gravity.CenterHorizontal
            };
            forgetSelectedView.AddChidren(forgetByEmail);
            var cancleBtn = new Button()
            {
                Y = Application.GetRealHeight(100) + forgetByEmail.Bottom,
                Width = Application.GetRealWidth(300),
                Height = Application.GetRealHeight(100),
                TextID = R.MyInternationalizationString.Cancel,
                TextColor = ZigbeeColor.Current.GXCTextWhiteColor,
                TextAlignment = TextAlignment.Center,
                BackgroundColor = ZigbeeColor.Current.GXCButtonBlueColor,
                Radius = (uint)Application.GetRealHeight(50),
                Gravity = Gravity.CenterHorizontal
            };
            forgetSelectedView.AddChidren(cancleBtn);
            forgetByPhone.MouseUpEventHandler += (sender1, e1) =>
            {
                forgetWPDDialog.Close();
                this.RemoveFromParent();
                var forgot = new Account.ForgotPasswordByPhone();
                CommonPage.Instance.AddChidren(forgot);
                forgot.Show();
            };
            forgetByEmail.MouseUpEventHandler += (sender1, e1) =>
            {
                forgetWPDDialog.Close();
                this.RemoveFromParent();
                var forgot = new Account.ForgotPasswordByEmail();
                CommonPage.Instance.AddChidren(forgot);
                forgot.Show();
            };
            cancleBtn.MouseUpEventHandler += (sender1, e1) =>
            {
                forgetWPDDialog.Close();
            };
            var forgot = new AccountForgetPWD();
            CommonPage.Instance.AddChidren(forgot);
            forgot.Show();
        }
        #endregion
@@ -547,8 +723,7 @@
        /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param>
        private void Register(object sender,MouseEventArgs mouseEventArgs)
        {
            this.RemoveFromParent();
            var registerPage = new RegistrationPhoneOREmail();
            var registerPage = new AccountRegister();
            Shared.Common.CommonPage.Instance.AddChidren(registerPage);
            registerPage.Show();
        }
@@ -574,18 +749,18 @@
        private void Pwd_TextChange(object sender,string mouseEventArgs)
        {
            loginErrorBtn.Text = "";
            if (1 <= passwrodET.Text.Trim().Length && passwrodET.Text.Trim().Length <= 16 && accountET.Text.Trim().Length > 0)
            if (1 <= pwdRow.PasswrodET.Text.Trim().Length && pwdRow.PasswrodET.Text.Trim().Length <= 16 && (phoneRow.AccountET.Text.Trim().Length > 0 || emailRow.AccountET.Text.Trim().Length>0))
            {
                loginBtn.Enable = loginBtn.IsSelected = true;
            }
            else if (passwrodET.Text.Trim().Length > 16)
            else if (pwdRow.PasswrodET.Text.Trim().Length > 16)
            {
                passwrodET.Text = mouseEventArgs.Remove(16);
                pwdRow.PasswrodET.Text = mouseEventArgs.Remove(16);
            }
            else if (passwrodET.Text.Trim().Length > 16 && accountET.Text.Trim().Length > 0)
            else if (pwdRow.PasswrodET.Text.Trim().Length > 16 && phoneRow.AccountET.Text.Trim().Length > 0)
            {
                loginBtn.Enable = loginBtn.IsSelected = true;
                passwrodET.Text = mouseEventArgs.Remove(16);
                pwdRow.PasswrodET.Text = mouseEventArgs.Remove(16);
            }
            else
            {
@@ -594,17 +769,7 @@
        }
        #endregion
        #region ◆ 密码隐藏__________________________
        private void HidePWD(object sender, MouseEventArgs mouseEventArgs)
        {
            passwrodET.SecureTextEntry = !passwrodET.SecureTextEntry;
            hidenPWDbtn.IsSelected = !hidenPWDbtn.IsSelected;
        }
        #endregion
    }
}