using 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 { /// /// 是否手机 /// public bool isPhone; /// /// 账号 /// public string account; /// /// 验证码 /// public string verCode; #region 控件View /// /// 密码文本框 /// EditText etPassword; /// /// 确认密码文本框 /// EditText etRepeatPassword; /// /// 修改按钮 /// Button btnReset; /// /// /// FrameLayout bodyView; #endregion public ResetPasswordPage() { bodyView = this; } public void LoadPage() { bodyView.BackgroundColor = CSS_Color.BackgroundColor; new TopViewDiv(bodyView, Language.StringByID(StringId.ModifyPassword)).LoadTopView(); #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, TextID = 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.AddChidren(lineView); lineView.Y = rowView.Height - lineView.Height; #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, }; 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.GetRealHeight(44), Radius = (uint)Application.GetRealHeight(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 { /// /// 指定关闭页面个数 /// /// void ClosePageWithCount(int countPage) { //关闭多少个页面 for (int i = 0; i < countPage; i++) { MainPage.BasePageView.GetChildren(MainPage.BasePageView.ChildrenCount - 1).RemoveFromParent(); } } /// /// /// /// 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, Text = Language.StringByID(StringId.IncorrectRepeatPassword) }.Show(bodyView); return; } var waitPage = new Loading(); waitPage.Start("Please wait..."); new Thread(() => { try { // 忘记密码 var resultObj = new HttpServerRequest().ForgetPassword(account, password, verCode, isPhone); if (resultObj.Code == StateCode.SUCCESS) { Application.RunOnMainThread(() => { Utlis.ShowTip(Language.StringByID(StringId.PasswordChangeSuccessfully), bodyView); ClosePageWithCount(2); }); } else { // 提示错误 IMessageCommon.Current.ShowErrorInfoAlter(NewAPI.API_POST_Member_ForgetPwd, resultObj.Code); } } catch { } finally { Application.RunOnMainThread(() => { waitPage.Hide(); }); } }) { IsBackground = true }.Start(); } /// /// 加载方式按钮事件 /// void LoadEvent_Reset() { btnReset.MouseUpEventHandler += (sender, e) => { if (btnReset.IsSelected) { ResetPassword(etPassword.Text.ToString()); } }; } /// /// 加载文本框焦点变化事件 /// void LoadEvent_EditTextFcousChange() { //密码文本框焦点变化事件 etPassword.FoucsChanged += (sender, e) => { if (etPassword.Foucs) { } else { //校验密码是否符合要求 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); } } }; //确认密码文本框焦点变化事件 etRepeatPassword.FoucsChanged += (sender, e) => { if (etRepeatPassword.Foucs) { } else { //校验两次输入的密码是否一致 if (etPassword.Text.Trim() != etRepeatPassword.Text.Trim()) { new Tip() { CloseTime = 1, Direction = AMPopTipDirection.None, Text = Language.StringByID(StringId.IncorrectRepeatPassword) }.Show(bodyView); } else { LoadMothed_EnableResetButton(); } } }; } /// /// 使能修改确定按钮 /// void LoadMothed_EnableResetButton() { if (!string.IsNullOrEmpty(etPassword.Text) && (etPassword.Text.Trim() == etRepeatPassword.Text.Trim())) { btnReset.IsSelected = true; } else { btnReset.IsSelected = false; } } } }