using System;
|
|
namespace Shared.Phone.UserCenter.Password
|
{
|
/// <summary>
|
/// 修改账号密码画面
|
/// </summary>
|
public class EditorAccountPasswordForm : EditorCommonForm
|
{
|
#region ■ 变量声明___________________________
|
|
/// <summary>
|
/// 密码错误信息控件
|
/// </summary>
|
private NormalViewControl msgControl = null;
|
|
#endregion
|
|
#region ■ 初始化_____________________________
|
|
/// <summary>
|
/// 画面显示(底层会固定调用此方法,借以完成画面创建)
|
/// </summary>
|
public void ShowForm()
|
{
|
//设定标题
|
base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uChangedPassword));
|
|
//初始化中部控件
|
this.InitMiddleFrame();
|
}
|
|
/// <summary>
|
/// 初始化中部控件
|
/// </summary>
|
private void InitMiddleFrame()
|
{
|
//清空bodyFrame
|
this.ClearBodyFrame();
|
|
var frameBackGroud = new FrameLayout();
|
frameBackGroud.BackgroundColor = UserCenterColor.Current.White;
|
frameBackGroud.Height = Application.GetRealHeight(521);
|
bodyFrameLayout.AddChidren(frameBackGroud);
|
|
//请输入原密码
|
var rowOldPsw = new FrameRowControl();
|
//关闭状态提示
|
rowOldPsw.UseClickStatu = false;
|
rowOldPsw.Y = Application.GetRealHeight(26);
|
frameBackGroud.AddChidren(rowOldPsw);
|
var txtoldPsw = new TextInputControl(Application.GetRealWidth(800), rowOldPsw.Height);
|
txtoldPsw.X = ControlCommonResourse.XXLeft;
|
txtoldPsw.SecureTextEntry = true;
|
txtoldPsw.PlaceholderText = Language.StringByID(R.MyInternationalizationString.PleaseInputOldPsw);
|
rowOldPsw.AddChidren(txtoldPsw);
|
//底线
|
var btnOldLine = rowOldPsw.AddBottomLine();
|
//联动线的状态
|
txtoldPsw.btnLine = btnOldLine;
|
//图标
|
var btnoldPswIcon = rowOldPsw.AddMostRightEmptyIcon(58, 58);
|
btnoldPswIcon.UnSelectedImagePath = "Item/HidenPWD.png";
|
btnoldPswIcon.SelectedImagePath = "Item/UnHidenPWD.png";
|
btnoldPswIcon.ButtonClickEvent += (sender, e) =>
|
{
|
btnoldPswIcon.IsSelected = !btnoldPswIcon.IsSelected;
|
txtoldPsw.SecureTextEntry = !txtoldPsw.SecureTextEntry;
|
};
|
|
//忘记密码?
|
var btnForgotPsw = new NormalViewControl(300, 49, true);
|
btnForgotPsw.Y = rowOldPsw.Bottom + Application.GetRealHeight(23);
|
btnForgotPsw.TextSize = 12;
|
btnForgotPsw.TextColor = UserCenterColor.Current.TextOrangeColor;
|
btnForgotPsw.TextID = R.MyInternationalizationString.ForgotPasswordMsg;
|
btnForgotPsw.TextAlignment = TextAlignment.CenterRight;
|
frameBackGroud.AddChidren(btnForgotPsw);
|
btnForgotPsw.X = bodyFrameLayout.Width - ControlCommonResourse.XXLeft - btnForgotPsw.Width;
|
btnForgotPsw.ButtonClickEvent += (sender, e) =>
|
{
|
var form = new ForgotAccountPasswordForm();
|
form.AddForm();
|
};
|
|
//请输入新密码
|
var rowNewPsw = new FrameRowControl();
|
//关闭状态提示
|
rowNewPsw.UseClickStatu = false;
|
rowNewPsw.Y = Application.GetRealHeight(236);
|
frameBackGroud.AddChidren(rowNewPsw);
|
var txtNewPsw = new TextInputControl(Application.GetRealWidth(800), rowNewPsw.Height);
|
txtNewPsw.X = ControlCommonResourse.XXLeft;
|
txtNewPsw.SecureTextEntry = true;
|
txtNewPsw.PlaceholderText = Language.StringByID(R.MyInternationalizationString.uPleaseInputNewPassword);
|
rowNewPsw.AddChidren(txtNewPsw);
|
//底线
|
var btnNewLine = rowNewPsw.AddBottomLine();
|
//联动线的状态
|
txtNewPsw.btnLine = btnNewLine;
|
//图标
|
var btnNewPswIcon = rowNewPsw.AddMostRightEmptyIcon(58, 58);
|
btnNewPswIcon.UnSelectedImagePath = "Item/HidenPWD.png";
|
btnNewPswIcon.SelectedImagePath = "Item/UnHidenPWD.png";
|
btnNewPswIcon.ButtonClickEvent += (sender, e) =>
|
{
|
btnNewPswIcon.IsSelected = !btnNewPswIcon.IsSelected;
|
txtNewPsw.SecureTextEntry = !txtNewPsw.SecureTextEntry;
|
};
|
|
//请重复输入新密码
|
var rowConfirmPsw = new FrameRowControl();
|
//关闭状态提示
|
rowConfirmPsw.UseClickStatu = false;
|
rowConfirmPsw.Y = rowNewPsw.Bottom + Application.GetRealHeight(10);
|
frameBackGroud.AddChidren(rowConfirmPsw);
|
var txtConfirmPsw = new TextInputControl(Application.GetRealWidth(800), rowConfirmPsw.Height);
|
txtConfirmPsw.X = ControlCommonResourse.XXLeft;
|
txtConfirmPsw.SecureTextEntry = true;
|
txtConfirmPsw.PlaceholderText = Language.StringByID(R.MyInternationalizationString.uPleaseRepeatInputNewPassword);
|
rowConfirmPsw.AddChidren(txtConfirmPsw);
|
//图标
|
var btnConfirmPswIcon = rowConfirmPsw.AddMostRightEmptyIcon(58, 58);
|
btnConfirmPswIcon.UnSelectedImagePath = "Item/HidenPWD.png";
|
btnConfirmPswIcon.SelectedImagePath = "Item/UnHidenPWD.png";
|
btnConfirmPswIcon.ButtonClickEvent += (sender, e) =>
|
{
|
btnConfirmPswIcon.IsSelected = !btnConfirmPswIcon.IsSelected;
|
txtConfirmPsw.SecureTextEntry = !txtConfirmPsw.SecureTextEntry;
|
};
|
|
//错误信息
|
this.msgControl = new NormalViewControl(bodyFrameLayout.Width, Application.GetRealHeight(58), false);
|
msgControl.Y = Application.GetRealHeight(582);
|
msgControl.TextAlignment = TextAlignment.Center;
|
msgControl.TextColor = 0xfff75858;
|
msgControl.IsBold = true;
|
bodyFrameLayout.AddChidren(msgControl);
|
|
//确认修改
|
var btnfinish = new BottomClickButton(688);
|
btnfinish.Y = Application.GetRealHeight(708);
|
btnfinish.TextID = R.MyInternationalizationString.DoEditor;
|
bodyFrameLayout.AddChidren(btnfinish);
|
btnfinish.ButtonClickEvent += (sender, e) =>
|
{
|
msgControl.Text = string.Empty;
|
//密码检测
|
bool flage = this.CheckPassword(txtoldPsw.Text, txtNewPsw.Text, txtConfirmPsw.Text);
|
if (flage == false)
|
{
|
return;
|
}
|
//保存密码
|
this.SavePassword(txtConfirmPsw.Text);
|
};
|
}
|
|
#endregion
|
|
#region ■ 保存密码___________________________
|
|
/// <summary>
|
/// 保存密码
|
/// </summary>
|
/// <param name="newPassword"></param>
|
private void SavePassword(string newPassword)
|
{
|
var pra = new SavePasswordPra();
|
pra.NewPassword = newPassword;
|
|
//更改密码
|
bool flage = UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/UpdatePassword", false, pra);
|
if (flage == false)
|
{
|
return;
|
}
|
//密码已经修改,请重新登录
|
string msg = Language.StringByID(R.MyInternationalizationString.uPasswordIsHadChangedAndLoginAgain);
|
this.ShowMassage(ShowMsgType.Remind, msg, () =>
|
{
|
//从新登录
|
UserCenterLogic.ReLoginAgain(Common.Config.Instance.Account);
|
}, Language.StringByID(R.MyInternationalizationString.Login));
|
}
|
|
#endregion
|
|
#region ■ 一般方法___________________________
|
|
/// <summary>
|
/// 密码检测
|
/// </summary>
|
/// <param name="oldPsw">输入的旧密码</param>
|
/// <param name="newPsw">输入的新密码</param>
|
/// <param name="newPsw2">输入的确认密码</param>
|
/// <returns></returns>
|
private bool CheckPassword(string oldPsw, string newPsw, string newPsw2)
|
{
|
if (oldPsw == string.Empty)
|
{
|
//请输入原密码
|
this.msgControl.TextID = R.MyInternationalizationString.PleaseInputOldPsw;
|
return false;
|
}
|
if (newPsw == string.Empty)
|
{
|
//请输入新密码
|
this.msgControl.TextID = R.MyInternationalizationString.uPleaseInputNewPassword;
|
return false;
|
}
|
if (newPsw2 == string.Empty)
|
{
|
//请重复输入新密码
|
this.msgControl.TextID = R.MyInternationalizationString.uPleaseRepeatInputNewPassword;
|
return false;
|
}
|
if (oldPsw != Common.Config.Instance.Password)
|
{
|
//密码错误,请重新输入
|
this.msgControl.TextID = R.MyInternationalizationString.uOldPsswordIsError;
|
return false;
|
}
|
if (newPsw != newPsw2)
|
{
|
//确认密码不一致,请重新输入
|
this.msgControl.TextID = R.MyInternationalizationString.SecondPswNotEqual1;
|
return false;
|
}
|
if (newPsw == oldPsw)
|
{
|
//新密码和原密码一致,请重新输入
|
this.msgControl.TextID = R.MyInternationalizationString.uNewPswAndOldPswIsEqual;
|
return false;
|
}
|
if (newPsw.Length < 6 || newPsw.Length > 13)
|
{
|
//密码长度为6-13个字符
|
string textValue = Language.StringByID(R.MyInternationalizationString.PswLengthMsg);
|
if (textValue.Contains("{0}") == true)
|
{
|
textValue = string.Format(textValue, "6-13");
|
}
|
this.msgControl.Text = textValue;
|
return false;
|
}
|
|
return true;
|
}
|
|
#endregion
|
|
#region ■ 结构体_____________________________
|
|
/// <summary>
|
/// 保存密码的启动参数类
|
/// </summary>
|
private class SavePasswordPra
|
{
|
/// <summary>
|
/// 旧密码
|
/// </summary>
|
public string OldPassword = Common.Config.Instance.Password;
|
/// <summary>
|
/// 新密码
|
/// </summary>
|
public string NewPassword = string.Empty;
|
}
|
|
#endregion
|
}
|
}
|