From b9cb076fe6127160c96c35bf9c8cebcffe1d5ccd Mon Sep 17 00:00:00 2001
From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local>
Date: 星期五, 10 一月 2020 17:35:23 +0800
Subject: [PATCH] 2020.1.10

---
 ZigbeeApp/Shared/Phone/Device/Account/AccountRegister.cs |  107 +++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 86 insertions(+), 21 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/Device/Account/AccountRegister.cs b/ZigbeeApp/Shared/Phone/Device/Account/AccountRegister.cs
old mode 100755
new mode 100644
index b8d089e..ed300a9
--- a/ZigbeeApp/Shared/Phone/Device/Account/AccountRegister.cs
+++ b/ZigbeeApp/Shared/Phone/Device/Account/AccountRegister.cs
@@ -55,12 +55,17 @@
         /// 璐﹀彿
         /// </summary>
         private string account;
+        /// <summary>
+        /// OpenID
+        /// </summary>
+        public string OpenID;
 
         #endregion
 
         #region 鈼� 鏋勯�犳柟娉昣________________________
         public AccountRegister()
         {
+            CommonPage.Instance.IsDrawerLockMode = true;
             BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor;
             Tag = "Register";
         }
@@ -76,7 +81,6 @@
             AddTopFL();
             //AddBody
             AddBodyView();
-
 
             //bind
             BindEvent();
@@ -124,7 +128,7 @@
                 Width = Application.GetRealWidth(942),
                 Gravity = Gravity.CenterHorizontal,
                 BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor,
-                Radius = (uint)Application.GetRealHeight(30)
+                Radius = (uint)Application.GetRealHeight(17)
             };
             bodyFrameLayout.AddChidren(accountCodeFL);
 
@@ -139,6 +143,8 @@
                 Height = Application.GetRealHeight(58),
                 TextColor = ZigbeeColor.Current.GXCTextRed,
                 TextAlignment = TextAlignment.CenterLeft,
+                TextSize = CommonFormResouce.TextSize,
+                IsBold = true
             };
             bodyFrameLayout.AddChidren(errorBtn);
 
@@ -155,7 +161,9 @@
                 BackgroundColor = ZigbeeColor.Current.GXCButtonUnSelectedColor,
                 Radius = (uint)Application.GetRealHeight(127 / 2),
                 Enable = !string.IsNullOrEmpty(codeRow.VerificationCodeET?.Text),
-                IsSelected = !string.IsNullOrEmpty(codeRow.VerificationCodeET?.Text)
+                IsSelected = !string.IsNullOrEmpty(codeRow.VerificationCodeET?.Text),
+                TextSize = 16,
+                IsBold = true,
             };
             bodyFrameLayout.AddChidren(registerBtn);
 
@@ -164,7 +172,7 @@
                 Y = registerBtn.Bottom + Application.GetRealHeight(50),
                 Width = Application.GetRealWidth(400),
                 Height = Application.GetRealHeight(58),
-                TextID = R.MyInternationalizationString.LoginByAccountPWD,
+                TextID = R.MyInternationalizationString.LoginByAccountPWD_1,
                 TextColor = ZigbeeColor.Current.GXCTextGrayColor,
                 TextSize = CommonFormResouce.loginTextSize,
                 Gravity=Gravity.CenterHorizontal
@@ -184,8 +192,11 @@
         private void SelectPhoneOrEmail_MouseUpEvent(object sender, MouseEventArgs mouseEventArgs)
         {
             phoneEmailForm.SelectedPhone.IsSelected = phoneEmailForm.SelectedEmail.IsSelected = false;
+            phoneEmailForm.SelectedPhone.IsBold = phoneEmailForm.SelectedEmail.IsBold = false;
             registerBtn.Enable = registerBtn.IsSelected = false;
-            (sender as Button).IsSelected = true;
+            (sender as Button).IsSelected = (sender as Button).IsBold = true;
+            account = string.Empty;
+            errorBtn.Text = string.Empty;
             if ((sender as Button).Tag.ToString() == "Phone")
             {
                 AddPhoneOrEmailFL(accountCodeFL, "Phone");
@@ -204,7 +215,6 @@
         private void AddPhoneOrEmailFL(FrameLayout accountCodeFrameLayout, string phoneOrEmail)
         {
             accountCodeFrameLayout.RemoveAll();
-
             if (phoneOrEmail == "Phone")
             {
                 phoneRow = new PhoneRowForm();
@@ -219,11 +229,11 @@
             }
             pwdRow = new PwdRowForm();
             pwdRow.Init(accountCodeFrameLayout, 29, 196);
-            //pwdRow.PasswrodET.TextChangeEventHandler += Account_TextChange;
+            pwdRow.PasswrodET.TextChangeEventHandler += Code_TextChange;
 
             pwdComfireRow = new PwdRowForm();
             pwdComfireRow.Init(accountCodeFrameLayout, 29, 363);
-            //pwdComfireRow.PasswrodET.TextChangeEventHandler += Account_TextChange;
+            pwdComfireRow.PasswrodET.TextChangeEventHandler += Code_TextChange;
             pwdComfireRow.SetPlaceholdText(Language.StringByID(R.MyInternationalizationString.PleaseComfirePWD));
 
             codeRow = new CodeForRegisterRowForm();
@@ -245,6 +255,7 @@
             phoneEmailForm.SelectedEmail.MouseUpEventHandler += SelectPhoneOrEmail_MouseUpEvent;
             registerBtn.MouseUpEventHandler += Register;
             loginByAccountPWDBtn.MouseUpEventHandler += LoginByPWD;
+            codeRow.VerificationCodeET.TextChangeEventHandler += Code_TextChange;
         }
         #endregion
 
@@ -256,6 +267,22 @@
         /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param>
         private async void Register(object sender, MouseEventArgs mouseEventArgs)
         {
+            if (CheckAccount(account) == false)
+            {
+                return;
+            }
+            if (pwdRow.PasswrodET.Text.Trim() != pwdComfireRow.PasswrodET.Text.Trim())
+            {
+                errorBtn.TextID = R.MyInternationalizationString.TwoPasswordInconsistency;
+                return;
+            }
+
+            if (AccountLogic.Instance.CheckPwdLength(pwdRow.PasswrodET.Text.Trim()) == false)
+            {
+                errorBtn.TextID = R.MyInternationalizationString.ThePWDLengthError;
+                return;
+            }
+
             CommonPage.Loading.Start();
             try
             {
@@ -281,7 +308,7 @@
                 {
                     var registerSuccess = new Account.AccountRegisterSuccess();
                     CommonPage.Instance.AddChidren(registerSuccess);
-                    registerSuccess.Show(account, pwdRow.PasswrodET.Text.Trim());
+                    registerSuccess.Show(account, pwdRow.PasswrodET.Text.Trim(), OpenID);
                 }
                 else if (stateCodeStr == "EXIST")
                 {
@@ -302,6 +329,10 @@
                 {
                     //楠岃瘉鐮侀敊璇�
                     errorBtn.TextID = R.MyInternationalizationString.VALIDCODEANDPHONENOEQUAL;
+                }
+                else if (stateCodeStr == "NORECORD")
+                {
+                    errorBtn.TextID = R.MyInternationalizationString.NORECORD;
                 }
                 else
                 {
@@ -341,15 +372,13 @@
         /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param>
         private void Account_TextChange(object sender, string mouseEventArgs)
         {
-            errorBtn.Text = "";
+            errorBtn.Text = string.Empty;
             if ((sender as EditText).Text.Trim().Length > 0)
             {
-                //IsRightAccount = true;
                 codeRow.SendCodeBtn.Enable = codeRow.SendCodeBtn.IsSelected = true;
             }
             else
             {
-                //IsRightAccount = false;
                 codeRow.SendCodeBtn.Enable = codeRow.SendCodeBtn.IsSelected = false;
             }
             account = (sender as EditText).Text.Trim();
@@ -362,8 +391,8 @@
         /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param>
         private void Code_TextChange(object sender, string mouseEventArgs)
         {
-            errorBtn.Text = "";
-            if ((sender as EditText).Text.Trim().Length > 0)
+            errorBtn.Text = string.Empty;
+            if (codeRow.VerificationCodeET.Text.Trim().Length > 0 && account.Trim().Length > 0 && pwdRow.PasswrodET.Text.Trim().Length > 0 && pwdComfireRow.PasswrodET.Text.Trim().Length > 0)
             {
                 registerBtn.Enable = registerBtn.IsSelected = true;
             }
@@ -383,15 +412,23 @@
         /// <param name="mouseEventArgs"></param>
         private async void SendCode_MouseUpEventAsync(object sender, MouseEventArgs mouseEventArgs)
         {
-            (sender as Button).Enable = (sender as Button).IsSelected = false;
-            //鍏堝垽鏂�2娆″瘑鐮佽緭鍏ユ槸鍚︿竴鑷�
-            if (pwdRow.PasswrodET.Text.Trim() != pwdComfireRow.PasswrodET.Text.Trim())
-            { 
-                var alert = new Alert(Language.StringByID(R.MyInternationalizationString.TIP), Language.StringByID(R.MyInternationalizationString.TwoPasswordInconsistency), Language.StringByID(R.MyInternationalizationString.Confrim));
-                alert.Show();
-                codeRow.SendCodeBtn.Enable = codeRow.SendCodeBtn.IsSelected = false;
+            if (CheckAccount(account) == false)
+            {
                 return;
             }
+            //鍏堝垽鏂�2娆″瘑鐮佽緭鍏ユ槸鍚︿竴鑷�
+            if (pwdRow.PasswrodET.Text.Trim() != pwdComfireRow.PasswrodET.Text.Trim())
+            {
+                errorBtn.TextID = R.MyInternationalizationString.TwoPasswordInconsistency;
+                return;
+            }
+
+            if (AccountLogic.Instance.CheckPwdLength(pwdRow.PasswrodET.Text.Trim()) == false)
+            {
+                errorBtn.TextID = R.MyInternationalizationString.ThePWDLengthError;
+                return;
+            }
+
             CommonPage.Loading.Start();
             (sender as Button).Enable = (sender as Button).IsSelected = false;
             try
@@ -459,6 +496,34 @@
                 CommonPage.Loading.Hide();
             }
         }
+
+        /// <summary>
+        /// CheckAccount
+        /// </summary>
+        /// <param name="accountStr"></param>
+        /// <returns></returns>
+        private bool CheckAccount(string accountStr)
+        {
+            errorBtn.Text = string.Empty;
+            if (phoneEmailForm.SelectedEmail.IsSelected)
+            {
+                if (AccountLogic.Instance.CheckEmail(accountStr) == false)
+                {
+                    errorBtn.TextID = R.MyInternationalizationString.TheEmailError;
+                    return false;
+                }
+            }
+            else
+            {
+                if (AccountLogic.Instance.CheckPhoneWithZone(accountStr, CommonPage.PhoneZoneStr) == false)
+                {
+                    errorBtn.TextID = R.MyInternationalizationString.ThePhoneError;
+                    return false;
+                }
+            }
+            return true;
+        }
+
         #endregion
     }
 }
\ No newline at end of file

--
Gitblit v1.8.0