From dfa6733793434bdcfd394f978ae72f1628b2260f Mon Sep 17 00:00:00 2001
From: xm <1271024303@qq.com>
Date: 星期三, 22 四月 2020 16:50:03 +0800
Subject: [PATCH] 合并代码

---
 ZigbeeApp/Shared/Phone/Login/AccountLoginByCode.cs |  884 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 884 insertions(+), 0 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/Login/AccountLoginByCode.cs b/ZigbeeApp/Shared/Phone/Login/AccountLoginByCode.cs
new file mode 100755
index 0000000..db2e075
--- /dev/null
+++ b/ZigbeeApp/Shared/Phone/Login/AccountLoginByCode.cs
@@ -0,0 +1,884 @@
+锘縰sing System;
+using Shared.Common;
+using System.Text.RegularExpressions;
+using System.Collections.Generic;
+using System.Timers;
+using Shared.Phone.UserView;
+using Shared.Phone.Device.CommonForm;
+
+namespace Shared.Phone.Login
+{
+    /// <summary>
+    /// 楠岃瘉鐮佺櫥褰�
+    /// </summary>
+    public class AccountLoginByCode : FrameLayout
+    {
+
+        #region 鈼� 鍙橀噺____________________________
+        /// <summary>
+        /// 鑳屾櫙瑙嗗浘
+        /// </summary>
+        private FrameLayout midFrameLayout;
+        /// <summary>
+        /// 鎵嬫満閭
+        /// </summary>
+        private PhoneEmailForm phoneEmailForm;
+        /// <summary>
+        /// phoneRowForm
+        /// </summary>
+        private PhoneRowForm phoneRow;
+        /// <summary>
+        /// emailRow
+        /// </summary>
+        private EmailRowForm emailRow;
+        /// <summary>
+        /// codeRow
+        /// </summary>
+        private VerificationCodeRowForm codeRow;
+        /// <summary>
+        /// 璐﹀彿楠岃瘉鐮乫l
+        /// </summary>
+        private FrameLayout accountCodeFL;
+        /// <summary>
+        /// 鐧诲綍鎸夐挳
+        /// </summary>
+        private Button loginBtn;
+        /// <summary>
+        /// 蹇樿瀵嗙爜鎸夐挳
+        /// </summary>
+        private Button forgotPasswordBtn;
+        /// <summary>
+        /// 娉ㄥ唽
+        /// </summary>
+        private Button registerBtn;
+        /// <summary>
+        /// 璐﹀彿鐧诲綍
+        /// </summary>
+        private Button LoginByAccountPWDBtn;
+        /// <summary>
+        /// 鐧诲綍閿欒鎻愮ず鎸夐挳
+        /// </summary>
+        private Button loginErrorBtn;
+        /// <summary>
+        /// 璐﹀彿
+        /// </summary>
+        private string account;
+        /// <summary>
+        /// 楠岃瘉鐮�
+        /// </summary>
+        private string code;
+        /// <summary>
+        /// wechat
+        /// </summary>
+        private Button wechatBtn;
+
+        private Timer t;
+        private DateTime dateBegin;
+
+        #endregion
+
+
+        /// <summary>
+        /// The phone string.
+        /// </summary>
+        //public string phoneStr = "";
+        /// <summary>
+        /// 鎵嬫満鍙疯緭鍏ユ槸鍚︾鍚堣鍒�
+        /// </summary>
+        public bool IsRightAccount = false;
+        /// <summary>
+        /// Initializes a new instance of the <see cref="T:Shared.Phone.Device.Account.AccountLoginByCode"/> class.
+        /// </summary>
+        public AccountLoginByCode()
+        {
+            CommonPage.Instance.IsDrawerLockMode = true;
+            Tag = "Login";
+            BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor;
+            t = new Timer();
+            dateBegin = new DateTime();
+        }
+        public override void RemoveFromParent()
+        {
+            base.RemoveFromParent();
+        }
+        /// <summary>
+        /// Show this instance.
+        /// </summary>
+        public void Show()
+        {
+            ShowLoginByCodeView();
+        }
+        /// <summary>
+        /// Shows the login by code view.
+        /// </summary>
+        public void ShowLoginByCodeView()
+        {
+            #region midFrameLayout
+            midFrameLayout = new FrameLayout()
+            {
+                Width = LayoutParams.MatchParent,
+                Height = Application.GetRealHeight(CommonPage.AppRealHeight),
+                BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor
+            };
+            AddChidren(midFrameLayout);
+            #endregion
+
+            var logoBG = new Button()
+            {
+                Height = Application.GetRealHeight(619),
+                UnSelectedImagePath = "Account/Logo_loginBG.png"
+            };
+            midFrameLayout.AddChidren(logoBG);
+
+            var phoneEmailBGFL = new FrameLayout()
+            {
+                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(logo);
+
+            var logoName = new Button()
+            {
+                Y = logo.Bottom,
+                Height = Application.GetRealHeight(69),
+                Width = Application.GetRealWidth(300),
+                Gravity = Gravity.CenterHorizontal,
+                TextID = R.MyInternationalizationString.AppName,
+                TextColor = ZigbeeColor.Current.GXCTextWhiteColor,
+                TextSize = 16
+            };
+            midFrameLayout.AddChidren(logoName);
+
+            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(58),
+                TextColor = ZigbeeColor.Current.GXCTextRed,
+                TextAlignment = TextAlignment.CenterLeft,
+                TextSize = CommonFormResouce.TextSize,
+                IsBold = true
+            };
+            midFrameLayout.AddChidren(loginErrorBtn);
+
+            accountCodeFL = new FrameLayout()
+            {
+                Y = Application.GetRealHeight(801),
+                Height = Application.GetRealHeight(553),
+                Width = Application.GetRealWidth(942),
+                Gravity = Gravity.CenterHorizontal,
+                BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor,
+                Radius = (uint)Application.GetRealHeight(17)
+            };
+            midFrameLayout.AddChidren(accountCodeFL);
+
+            AddPhoneOrEmailFL(accountCodeFL, "Phone");
+
+            forgotPasswordBtn = new Button()
+            {
+                X = Application.GetRealWidth(CommonPage.AppRealWidth - 115 - 250),
+                Y = Application.GetRealHeight(1198),
+                Width = Application.GetRealWidth(250),
+                Height = Application.GetRealHeight(58),
+                TextID = R.MyInternationalizationString.ForgotPWD_1,
+                TextSize = CommonFormResouce.loginTextSize,
+                TextColor = Shared.Common.ZigbeeColor.Current.GXCTextGrayColor,
+                TextAlignment = TextAlignment.CenterRight
+            };
+            midFrameLayout.AddChidren(forgotPasswordBtn);
+
+            loginBtn = new Button()
+            {
+                Y = Application.GetRealHeight(1281),
+                Width = Application.GetRealWidth(688),
+                Height = Application.GetRealHeight(127),
+                Gravity = Gravity.CenterHorizontal,
+                TextID = R.MyInternationalizationString.Login,
+                TextSize = 16,
+                IsBold=true,
+                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(codeRow.VerificationCodeET?.Text),
+                IsSelected = !string.IsNullOrEmpty(codeRow.VerificationCodeET?.Text)
+            };
+            midFrameLayout.AddChidren(loginBtn);
+
+            LoginByAccountPWDBtn = new Button()
+            {
+                X = Application.GetRealWidth(98),
+                Y = Application.GetRealHeight(1466),
+                Width = Application.GetRealWidth(300),
+                Height = Application.GetRealHeight(49),
+                TextID = R.MyInternationalizationString.LoginByAccountPWD,
+                TextColor = ZigbeeColor.Current.GXCTextGrayColor,
+                TextAlignment = TextAlignment.CenterLeft,
+                TextSize = CommonFormResouce.loginTextSize
+            };
+            midFrameLayout.AddChidren(LoginByAccountPWDBtn);
+
+            registerBtn = new Button()
+            {
+                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);
+
+            BindEvent();
+        }
+
+        #region 鈼� 缁戝畾浜嬩欢_________________________
+
+        /// <summary>
+        /// 缁戝畾鎸夐挳浜嬩欢
+        /// </summary>
+        private void BindEvent()
+        {
+            //閫夋嫨鎵嬫満閭
+            phoneEmailForm.SelectedPhone.MouseUpEventHandler += SelectPhoneOrEmail_MouseUpEvent;
+            phoneEmailForm.SelectedEmail.MouseUpEventHandler += SelectPhoneOrEmail_MouseUpEvent;
+            //鐧诲綍浜嬩欢
+            loginBtn.MouseUpEventHandler += LoginBtnEvent;
+            //璐﹀彿鐧诲綍
+            LoginByAccountPWDBtn.MouseUpEventHandler += LoginByPWD;
+            //娉ㄥ唽浜嬩欢
+            registerBtn.MouseUpEventHandler += Register;
+            //蹇樿瀵嗙爜
+            forgotPasswordBtn.MouseUpEventHandler += ForgetPWD_MouseUpEvent;
+            //wechat
+            wechatBtn.MouseUpEventHandler += LoginByWechat;
+
+        }
+
+        #endregion
+
+
+        #region 鈼� 鐧诲綍____________________________
+
+        /// <summary>
+        /// 鐧诲綍浜嬩欢
+        /// </summary>
+        /// <param name="sender">Sender.</param>
+        /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param>
+        private async void LoginBtnEvent(object sender, MouseEventArgs mouseEventArgs)
+        {
+            CommonPage.Loading.Start();
+            try
+            {
+                if (CheckAccount(account) == false)
+                {
+                    return;
+                }
+                var reqLoginByCode = new SendDataToServer.LoginValidCodeOBJ()
+                {
+                    Account = account,
+                    Code = code,
+                    Language = CommonPage.ZigBeeLanguage,
+                    AreaCode = int.Parse(CommonPage.PhoneZoneStr)
+                };
+                var requestRevetLoginCodeOBJ = await CommonFormResouce.LoginByCode(reqLoginByCode);
+                if (requestRevetLoginCodeOBJ == null)
+                {
+                    CommonPage.Instance.FailureToServer();
+                    return;
+                }
+                var stateCodeStr = requestRevetLoginCodeOBJ.StateCode.ToUpper();
+                if (stateCodeStr == "SUCCESS")
+                {
+                    if (requestRevetLoginCodeOBJ.ResponseData == null)
+                    {
+                        return;
+                    }
+
+                    HomePage.Instance.ShowLoginLoadView();
+                    new System.Threading.Thread(async () =>
+                    {
+                        var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<Shared.Common.ResponseEntity.UserLoginRes>(requestRevetLoginCodeOBJ.ResponseData.ToString());
+                        var revertData = responseDataObj;
+                        Config.ReFresh();
+                        //鏍囪涓婁竴娆℃槸涓嶆槸鍚屼竴涓处鍙风櫥闄�
+                        UserCenter.UserCenterResourse.ResidenceOption.TheSameLoginAccount = Config.Instance.Guid == revertData.Guid;
+                        Config.Instance.Password = string.Empty;
+                        Config.Instance.Account = revertData.Account;
+                        Config.Instance.Guid = revertData.Guid;
+                        Config.Instance.MD5PWD = revertData.MD5PWD;
+                        Config.Instance.LoginDateTime = DateTime.Now;
+                        Config.Instance.LoginToken = revertData.Token;
+                        //闇�瑕佹妸鐧诲綍鍚庤繑鍥炵殑md5瀵嗙爜 璧嬪�肩敓鎴怲oken  鍥犱负鐢ㄦ埛娌℃湁杈撳叆瀵嗙爜
+                        Config.Instance.MD5PWD = revertData.MD5PWD;
+                        Config.Instance.Save();
+                        var resultRegID = await CommonPage.Instance.PushRegID();
+                        var homes = await House.GetHomeLists();
+    
+                        //鍒锋柊涓汉涓績鐨勫唴瀛樺強绾跨▼
+                        await UserCenter.UserCenterLogic.InitUserCenterMenmoryAndThread();
+                        //鍚姩ZigBee
+                        ZigBee.Common.Application.Init();
+
+                        UserCenter.HdlRoomLogic.Current.InitAllRoom();
+                        Application.RunOnMainThread(() =>
+                        {
+                            this.RemoveFromParent();
+                            CommonPage.Instance.RemoveViewByTag("Login");
+                            UserPage.Instance.Fresh();
+                            CommonPage.Loading.Hide();
+                        });
+                    })
+                    { IsBackground = true }.Start();
+                }
+                else if (stateCodeStr == "NOTVERIFY")
+                {
+                    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;
+                }
+                else if (stateCodeStr == "PARAMETEROREMPTY")
+                {
+                    CommonPage.Loading.Hide();
+                    //鎻愪緵鐨勫弬鏁伴敊璇�
+                    loginErrorBtn.TextID = R.MyInternationalizationString.PARAMETEROREMPTY;
+                }
+                else if (stateCodeStr == "VALIDCODEANDPHONENOEQUAL")
+                {
+                    CommonPage.Loading.Hide();
+                    loginErrorBtn.TextID = R.MyInternationalizationString.VALIDCODEANDPHONENOEQUAL;
+                }
+                else if (stateCodeStr == "NORECORD")
+                {
+                    CommonPage.Loading.Hide();
+                    loginErrorBtn.TextID = R.MyInternationalizationString.NORECORD;
+                }
+                else if (stateCodeStr == "YOUDATANOISLOCALREGION")
+                {
+                    CommonPage.Loading.Hide();
+                    //涓嶅湪鏈尯鍩燂紝闇�瑕侀噸瀹氬悜鍖哄煙鍚庡啀娆¤姹傜櫥褰�
+                    if (requestRevetLoginCodeOBJ.ResponseData == null)
+                    {
+                        return;
+                    }
+                    var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<Shared.Common.ResponseEntity.UserLoginLocalRegionRes>(requestRevetLoginCodeOBJ.ResponseData.ToString());
+                    CommonPage.RequestHttpsHost = responseDataObj.RegionServer;
+                    //鍐嶆鐧诲綍
+                    //loginByCode();
+                }
+                else
+                {
+                    CommonPage.Loading.Hide();
+                    loginErrorBtn.TextID = R.MyInternationalizationString.RequestServerFailed;
+                }
+            }
+            catch
+            {
+                CommonPage.Loading.Hide();
+                CommonPage.Instance.FailureToServer();
+            }
+            finally
+            {
+                CommonPage.Loading.Hide();
+            }
+
+        }
+
+        /// <summary>
+        /// 閫氳繃瀵嗙爜鐧诲綍
+        /// </summary>
+        /// <param name="sender">Sender.</param>
+        /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param>
+        private void LoginByPWD(object sender, MouseEventArgs mouseEventArgs)
+        {
+            this.RemoveFromParent();
+            var login = new AccountLogin();
+            Shared.Common.CommonPage.Instance.AddChidren(login);
+            login.Show();
+        }
+
+        /// <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;
+            phoneEmailForm.SelectedPhone.IsBold = phoneEmailForm.SelectedEmail.IsBold = false;
+            loginBtn.Enable = loginBtn.IsSelected = false;
+            (sender as Button).IsSelected = (sender as Button).IsBold = true;
+            if ((sender as Button).Tag.ToString() == "Phone")
+            {
+                AddPhoneOrEmailFL(accountCodeFL, "Phone");
+            }
+            else
+            {
+                AddPhoneOrEmailFL(accountCodeFL, "Email");
+            }
+        }
+        /// <summary>
+        /// AddPhoneOrEmailFL
+        /// </summary>
+        /// <param name="accountCodeFrameLayout"></param>
+        /// <param name="phoneOrEmail"></param>
+        private void AddPhoneOrEmailFL(FrameLayout accountCodeFrameLayout, string phoneOrEmail)
+        {
+            accountCodeFrameLayout.RemoveAll();
+            account = string.Empty;
+            loginErrorBtn.Text = string.Empty;
+            if (phoneOrEmail == "Phone")
+            {
+                phoneRow = new PhoneRowForm();
+                phoneRow.Init(accountCodeFrameLayout, this, this.account, 29, 29);
+                phoneRow.AccountET.TextChangeEventHandler += Account_TextChange;
+            }
+            else
+            {
+                emailRow = new EmailRowForm();
+                emailRow.Init(accountCodeFrameLayout, this.account, 29, 29);
+                emailRow.AccountET.TextChangeEventHandler += Account_TextChange;
+            }
+
+            codeRow = new VerificationCodeRowForm();
+            codeRow.Init(accountCodeFrameLayout, 29, 225);
+            codeRow.SendCodeBtn.MouseUpEventHandler += SendCode_MouseUpEventAsync;
+            codeRow.VerificationCodeET.TextChangeEventHandler += Code_TextChange;
+        }
+
+        /// <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();
+                            UserCenter.HdlRoomLogic.Current.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();
+                            UserCenter.HdlRoomLogic.Current.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;
+                //鏍囪涓婁竴娆℃槸涓嶆槸鍚屼竴涓处鍙风櫥闄�
+                UserCenter.UserCenterResourse.ResidenceOption.TheSameLoginAccount = Config.Instance.Guid == revertData.Guid;
+                Config.Instance.Account = revertData.Account;
+                Config.Instance.MD5PWD = revertData.MD5PWD;
+                Config.Instance.Guid = revertData.Guid;
+                Config.Instance.LoginDateTime = DateTime.Now;
+                Config.Instance.Save();
+                return true;
+            }
+            else
+            {
+                return false;
+            }
+        }
+
+        #endregion
+
+        #region 鈼� 璐﹀彿銆侀獙璇佺爜鐩戝惉______________________
+        /// <summary>
+        /// 璐﹀彿鐩戝惉
+        /// </summary>
+        /// <param name="sender">Sender.</param>
+        /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param>
+        private void Account_TextChange(object sender, string mouseEventArgs)
+        {
+            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;
+            }
+        }
+
+        /// <summary>
+        /// code鐩戝惉浜嬩欢
+        /// </summary>
+        /// <param name="sender">Sender.</param>
+        /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param>
+        private void Code_TextChange(object sender, string mouseEventArgs)
+        {
+            loginErrorBtn.Text = "";
+            if ((sender as EditText).Text.Trim().Length > 0 && IsRightAccount)
+            {
+                loginBtn.Enable = loginBtn.IsSelected = true;
+            }
+            else
+            {
+                loginBtn.Enable = loginBtn.IsSelected = false;
+            }
+            code = (sender as EditText).Text.Trim();
+        }
+
+        #endregion
+
+
+        void TimeOut(object sender, System.Timers.ElapsedEventArgs e)
+        {
+            var span = DateTime.Now - dateBegin;
+            if (span.TotalSeconds <= 61)
+            {
+                Application.RunOnMainThread(() =>
+                {
+                    codeRow.SendCodeBtn.Text = Convert.ToInt16(60 - span.TotalSeconds) + "s" + Language.StringByID(R.MyInternationalizationString.SendVerificationCodeAgain);
+                    codeRow.SendCodeBtn.Enable = false;
+                });
+            }
+            else
+            {
+                Application.RunOnMainThread(() =>
+                {
+                    codeRow.SendCodeBtn.Enable = true;
+                    codeRow.SendCodeBtn.TextID = R.MyInternationalizationString.SendVerificationCode;
+                    t.Stop();
+                    t.Close();
+                });
+            }
+        }
+
+        void TimeBegin()
+        {
+            t.Interval = 1000;
+            t.AutoReset = true;
+            t.Enabled = true;
+            t.Elapsed += TimeOut;
+            //鍚姩璁℃椂鍣ㄥ�掕鏃�-60s
+            t.Start();
+            dateBegin = DateTime.Now;
+        }
+
+        #region 鈼� 娉ㄥ唽_____________________________
+
+        /// <summary>
+        /// 娉ㄥ唽
+        /// </summary>
+        /// <param name="sender">Sender.</param>
+        /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param>
+        private void Register(object sender, MouseEventArgs mouseEventArgs)
+        {
+            this.RemoveFromParent();
+            var registerPage = new AccountRegister();
+            CommonPage.Instance.AddChidren(registerPage);
+            registerPage.Show();
+        }
+
+        #endregion
+
+        #region 鈼� 蹇樿瀵嗙爜________________________
+        /// <summary>
+        /// 蹇樿瀵嗙爜
+        /// </summary>
+        private void ForgetPWD_MouseUpEvent(object sender, MouseEventArgs mouseEventArgs)
+        {
+            this.RemoveFromParent();
+            var forgot = new AccountForgetPWD();
+            CommonPage.Instance.AddChidren(forgot);
+            forgot.Show();
+        }
+
+        #endregion
+
+        #region 鈼� 鍙戦�侀獙璇佺爜________________________
+        /// <summary>
+        /// 鍙戦�侀獙璇佺爜
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <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
+            {
+                int companyInt = 0;
+                if (CommonPage.PhoneZoneStr == "86" || phoneEmailForm.SelectedEmail.IsSelected)
+                {
+                    companyInt = CommonPage.Company;
+                }
+                else
+                {
+                    companyInt = CommonPage.CompanyForINTERNETION;
+                }
+                var reqDtoSignPhone = new SendDataToServer.LoginSendVerCodeObj()
+                {
+                    Account = account,
+                    Company = companyInt,
+                    AreaCode = int.Parse(CommonPage.PhoneZoneStr),
+                    Language = CommonPage.ZigBeeLanguage
+                };
+                var requestRevertObj = await CommonFormResouce.LoginSendVerCode(reqDtoSignPhone);
+                if (requestRevertObj == null)
+                {
+                    CommonPage.Instance.FailureToServer();
+                    return;
+                }
+                var stateCodeStr = requestRevertObj.StateCode.ToUpper();
+                if (stateCodeStr == "SUCCESS")
+                {
+                    TimeBegin();
+                    var alert = new Alert(Language.StringByID(R.MyInternationalizationString.TIP), Language.StringByID(R.MyInternationalizationString.SendVerificationCodeSuccess), Language.StringByID(R.MyInternationalizationString.Confrim));
+                    alert.Show();
+                }
+                else if (stateCodeStr == "PARAMETEROREMPTY")
+                {
+                    //鎻愪緵鐨勫弬鏁伴敊璇�
+                    loginErrorBtn.TextID = R.MyInternationalizationString.PARAMETEROREMPTY;
+                    (sender as Button).Enable = (sender as Button).IsSelected = true;
+                }
+                else if (stateCodeStr == "ACCOUNTNOEXISTS")
+                {
+                    //璐﹀彿涓嶅瓨鍦�
+                    loginErrorBtn.TextID = R.MyInternationalizationString.ACCOUNTNOEXISTS;
+                    IsRightAccount = false;
+                    (sender as Button).Enable = (sender as Button).IsSelected = true;
+                }
+                else if (stateCodeStr == "SENDFAIL")
+                {
+                    //楠岃瘉鐮佸彂閫佸け璐�
+                    loginErrorBtn.TextID = R.MyInternationalizationString.SENDFAIL;
+                    (sender as Button).Enable = (sender as Button).IsSelected = true;
+                }
+                else
+                {
+                    loginErrorBtn.TextID = R.MyInternationalizationString.RequestServerFailed;
+                    (sender as Button).Enable = (sender as Button).IsSelected = true;
+                }
+            }
+            catch
+            {
+                loginErrorBtn.TextID = R.MyInternationalizationString.RequestServerFailed;
+                (sender as Button).Enable = (sender as Button).IsSelected = true;
+            }
+            finally
+            {
+                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 鈼� 楠岃瘉楠岃瘉鐮乢_______________________
+
+
+
+        #endregion
+    }
+}

--
Gitblit v1.8.0