From 4a61a132ce09b1fd42fd80fcbff1855bad4c0f48 Mon Sep 17 00:00:00 2001
From: JLChen <551775569@qq.com>
Date: 星期三, 15 一月 2020 11:15:24 +0800
Subject: [PATCH] 2020-01-15 1.优化。
---
Crabtree/SmartHome/UI/SimpleControl/Phone/Register/AccountModifyPassword.cs | 45 +++++++++++++++++++++++++++++++++++++++------
1 files changed, 39 insertions(+), 6 deletions(-)
diff --git a/Crabtree/SmartHome/UI/SimpleControl/Phone/Register/AccountModifyPassword.cs b/Crabtree/SmartHome/UI/SimpleControl/Phone/Register/AccountModifyPassword.cs
index 3b6f27b..4f4b0be 100644
--- a/Crabtree/SmartHome/UI/SimpleControl/Phone/Register/AccountModifyPassword.cs
+++ b/Crabtree/SmartHome/UI/SimpleControl/Phone/Register/AccountModifyPassword.cs
@@ -80,8 +80,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,
@@ -101,8 +101,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
@@ -122,8 +122,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
@@ -175,17 +175,20 @@
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),
@@ -216,5 +219,35 @@
};
}
+
+ 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 ();
+ });
+ }
+
+
+ }
}
}
\ No newline at end of file
--
Gitblit v1.8.0