| | |
| | | }; |
| | | 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", |
| | | }; |
| | |
| | | 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, |
| | |
| | | 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), |
| | |
| | | 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 |
| | |
| | | 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", |
| | | }; |
| | |
| | | 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 |
| | |
| | | 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 (); |
| | |
| | | string oldPassword = etCurPassword.Text.Trim (); |
| | | string newPassword = etNewPassword.Text.Trim (); |
| | | try { |
| | | var requestObj = new UpdatePasswordObj () { OldPassword = oldPassword, Password = newPassword }; |
| | | var requestObj = new UpdatePasswordObj () { OldPassword = oldPassword, NewPassword = newPassword }; |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj); |
| | | var revertObj = MainPage.RequestHttps ("UpdatePassword", requestJson); |
| | | if (revertObj.StateCode == "SUCCESS") { |
| | | var revertObj = MainPage.RequestHttps (API.UpdatePassword, requestJson); |
| | | 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), |
| | |
| | | }; |
| | | |
| | | } |
| | | |
| | | void ShowErrorInfo (string stateCodeStr) |
| | | { |
| | | 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 (); |
| | | }); |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | } |