From 7ed9cc5bb6a07a8358a2705797bd2b31c6e39fd4 Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期四, 07 一月 2021 18:33:34 +0800 Subject: [PATCH] 2021-01-07 1.注册功能,忘记密码功能相关接口替换,UI界面修改调整。 --- Crabtree/SmartHome/UI/SimpleControl/Phone/Register/AccountRegistration.cs | 411 ++++++++++++++++++++++++++++++++++----------------------- 1 files changed, 244 insertions(+), 167 deletions(-) diff --git a/Crabtree/SmartHome/UI/SimpleControl/Phone/Register/AccountRegistration.cs b/Crabtree/SmartHome/UI/SimpleControl/Phone/Register/AccountRegistration.cs index b3fff6e..b0fde58 100644 --- a/Crabtree/SmartHome/UI/SimpleControl/Phone/Register/AccountRegistration.cs +++ b/Crabtree/SmartHome/UI/SimpleControl/Phone/Register/AccountRegistration.cs @@ -5,6 +5,11 @@ { public class AccountRegistration_Crabtree : Dialog { + /// <summary> + /// + /// </summary> + PageLayout bodyPageView; + public AccountRegistration_Crabtree () { BackgroundColor = SkinStyle.Current.MainColor; @@ -49,37 +54,171 @@ new AccountLogin ().Show (); }; - var bodyView = new FrameLayout () { + bodyPageView = new PageLayout () { Width = LayoutParams.MatchParent, - Height = Application.GetRealHeight (1136 - 126), + Height = Application.GetRealHeight (Application.DesignHeight - 126), Y = topView.Bottom, BackgroundColor = SkinStyle.Current.ViewColor, }; - AddChidren (bodyView); - bodyView.MouseDownEventHandler += (sender, e) => { + AddChidren (bodyPageView); + + bodyPageView.PageChange += (sender, e) => { + //2020-09-04 淇瀹夊崜鍙虫粦闂��闂 + if (e < bodyPageView.ChildrenCount - 1) { + bodyPageView.GetChildren (bodyPageView.ChildrenCount - 1).RemoveFromParent (); + } + }; + bodyPageView.MouseDownEventHandler += (sender, e) => { Application.HideSoftInput (); }; + FrameLayout bodyView = new FrameLayout (); + bodyPageView.AddChidren (bodyView); + bodyPageView.IsShowPoint = false; EmailRegistrationView (bodyView); } + + /// <summary> + /// 閭娉ㄥ唽椤甸潰 + /// </summary> + /// <param name="registrationView"></param> void EmailRegistrationView (FrameLayout registrationView) { + registrationView.RemoveAll (); + Button btnEmail = new Button () { + Width = Application.GetRealWidth (500), + Height = Application.GetRealWidth (85), + Gravity = Gravity.CenterHorizontal, + Y = Application.GetRealWidth (20), + TextID = R.MyInternationalizationString.EmailAddress, + TextAlignment = TextAlignment.CenterLeft, + TextSize = 12, + TextColor = SkinStyle.Current.TextColor1, + }; + registrationView.AddChidren (btnEmail); + + FrameLayout EmailView = new FrameLayout () { + Width = Application.GetRealWidth (500), + Height = Application.GetRealWidth (85), + Gravity = Gravity.CenterHorizontal, + Y = btnEmail.Bottom, + BorderWidth = 1, + Radius = 5, + BorderColor = SkinStyle.Current.BorderColor, + //Text = "1270166900@qq.com" + }; + registrationView.AddChidren (EmailView); + + EditText etEmailAddress = new EditText () { + TextAlignment = TextAlignment.Center, + TextColor = SkinStyle.Current.TextColor1, + PlaceholderText = Language.StringByID (R.MyInternationalizationString.EmailAddress), + PlaceholderTextColor = SkinStyle.Current.PlaceholderTextColor, + }; + EmailView.AddChidren (etEmailAddress); + + Button btnNext = new Button () { + Y = EmailView.Bottom + Application.GetRealWidth (20), + Width = Application.GetRealWidth (500), + Height = Application.GetRealWidth (85), + Gravity = Gravity.CenterHorizontal, + BackgroundColor = SkinStyle.Current.MainColor, + SelectedBackgroundColor = SkinStyle.Current.SelectedColor, + TextID = R.MyInternationalizationString.Next, + TextColor = SkinStyle.Current.TextColor1, + Radius = 5, + BorderColor = SkinStyle.Current.Transparent, + BorderWidth = 0, + TextSize = 18, + TextAlignment = TextAlignment.Center, + }; + registrationView.AddChidren (btnNext); + btnNext.MouseDownEventHandler += (sender, e) => { + btnNext.IsSelected = true; + }; + + btnNext.MouseUpEventHandler += (sender, e) => { + btnNext.IsSelected = false; + string account = etEmailAddress.Text.Trim (); + if (!CommonUtlis.Current.CheckEmail (account)) { + new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.PleaseCheckEmailAddressCorrectly), + Language.StringByID (R.MyInternationalizationString.Close)).Show (); + return; + } + + SendVerificationCode (account, false); + }; + + } + + /// <summary> + /// 鎵嬫満鎴栬�呴偖绠卞彂閫侀獙璇佺爜骞跺姞杞藉搴旂殑娉ㄥ唽椤甸潰 + /// </summary> + /// <param name="account">璐﹀彿 閭鎴栬�呮墜鏈哄彿</param> + /// <param name="isPhone">鏄惁鏄墜鏈�</param> + void SendVerificationCode (string account, bool isPhone = true) + { + MainPage.Loading.Start (Language.StringByID (R.MyInternationalizationString.load)); + System.Threading.Tasks.Task.Run (() => { + try { + var requestRevertObj = HttpServerRequest.Current.VerificationCodeSend (VerifyType.REGISTER_USER, account); + if (requestRevertObj.Code == StateCode.SUCCESS) { + Application.RunOnMainThread (() => { + // isPhone 鏄惁鏄墜鏈� + InitSMSView (account, false); + bodyPageView.PageIndex = bodyPageView.ChildrenCount - 1; + }); + } else { + //鎻愮ず閿欒 + IMessageCommon.Current.ShowErrorInfoAlter (requestRevertObj.Code); + } + } catch { + MainPage.FailureToServer (); + } finally { + Application.RunOnMainThread (() => { + MainPage.Loading.Hide (); + }); + } + }); + } + + /// <summary> + /// 楠岃瘉楠岃瘉鐮佸苟鎻愪氦娉ㄥ唽 + /// </summary> + /// <param name="mAccount"></param> + /// <param name="bPhone"></param> + void InitSMSView (string mAccount, bool bPhone = true) + { + FrameLayout mobileChencView = new FrameLayout (); + bodyPageView.AddChidren (mobileChencView); + + Button btnAccount = new Button () { + Gravity = Gravity.CenterHorizontal, + Y = Application.GetRealWidth (20), + Width = Application.GetRealWidth (500), + Height = Application.GetRealWidth (50), + Text = mAccount, + TextColor = SkinStyle.Current.TextColor1, + TextAlignment = TextAlignment.Center, + }; + mobileChencView.AddChidren (btnAccount); + Button btnName = new Button () { Width = Application.GetRealWidth (500), - Height = Application.GetRealHeight (85), + Height = Application.GetRealWidth (85), X = Application.GetRealWidth (70), - Y = Application.GetRealHeight (20), + Y = Application.GetRealWidth (70), TextID = R.MyInternationalizationString.Name, TextAlignment = TextAlignment.CenterLeft, TextSize = 12, TextColor = SkinStyle.Current.TextColor1, }; - registrationView.AddChidren (btnName); + mobileChencView.AddChidren (btnName); EditText etName = new EditText () { Width = Application.GetRealWidth (500), - Height = Application.GetRealHeight (85), + Height = Application.GetRealWidth (85), X = Application.GetRealWidth (70), Y = btnName.Bottom, TextAlignment = TextAlignment.Center, @@ -87,51 +226,24 @@ Radius = 5, BorderColor = SkinStyle.Current.BorderColor, TextColor = SkinStyle.Current.TextColor1, - //Text = "wxr@hdlchina.com.cn" }; - registrationView.AddChidren (etName); - - Button btnEmail = new Button () { - Width = Application.GetRealWidth (500), - Height = Application.GetRealHeight (85), - X = Application.GetRealWidth (70), - Y = etName.Bottom + Application.GetRealHeight (20), - Text= "Email ID", - TextAlignment = TextAlignment.CenterLeft, - TextSize = 12, - TextColor = SkinStyle.Current.TextColor1, - }; - registrationView.AddChidren (btnEmail); - - EditText etEmailAddress = new EditText () { - Width = Application.GetRealWidth (500), - Height = Application.GetRealHeight (85), - X = Application.GetRealWidth (70), - Y = btnEmail.Bottom, - TextAlignment = TextAlignment.Center, - BorderWidth = 1, - Radius = 5, - BorderColor = SkinStyle.Current.BorderColor, - TextColor = SkinStyle.Current.TextColor1, - //Text = "wxr@hdlchina.com.cn" - }; - registrationView.AddChidren (etEmailAddress); + mobileChencView.AddChidren (etName); Button btnPassword = new Button () { Width = Application.GetRealWidth (500), - Height = Application.GetRealHeight (85), + Height = Application.GetRealWidth (85), X = Application.GetRealWidth (70), - Y = etEmailAddress.Bottom + Application.GetRealHeight (20), + Y = etName.Bottom, TextID = R.MyInternationalizationString.Password, TextAlignment = TextAlignment.CenterLeft, TextSize = 12, TextColor = SkinStyle.Current.TextColor1, }; - registrationView.AddChidren (btnPassword); + mobileChencView.AddChidren (btnPassword); EditText etPasswrod = new EditText () { Width = Application.GetRealWidth (500), - Height = Application.GetRealHeight (85), + Height = Application.GetRealWidth (85), X = Application.GetRealWidth (70), Y = btnPassword.Bottom, BorderWidth = 1, @@ -142,19 +254,19 @@ SecureTextEntry = true, //Text = "hdltest1985" }; - registrationView.AddChidren (etPasswrod); + mobileChencView.AddChidren (etPasswrod); Button btnShowPassword = new Button () { X = etPasswrod.Right - Application.GetRealWidth (80), - Y = etPasswrod.Y + Application.GetRealHeight (12), - Width = Application.GetMinRealAverage (73), - Height = Application.GetMinRealAverage (60), + Y = etPasswrod.Y + Application.GetRealWidth (12), + Width = Application.GetRealWidth (73), + Height = Application.GetRealWidth (60), SelectedImagePath = "CrabtreeAdd/ShowPW.png", UnSelectedImagePath = "CrabtreeAdd/HidePW.png", BorderColor = SkinStyle.Current.Transparent, BorderWidth = 1, Radius = 1 }; - registrationView.AddChidren (btnShowPassword); + mobileChencView.AddChidren (btnShowPassword); btnShowPassword.MouseUpEventHandler += (dd, ff) => { btnShowPassword.IsSelected = !btnShowPassword.IsSelected; etPasswrod.SecureTextEntry = !btnShowPassword.IsSelected; @@ -162,19 +274,19 @@ Button btnConfirmpassword = new Button () { Width = Application.GetRealWidth (500), - Height = Application.GetRealHeight (85), + Height = Application.GetRealWidth (85), X = Application.GetRealWidth (70), - Y = etPasswrod.Bottom + Application.GetRealHeight (20), + Y = etPasswrod.Bottom, TextID = R.MyInternationalizationString.RepeatPassword, TextAlignment = TextAlignment.CenterLeft, TextSize = 12, TextColor = SkinStyle.Current.TextColor1, }; - registrationView.AddChidren (btnConfirmpassword); + mobileChencView.AddChidren (btnConfirmpassword); EditText etConfirmPassword = new EditText () { Width = Application.GetRealWidth (500), - Height = Application.GetRealHeight (85), + Height = Application.GetRealWidth (85), X = Application.GetRealWidth (70), Y = btnConfirmpassword.Bottom, BorderWidth = 1, @@ -185,120 +297,137 @@ SecureTextEntry = true, //Text = "hdltest1985" }; - registrationView.AddChidren (etConfirmPassword); + mobileChencView.AddChidren (etConfirmPassword); Button btnShowPassword2 = new Button () { X = etPasswrod.Right - Application.GetRealWidth (80), - Y = etConfirmPassword.Y + Application.GetRealHeight (12), - Width = Application.GetMinRealAverage (73), - Height = Application.GetMinRealAverage (60), + Y = etConfirmPassword.Y + Application.GetRealWidth (12), + Width = Application.GetRealWidth (73), + Height = Application.GetRealWidth (60), SelectedImagePath = "CrabtreeAdd/ShowPW.png", UnSelectedImagePath = "CrabtreeAdd/HidePW.png", BorderColor = SkinStyle.Current.Transparent, BorderWidth = 1, Radius = 1 }; - registrationView.AddChidren (btnShowPassword2); + mobileChencView.AddChidren (btnShowPassword2); btnShowPassword2.MouseUpEventHandler += (dd, ff) => { btnShowPassword2.IsSelected = !btnShowPassword2.IsSelected; etConfirmPassword.SecureTextEntry = !btnShowPassword2.IsSelected; }; - Button btnOK = new Button () { - Width = Application.GetRealWidth (247), - Height = Application.GetRealHeight (89), - X = Application.GetRealWidth ((640 - 247) / 2), - Y = Application.GetRealHeight (800), - BackgroundColor = SkinStyle.Current.ButtonColor, - SelectedBackgroundColor = SkinStyle.Current.SelectedColor, - Text = "Sign up", + + Button btnTitle = new Button () { + Gravity = Gravity.CenterHorizontal, + Y = etConfirmPassword.Bottom, + Width = Application.GetRealWidth (500), + Height = Application.GetRealWidth (85), + TextID = R.MyInternationalizationString.MobileVerificationCode, TextColor = SkinStyle.Current.TextColor1, + TextAlignment = TextAlignment.CenterLeft, + }; + mobileChencView.AddChidren (btnTitle); + + EditText etCode = new EditText () { + Width = Application.GetRealWidth (500), + Height = Application.GetRealWidth (85), + Gravity = Gravity.CenterHorizontal, + Y = btnTitle.Bottom, + BorderWidth = 1, Radius = 5, - BorderColor = SkinStyle.Current.Transparent, - BorderWidth = 0, - TextSize = 18, + BorderColor = SkinStyle.Current.BorderColor, + TextAlignment = TextAlignment.Center, + TextColor = SkinStyle.Current.TextColor1 }; - registrationView.AddChidren (btnOK); - btnOK.MouseDownEventHandler += (sender, e) => { - btnOK.IsSelected = true; + mobileChencView.AddChidren (etCode); + + Button btnConfirem = new Button () { + Gravity = Gravity.CenterHorizontal, + Y = etCode.Bottom + Application.GetRealWidth (50), + Width = Application.GetRealWidth (500), + Height = Application.GetRealWidth (85), + Text = "Sign up", + //TextID = R.MyInternationalizationString.Confrim, + TextColor = SkinStyle.Current.TextColor1, + TextAlignment = TextAlignment.Center, + BackgroundColor = SkinStyle.Current.MainColor, + SelectedBackgroundColor = SkinStyle.Current.SelectedColor, }; - btnOK.MouseUpEventHandler += (sender, e) => { - btnOK.IsSelected = false; + mobileChencView.AddChidren (btnConfirem); + + etCode.TextChangeEventHandler += (sender, e) => { + if (e.Length > 6) { + etCode.Text = e.Remove (6); + } else if (e.Length == 6) { + //btnConfirem.IsSelected = btnConfirem.Enable = true; + } else { + //btnConfirem.IsSelected = btnConfirem.Enable = false; + } }; - btnOK.MouseUpEventHandler += (sender, e) => { - //var reg = new Regex ("^\\s*([A-Za-z0-9_-]+(\\.\\w+)*@(\\w+\\.)+\\w{2,5})\\s*$"); - //var ss = reg.Match (etEmailAddress.Text); - string account = etEmailAddress.Text.Trim (); + btnConfirem.MouseDownEventHandler += (sender, e) => { + btnConfirem.IsSelected = true; + }; + + //鐐瑰嚮娉ㄥ唽浜嬩欢 + btnConfirem.MouseUpEventHandler += (sender, e) => { + btnConfirem.IsSelected = false; string passwordText = etPasswrod.Text.Trim (); + string confrimPasswordText = etConfirmPassword.Text.Trim (); string userName = etName.Text.Trim (); - var regName = new Regex (@"^[~!0-9@#$%^&=*\x22]+"); - if (userName.Length == 0) { + var regName = new Regex (@"^[~!0-9@#$%^&=*\x22]+"); + if (string.IsNullOrEmpty (userName)) { new Alert ("", "Please fill in the Name.", Language.StringByID (R.MyInternationalizationString.Close)).Show (); return; } else if (regName.Match (userName).Success) { new Alert ("", "Protect Your Illegal Characters in Name", Language.StringByID (R.MyInternationalizationString.Close)).Show (); return; - } else if (!CommonUtlis.Current.CheckEmail (account)) { - new Alert ("", Language.StringByID (R.MyInternationalizationString.PleaseCheckEmailAddressCorrectly), - Language.StringByID (R.MyInternationalizationString.Close)).Show (); - return; } - - - - if (etPasswrod.Text == "" && etConfirmPassword.Text == "") { + //妫�娴嬪瘑鐮� + if (passwordText == "" && confrimPasswordText == "") { new Alert ("", Language.StringByID (R.MyInternationalizationString.PleaseWriteTheCompleteContent), Language.StringByID (R.MyInternationalizationString.Close)).Show (); return; - } else if (passwordText.Contains(userName)) { + } else if (passwordText.Contains (userName)) { //瀵嗙爜涓嶈兘鍖呭惈鐢ㄦ埛鍚� new Alert ("", ErrorCode.PasswordNotUsername, Language.StringByID (R.MyInternationalizationString.Close)).Show (); return; - } else if (!CommonUtlis.Current.CheckPassword(etPasswrod.Text.Trim ())) { + } else if (!CommonUtlis.Current.CheckPassword (passwordText)) { new Alert ("", ErrorCode.PasswordStrengthNotMatch, Language.StringByID (R.MyInternationalizationString.Close)).Show (); return; - } else if (etPasswrod.Text.Trim () != etConfirmPassword.Text.Trim ()) { + } else if (passwordText != confrimPasswordText) { new Alert ("", Language.StringByID (R.MyInternationalizationString.RepeatPasswordsDidNotmatch), Language.StringByID (R.MyInternationalizationString.Close)).Show (); return; } + //妫�娴嬮獙璇佺爜 + string verCode = etCode.Text.Trim (); + if (string.IsNullOrEmpty (verCode)) { + Utlis.ShowTip (Language.StringByID (R.MyInternationalizationString.PlsEntryVerificationCode)); + return; + } + + MainPage.Loading.Start (Language.StringByID (R.MyInternationalizationString.load)); + System.Threading.Tasks.Task.Run (() => { try { - Application.RunOnMainThread (() => { - MainPage.Loading.Start ("Please wait..."); - }); - //string isExistingAccount = "{\"Account\":\"" + account + "\"}"; - var detectionAccountObj = new DetectionAccountObj () { Account = account }; - var postJson = Newtonsoft.Json.JsonConvert.SerializeObject (detectionAccountObj); - - var isExistingAccountObj = MainPage.RequestHttps (API.DetectionAccount, postJson); - if (isExistingAccountObj.StateCode == "AccountExists") { - string sssd = "杩欎釜璐﹀彿宸茬粡娉ㄥ唽銆�"; - if (Language.CurrentLanguage == "English") - sssd = "This account has been registered."; + var isPhone = false; + var revertObj = HttpServerRequest.Current.ValidataCodeAndRegister (userName, mAccount, passwordText, verCode, isPhone); + if (revertObj.Code == StateCode.SUCCESS) { Application.RunOnMainThread (() => { - new Alert ("", sssd, Language.StringByID (R.MyInternationalizationString.Close)).Show (); + new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.TheAccountTegistrationIsSuccessful), Language.StringByID (R.MyInternationalizationString.Close)).Show (); + Close (); + new AccountLogin (mAccount, passwordText).Show (); }); - return; } else { - var requestObj = new YdRegisterAccountObj () { Account = account, Password = passwordText, Contact = userName, Language = Language.CurrentLanguage, Company = MainPage.SoftSmsType }; - var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj); - var revertObj = MainPage.RequestHttps (API.YdRegisterAccount, requestJson); - if (revertObj.StateCode.ToUpper() == StateCode.SUCCESS) { - Application.RunOnMainThread (() => { - new Alert ("", Language.StringByID (R.MyInternationalizationString.AuthenticationMail), Language.StringByID (R.MyInternationalizationString.Close)).Show (); - Close (); - new AccountLogin (account, passwordText).Show (); - }); - } else { - //娉ㄥ唽澶辫触鎻愮ず - ShowErrorInfo (revertObj.StateCode); - } + //鎻愮ず閿欒 + IMessageCommon.Current.ShowErrorInfoAlter (revertObj.Code); } + + } catch { MainPage.FailureToServer (); } finally { @@ -307,64 +436,12 @@ }); } }); - }; - etName.EditorEnterAction += (obj) => { - //Application.HideSoftInput (); - etEmailAddress.Foucs = true; }; - etEmailAddress.EditorEnterAction += (obj) => { - //Application.HideSoftInput (); - etPasswrod.Foucs = true; - }; - etPasswrod.EditorEnterAction += (obj) => { - Application.HideSoftInput (); - etConfirmPassword.Foucs = true; - }; - etConfirmPassword.EditorEnterAction += (obj) => { - //etConfirmPassword.Foucs = false; - Application.HideSoftInput (); - }; - //etConfirmPassword.MouseDownEventHandler += (dd, dds) => { - // etConfirmPassword.Foucs = true; - //}; - btnName.MouseDownEventHandler += (sender, e) => { - Application.HideSoftInput (); - }; - btnEmail.MouseDownEventHandler += (sender, e) => { - Application.HideSoftInput (); - }; - btnPassword.MouseDownEventHandler += (sender, e) => { - Application.HideSoftInput (); - }; - btnConfirmpassword.MouseDownEventHandler += (sender, e) => { - Application.HideSoftInput (); - }; - } - - - - void ShowErrorInfo (string stateCodeStr) - { - string mes = ""; - //2020-01-06 浠hˉ鍏� - if (stateCodeStr == "AccountExists") { - mes = "This account has been registered."; - } else if (stateCodeStr == "AccountYesRegisterNoIsverify") { - mes = ErrorCode.AccountYesRegisterNoIsverify; - } else if (stateCodeStr == ErrorCode.NetworkError) { - mes = ErrorCode.NetworkError; - } else { - mes = ErrorCode.OperationFailed + ErrorCode.Reason + stateCodeStr; - } - if (!string.IsNullOrEmpty (mes)) { - Application.RunOnMainThread (() => { - new Alert ("", mes, Language.StringByID (R.MyInternationalizationString.Close)).Show (); - }); - } } + } } \ No newline at end of file -- Gitblit v1.8.0