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
|
{
|
/// <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;
|
#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,
|
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
|
{
|
|
/// <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,
|
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));
|
ClosePageWithCount(2);
|
});
|
}
|
else
|
{
|
// 提示错误
|
IMessageCommon.Current.ShowErrorInfoAlter(resultObj.Code);
|
}
|
}
|
catch { }
|
finally
|
{
|
Application.RunOnMainThread(() =>
|
{
|
waitPage.Hide();
|
});
|
}
|
})
|
{ 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 (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 (etPassword.Text.Trim() != etRepeatPassword.Text.Trim())
|
{
|
new Tip()
|
{
|
CloseTime = 1,
|
Direction = AMPopTipDirection.None,
|
Text = Language.StringByID(StringId.IncorrectRepeatPassword)
|
}.Show(bodyView);
|
}
|
else
|
{
|
LoadMothed_EnableResetButton();
|
}
|
}
|
};
|
|
}
|
|
/// <summary>
|
/// 使能修改确定按钮
|
/// </summary>
|
void LoadMothed_EnableResetButton()
|
{
|
if (!string.IsNullOrEmpty(etPassword.Text) && (etPassword.Text.Trim() == etRepeatPassword.Text.Trim()))
|
{
|
btnReset.IsSelected = true;
|
}
|
else
|
{
|
btnReset.IsSelected = false;
|
}
|
}
|
}
|
}
|