From 5a5a2b696866f947b6025d26c3302e8ffef46435 Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期一, 11 一月 2021 16:11:20 +0800 Subject: [PATCH] 2021-01-11 1.更新MQTT连接和本地搜索网关方法。2.子账号相关接口完善 --- Crabtree/SmartHome/UI/SimpleControl/Phone/Register/AccountModifyPassword.cs | 120 +++++++++++++++++++++++++++-------------------------------- 1 files changed, 55 insertions(+), 65 deletions(-) diff --git a/Crabtree/SmartHome/UI/SimpleControl/Phone/Register/AccountModifyPassword.cs b/Crabtree/SmartHome/UI/SimpleControl/Phone/Register/AccountModifyPassword.cs index fea7fb9..2f4ebcb 100644 --- a/Crabtree/SmartHome/UI/SimpleControl/Phone/Register/AccountModifyPassword.cs +++ b/Crabtree/SmartHome/UI/SimpleControl/Phone/Register/AccountModifyPassword.cs @@ -1,5 +1,5 @@ 锘縰sing System; -using service.hdlcontrol.com_push; +//using service.hdlcontrol.com_push; namespace Shared.SimpleControl.Phone { @@ -68,10 +68,11 @@ }; BodyView.AddChidren (ResetPasswrodView); + var viewX = (Application.GetRealWidth (640) - Application.GetMinRealAverage (500)) / 2; var curPasswordView = new FrameLayout () { - Width = Application.GetRealWidth (500), - Height = Application.GetRealHeight (90), - X = Application.GetRealWidth (70), + Width = Application.GetMinRealAverage (500), + Height = Application.GetMinRealAverage (90), + X = viewX, Y = Application.GetRealHeight (200), BackgroundImagePath = "Register/Register_Password_kuang.png", }; @@ -80,8 +81,8 @@ var etCurPassword = new EditText () { Width = Application.GetRealWidth (400), X = Application.GetRealWidth (100), - PlaceholderText = Language.StringByID (R.MyInternationalizationString.PleaseEnterOldPassword), PlaceholderTextColor = SkinStyle.Current.PlaceholderTextColor, + PlaceholderText = Language.StringByID (R.MyInternationalizationString.PleaseEnterOldPassword), TextAlignment = TextAlignment.CenterLeft, SecureTextEntry = true, TextColor = SkinStyle.Current.TextColor1, @@ -89,9 +90,9 @@ curPasswordView.AddChidren (etCurPassword); var newPasswordView = new FrameLayout () { - Width = Application.GetRealWidth (500), - Height = Application.GetRealHeight (90), - X = Application.GetRealWidth (70), + Width = Application.GetMinRealAverage (500), + Height = Application.GetMinRealAverage (90), + X = viewX, Y = curPasswordView.Bottom + Application.GetRealHeight (70), BackgroundImagePath = "Register/Register_Password_kuang.png", Radius = (uint)Application.GetRealHeight (0), @@ -101,8 +102,8 @@ var etNewPassword = new EditText () { Width = Application.GetRealWidth (400), X = Application.GetRealWidth (100), - PlaceholderText = Language.StringByID (R.MyInternationalizationString.PleaseSetNewPasword), PlaceholderTextColor = SkinStyle.Current.PlaceholderTextColor, + PlaceholderText = Language.StringByID (R.MyInternationalizationString.PleaseSetNewPasword), TextAlignment = TextAlignment.CenterLeft, TextColor = SkinStyle.Current.TextColor1, SecureTextEntry = true @@ -110,9 +111,9 @@ newPasswordView.AddChidren (etNewPassword); var confrimFpasswordView = new FrameLayout () { - Width = Application.GetRealWidth (500), - Height = Application.GetRealHeight (90), - X = Application.GetRealWidth (70), + Width = Application.GetMinRealAverage (500), + Height = Application.GetMinRealAverage (90), + X = viewX, Y = newPasswordView.Bottom + Application.GetRealHeight (70), BackgroundImagePath = "Register/Register_Password_kuang.png", }; @@ -122,8 +123,8 @@ Width = Application.GetRealWidth (400), Height = Application.GetRealHeight (90), X = Application.GetRealWidth (100), - PlaceholderText = Language.StringByID (R.MyInternationalizationString.PleaseConfirmNewPassword), PlaceholderTextColor = SkinStyle.Current.PlaceholderTextColor, + PlaceholderText = Language.StringByID (R.MyInternationalizationString.PleaseConfirmNewPassword), TextAlignment = TextAlignment.CenterLeft, TextColor = SkinStyle.Current.TextColor1, SecureTextEntry = true @@ -168,37 +169,22 @@ if (string.IsNullOrEmpty (etNewPassword.Text.Trim ())) { new Alert ("", Language.StringByID (R.MyInternationalizationString.NewPasswordIsEmpty), Language.StringByID (R.MyInternationalizationString.Close)).Show (); + } else if (!string.IsNullOrEmpty(MainPage.LoginUser.Name) && etNewPassword.Text.Trim ().Contains (MainPage.LoginUser.Name)) { + //瀵嗙爜涓嶈兘鍖呭惈鐢ㄦ埛鍚� + new Alert ("", ErrorCode.PasswordNotUsername, + Language.StringByID (R.MyInternationalizationString.Close)).Show (); + return; + } else if (!CommonUtlis.Current.CheckPassword (etNewPassword.Text.Trim ())) { + new Alert ("", ErrorCode.PasswordStrengthNotMatch, + Language.StringByID (R.MyInternationalizationString.Close)).Show (); + //return; } else if (etNewPassword.Text.Trim () != etConfrimPassword.Text.Trim ()) { new Alert ("", Language.StringByID (R.MyInternationalizationString.PleaseConfirmPasswordIsCorrect), Language.StringByID (R.MyInternationalizationString.Close)).Show (); } else { string oldPassword = etCurPassword.Text.Trim (); string newPassword = etNewPassword.Text.Trim (); - try { - var requestObj = new UpdatePasswordObj () { OldPassword = oldPassword, NewPassword = newPassword }; - var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj); - var revertObj = MainPage.RequestHttps (API.UpdatePassword, requestJson, true); - if (revertObj.StateCode.ToUpper() == "SUCCESS") { - MainPage.LoginUser.Password = newPassword; - MainPage.LoginUser.SaveUserInfo (); - Application.RunOnMainThread (() => { - this.RemoveFromParent (); - new Alert ("", Language.StringByID (R.MyInternationalizationString.PasswordModificationSuccess), Language.StringByID (R.MyInternationalizationString.Close)).Show (); - }); - } else { - ShowErrorInfo (revertObj.StateCode); - } - - } catch { - Application.RunOnMainThread (() => { - new Alert ("", Language.StringByID (R.MyInternationalizationString.FailureToServer), - Language.StringByID (R.MyInternationalizationString.Close)).Show (); - }); - } finally { - Application.RunOnMainThread (() => { - MainPage.Loading.Hide (); - }); - } + ModifyPassword (oldPassword, newPassword); } } catch (Exception ex) { new Alert ("", Language.StringByID (R.MyInternationalizationString.CheckInternet), @@ -220,34 +206,38 @@ } - void ShowErrorInfo (string stateCodeStr) + /// <summary> + /// 淇敼瀵嗙爜 + /// </summary> + /// <param name="oldPassword"></param> + /// <param name="newPassword"></param> + void ModifyPassword (string oldPassword, string newPassword) { - string mes = ""; - if (stateCodeStr == "NewPasswordAndOldPasswordEqual") { - //鍘熷瘑鐮佸拰鏂板瘑鐮佺浉鍚� - mes = ErrorCode.NewPasswordAndOldPasswordEqual; - } else if (stateCodeStr == "OldPwdNoYes") { - //鍘熷瘑鐮侀敊璇� - mes = ErrorCode.OldPwdNoYes; - } else if (stateCodeStr == "AccountNoExists") { - //鐢ㄦ埛涓嶅瓨鍦� - mes = ErrorCode.ACCOUNTNOEXISTS; - } else if (stateCodeStr == "Fail") { - // 鎿嶄綔澶辫触 - mes = ErrorCode.OperationFailed; - } 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 (); - }); - } - - + MainPage.Loading.Start (""); + System.Threading.Tasks.Task.Run (() => { + try { + var revertObj = HttpServerRequest.Current.ModifyPassword (oldPassword, newPassword); + if (revertObj.Code == StateCode.SUCCESS) { + //var md5Password = Utlis.MD5Encrypt (newPassword); + MainPage.LoginUser.Password = newPassword; + MainPage.LoginUser.SaveUserInfo (); + Application.RunOnMainThread (() => { + this.RemoveFromParent (); + Utlis.ShowAlertOnMainThread (Language.StringByID (R.MyInternationalizationString.PasswordModificationSuccess)); + //new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.PasswordModificationSuccess), Language.StringByID (R.MyInternationalizationString.Close)).Show (); + }); + } else { + //鎻愮ず閿欒 + IMessageCommon.Current.ShowErrorInfoAlter (revertObj.Code); + } + } catch { + MainPage.FailureToServer (); + } finally { + Application.RunOnMainThread (() => { + MainPage.Loading.Hide (); + }); + } + }); } } } \ No newline at end of file -- Gitblit v1.8.0