From a1b0ab7044100daaa7e0f1da2d2ca45e38098963 Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期一, 29 三月 2021 09:13:25 +0800
Subject: [PATCH] 2021-3-29-2
---
HDL_ON/UI/UI2/4-PersonalCenter/ResetAccountPassword/ResetPasswordPage.cs | 355 ++++++++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 315 insertions(+), 40 deletions(-)
diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/ResetAccountPassword/ResetPasswordPage.cs b/HDL_ON/UI/UI2/4-PersonalCenter/ResetAccountPassword/ResetPasswordPage.cs
index 699a723..61fff82 100644
--- a/HDL_ON/UI/UI2/4-PersonalCenter/ResetAccountPassword/ResetPasswordPage.cs
+++ b/HDL_ON/UI/UI2/4-PersonalCenter/ResetAccountPassword/ResetPasswordPage.cs
@@ -1,12 +1,53 @@
锘縰sing System;
using Shared;
using HDL_ON.UI.CSS;
+using HDL_ON.DAL.Server;
+using System.Threading;
namespace HDL_ON.UI
{
public partial class ResetPasswordPage : FrameLayout
{
+ /// <summary>
+ /// 鏄惁鎵嬫満
+ /// </summary>
+ public bool isPhone;
+ /// <summary>
+ /// 璐﹀彿
+ /// </summary>
+ public string account;
+ /// <summary>
+ /// 楠岃瘉鐮�
+ /// </summary>
+ public string verCode;
+
+ #region 鎺т欢View
+ /// <summary>
+ /// 瀵嗙爜鏂囨湰妗�
+ /// </summary>
+ EditText etPassword;
+ /// <summary>
+ /// 纭瀵嗙爜鏂囨湰妗�
+ /// </summary>
+ EditText etRepeatPassword;
+
+ /// <summary>
+ /// 淇敼鎸夐挳
+ /// </summary>
+ Button btnReset;
+
+ /// <summary>
+ ///
+ /// </summary>
FrameLayout bodyView;
+
+ /// <summary>
+ /// 鏄惁鐐瑰嚮浜嗚繑鍥烇紝鐢ㄤ簬灞忚斀EditText澶卞幓鐒︾偣妫�娴嬩簨浠�
+ /// </summary>
+ bool isHitBack;
+
+ #endregion
+
public ResetPasswordPage()
{
bodyView = this;
@@ -14,60 +55,294 @@
public void LoadPage()
{
- bodyView.BackgroundColor = CSS_Color.MainBackgroundColor;
- new TopViewDiv(bodyView, Language.StringByID(StringId.ModifyPassword)).LoadTopView();
+ bodyView.BackgroundColor = CSS_Color.BackgroundColor;
+ Action backAction = () =>
+ {
+ isHitBack = true;
+ };
+ new TopViewDiv(bodyView, Language.StringByID(StringId.ModifyPassword)).LoadTopView(backAction);
+ #region 鏂板瘑鐮�
+ FrameLayout rowView = new FrameLayout()
+ {
+ Y = Application.GetRealHeight(64),
+ Height = Application.GetRealHeight(50),
+ BackgroundColor = CSS_Color.MainBackgroundColor,
+ };
+ bodyView.AddChidren(rowView);
+
+ //鏂板瘑鐮�
+ Button btnTitle = new Button()
+ {
+ X = Application.GetRealWidth(16),
+ Width = Application.GetRealWidth(180),
+ TextColor = CSS_Color.FirstLevelTitleColor,
+ TextSize = CSS_FontSize.SubheadingFontSize,
+ TextAlignment = TextAlignment.CenterLeft,
+ Text = Language.StringByID(StringId.NewPassword) + ":"
+ };
+ rowView.AddChidren(btnTitle);
+
+ etPassword = new EditText()
+ {
+ Width = Application.GetRealWidth(359),
+ TextColor = CSS_Color.PromptingColor1,
+ TextSize = CSS_FontSize.TextFontSize,
+ SecureTextEntry = true,
+ TextAlignment = TextAlignment.CenterRight,
+ Foucs = true
+ };
+ rowView.AddChidren(etPassword);
+ var lineView = new LineView(rowView.Height);
+ rowView.AddChidren(lineView);
+ #endregion
+
+ #region 鍐嶆杈撳叆鏂板瘑鐮�
+ FrameLayout rowView2 = new FrameLayout()
+ {
+ Y = rowView.Bottom,
+ Height = Application.GetRealHeight(50),
+ BackgroundColor = CSS_Color.MainBackgroundColor,
+ };
+ bodyView.AddChidren(rowView2);
+
+ //鍐嶆杈撳叆鏂板瘑鐮�
+ Button btnTitle2 = new Button()
+ {
+ X = Application.GetRealWidth(16),
+ Width = Application.GetRealWidth(180),
+ TextColor = CSS_Color.FirstLevelTitleColor,
+ TextSize = CSS_FontSize.SubheadingFontSize,
+ TextAlignment = TextAlignment.CenterLeft,
+ //TextID = StringId.NewPasswordAgain,
+ Text = Language.StringByID(StringId.NewPasswordAgain) + ":"
+ };
+ rowView2.AddChidren(btnTitle2);
+
+ etRepeatPassword = new EditText()
+ {
+ Width = Application.GetRealWidth(359),
+ TextColor = CSS_Color.PromptingColor1,
+ TextSize = CSS_FontSize.TextFontSize,
+ SecureTextEntry = true,
+ TextAlignment = TextAlignment.CenterRight,
+ };
+ rowView2.AddChidren(etRepeatPassword);
+ #endregion
+
+ btnReset = new Button()
+ {
+ Gravity = Gravity.CenterHorizontal,
+ Y = Application.GetRealHeight(224),
+ Width = Application.GetRealWidth(220),
+ Height = Application.GetRealWidth(44),
+ Radius = (uint)Application.GetRealWidth(22),
+ SelectedBackgroundColor = CSS_Color.MainColor,
+ BackgroundColor = CSS_Color.PromptingColor1,
+ TextID = StringId.Confirm,
+ TextSize = CSS_FontSize.SubheadingFontSize,
+ TextColor = CSS_Color.MainBackgroundColor,
+ TextAlignment = TextAlignment.Center,
+ };
+ bodyView.AddChidren(btnReset);
+
+ LoadEvent_Reset();
+ LoadEvent_EditTextFcousChange();
}
}
public partial class ResetPasswordPage
{
- public void ResetPassword(string password,string repeatPassword )
- {
- var waitPage = new Loading();
- waitPage.Start("Please wait...");
- var resetResult = new DAL.Server.HttpServerRequest().ResetPassword(MainPage.LoginUser.accountString, password, repeatPassword, 86);
- if (resetResult.StateCode.ToUpper() == "SUCCESS")
- {
- Application.RunOnMainThread(() =>
- {
- var page = new OperationResultDisPalyPage();
- page.Show();
- page.LoadPage(true, Language.StringByID(StringId.UnbindEmail), Language.StringByID(StringId.UnbindEmailSuccess), "");
- for (int i = 0; i < 2; i++)
+ /// <summary>
+ /// 鎸囧畾鍏抽棴椤甸潰涓暟
+ /// </summary>
+ /// <param name="countPage"></param>
+ void ClosePageWithCount(int countPage)
+ {
+ //鍏抽棴澶氬皯涓〉闈�
+ for (int i = 0; i < countPage; i++)
+ {
+ MainPage.BasePageView.GetChildren(MainPage.BasePageView.ChildrenCount - 1).RemoveFromParent();
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="password"></param>
+ void ResetPassword(string password)
+ {
+
+ //鏍¢獙瀵嗙爜鏄惁绗﹀悎瑕佹眰
+ if (etPassword.Text.Trim().Length < 6 || etPassword.Text.Trim().Length > 13)
+ {
+ new Tip()
+ {
+ CloseTime = 1,
+ Direction = AMPopTipDirection.None,
+ Text = Language.StringByID(StringId.PasswordIsUnqualified)
+ }.Show(bodyView);
+ return;
+ }
+
+ //鏍¢獙涓ゆ杈撳叆鐨勫瘑鐮佹槸鍚︿竴鑷�
+ if (etPassword.Text.Trim() != etRepeatPassword.Text.Trim())
+ {
+ new Tip()
+ {
+ CloseTime = 1,
+ Direction = AMPopTipDirection.None,
+ MaxWidth = Application.GetRealWidth(300),
+ Text = Language.StringByID(StringId.IncorrectRepeatPassword)
+ }.Show(bodyView);
+
+ return;
+ }
+
+ var waitPage = new Loading();
+ bodyView.AddChidren(waitPage);
+ waitPage.Start(Language.StringByID(StringId.PleaseWait));
+
+ new Thread(() =>
+ {
+ try
+ {
+ // 蹇樿瀵嗙爜
+ var resultObj = new HttpServerRequest().ForgetPassword(account, password, verCode, isPhone);
+ if (resultObj.Code == StateCode.SUCCESS)
{
- MainPage.BasePageView.GetChildren(MainPage.BasePageView.ChildrenCount - 1).RemoveFromParent();
+ Application.RunOnMainThread(() =>
+ {
+ Utlis.ShowTip(Language.StringByID(StringId.PasswordChangeSuccessfully));
+ ClosePageWithCount(2);
+ });
}
- });
+ else
+ {
+ // 鎻愮ず閿欒
+ IMessageCommon.Current.ShowErrorInfoAlter(resultObj.Code);
+ }
+ }
+ catch { }
+ finally
+ {
+ Application.RunOnMainThread(() =>
+ {
+ if (waitPage != null)
+ {
+ waitPage.RemoveFromParent();
+ waitPage = null;
+ }
+ });
+ }
+ })
+ { IsBackground = true }.Start();
+
+ }
+
+ /// <summary>
+ /// 鍔犺浇鏂瑰紡鎸夐挳浜嬩欢
+ /// </summary>
+ void LoadEvent_Reset()
+ {
+ btnReset.MouseUpEventHandler += (sender, e) =>
+ {
+ if (btnReset.IsSelected)
+ {
+ ResetPassword(etPassword.Text.ToString());
+ }
+ };
+ }
+
+ /// <summary>
+ /// 鍔犺浇鏂囨湰妗嗙劍鐐瑰彉鍖栦簨浠�
+ /// </summary>
+ void LoadEvent_EditTextFcousChange() {
+ //瀵嗙爜鏂囨湰妗嗙劍鐐瑰彉鍖栦簨浠�
+ etPassword.FoucsChanged += (sender, e) =>
+ {
+ if (etPassword.Foucs)
+ {
+
+ }
+ else
+ {
+ if (isHitBack) return;//鐐瑰嚮杩斿洖鍏抽棴椤甸潰涓嶆娴嬫彁绀�
+
+ if (etPassword.Text.Length == 0) return;//娌¤緭鍏ヤ笉妫�娴嬫彁绀�
+
+ //鏍¢獙瀵嗙爜鏄惁绗﹀悎瑕佹眰
+ if (etPassword.Text.Trim().Length < 6 || etPassword.Text.Trim().Length > 13)
+ {
+ new Tip()
+ {
+ CloseTime = 1,
+ Direction = AMPopTipDirection.None,
+ Text = Language.StringByID(StringId.PasswordIsUnqualified)
+ }.Show(bodyView);
+ }
+ else
+ {
+ LoadMothed_EnableResetButton();
+ }
+ }
+ };
+
+ //纭瀵嗙爜鏂囨湰妗嗙劍鐐瑰彉鍖栦簨浠�
+ etRepeatPassword.FoucsChanged += (sender, e) =>
+ {
+ if (etRepeatPassword.Foucs)
+ {
+
+ }
+ else
+ {
+ if (isHitBack) return;//鐐瑰嚮杩斿洖鍏抽棴椤甸潰涓嶆娴嬫彁绀�
+
+ if (etRepeatPassword.Text.Length == 0) return;//娌¤緭鍏ヤ笉妫�娴嬫彁绀�
+
+ //鏍¢獙涓ゆ杈撳叆鐨勫瘑鐮佹槸鍚︿竴鑷�
+ if (etPassword.Text.Trim() != etRepeatPassword.Text.Trim())
+ {
+ new Tip()
+ {
+ CloseTime = 1,
+ Direction = AMPopTipDirection.None,
+ MaxWidth = Application.GetRealWidth(300),
+ Text = Language.StringByID(StringId.IncorrectRepeatPassword)
+ }.Show(bodyView);
+ }
+ else
+ {
+ LoadMothed_EnableResetButton();
+ }
+ }
+ };
+
+ Action<View, string> textChangeEventHandler = (view, textStr) =>
+ {
+ LoadMothed_EnableResetButton();
+ };
+ etPassword.TextChangeEventHandler += textChangeEventHandler;
+ etRepeatPassword.TextChangeEventHandler += textChangeEventHandler;
+
+ }
+
+ /// <summary>
+ /// 浣胯兘淇敼纭畾鎸夐挳
+ /// </summary>
+ void LoadMothed_EnableResetButton()
+ {
+ if (!string.IsNullOrEmpty(etPassword.Text) && (etPassword.Text.Trim() == etRepeatPassword.Text.Trim()))
+ {
+ btnReset.IsSelected = true;
}
else
{
- string erorrInfo = "";
- switch (resetResult.StateCode)
- {
- case "PwdNoConfirm"://涓ゆ杈撳叆鐨勫瘑鐮佷笉涓�鑷�
- erorrInfo = Language.StringByID(StringId.IncorrectRepeatPassword);
- break;
- case "AccountNoExists"://涓ゆ杈撳叆鐨勫瘑鐮佷笉涓�鑷�
- erorrInfo = Language.StringByID(StringId.AccountNotExist);
- break;
- default:
- erorrInfo = "Server error";
- break;
- }
- Application.RunOnMainThread(() =>
- {
- waitPage.Hide();
- new Tip()
- {
- CloseTime = 3,
- Direction = AMPopTipDirection.None,
- Text = erorrInfo,
- }.Show(bodyView);
- });
+ btnReset.IsSelected = false;
}
}
}
--
Gitblit v1.8.0