From 557c8c4f75aafc97533721766272410042440d34 Mon Sep 17 00:00:00 2001
From: wei <kaede@kaededeMacBook-Air.local>
Date: 星期六, 21 八月 2021 11:00:29 +0800
Subject: [PATCH] 安防功能
---
HDL_ON/UI/UI2/4-PersonalCenter/UnlockSetting/AppUnlockPasswordPage.cs | 461 +++++++++++++++++++++++++++++++++++----------------------
1 files changed, 285 insertions(+), 176 deletions(-)
diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/UnlockSetting/AppUnlockPasswordPage.cs b/HDL_ON/UI/UI2/4-PersonalCenter/UnlockSetting/AppUnlockPasswordPage.cs
index f64b708..ccb481a 100644
--- a/HDL_ON/UI/UI2/4-PersonalCenter/UnlockSetting/AppUnlockPasswordPage.cs
+++ b/HDL_ON/UI/UI2/4-PersonalCenter/UnlockSetting/AppUnlockPasswordPage.cs
@@ -5,17 +5,25 @@
namespace HDL_ON.UI
{
+ /// <summary>
+ /// 瀵嗙爜瑙i攣
+ /// </summary>
public partial class AppUnlockPasswordPage : FrameLayout
{
FrameLayout bodyView;
EditText etPassword;
+ /// <summary>
+ ///
+ /// </summary>
+ Button btnTipError;
string passwrod = "";
string oldPasswrod = "";
Action backAction;
- public AppUnlockPasswordPage(string pw,Action action)
+ public AppUnlockPasswordPage(string pw, Action action)
{
bodyView = this;
+ bodyView.Tag = "unlockpage";
oldPasswrod = pw;
backAction = action;
}
@@ -47,16 +55,19 @@
TextAlignment = TextAlignment.Center,
TextColor = CSS_Color.FirstLevelTitleColor,
TextSize = CSS_FontSize.SubheadingFontSize,
- TextID = string.IsNullOrEmpty(oldPasswrod)? StringId.PlsEntryPassword : StringId.PlsRegisterRepeatPassword,
+ TextID = string.IsNullOrEmpty(oldPasswrod) ? StringId.PlsEntryPassword : StringId.PlsRegisterRepeatPassword,
};
bodyView.AddChidren(btnTipTitle);
-
- if (optionType == "2"|| optionType == "3")
+ if (optionType == "1")
+ {
+ btnTipTitle.TextID = string.IsNullOrEmpty(oldPasswrod) ? StringId.PlsEntryPassword : StringId.PlsRegisterRepeatPassword;
+ }
+ else if (optionType == "2")
{
btnTipTitle.TextID = StringId.PleaseEnterTheOriginalDigitalPassword;
}
- if(optionType == "7")
+ else
{
btnTipTitle.TextID = StringId.PlsEntryPassword;
}
@@ -121,7 +132,7 @@
bodyView.AddChidren(btnTipIcon4);
- Button btnTipError = new Button()
+ btnTipError = new Button()
{
Y = Application.GetRealWidth(258),
Height = Application.GetRealWidth(40),
@@ -136,7 +147,7 @@
etPassword = new EditText()
{
Y = Application.GetRealWidth(100),
- Height = Application.GetRealWidth(0),
+ Height = 1,
Foucs = true,
//Visible = false,
IsNumberKeyboardType = true,
@@ -145,9 +156,10 @@
//etPassword.MouseUpEventHandler = (sender, e) => { };
- etPassword.TextChangeEventHandler = (sender, e) => {
+ etPassword.TextChangeEventHandler = (sender, e) =>
+ {
passwrod = etPassword.Text.Trim();
- switch(etPassword.Text.Trim().Length)
+ switch (etPassword.Text.Trim().Length)
{
case 0:
btnTipIcon1.IsSelected = false;
@@ -184,157 +196,31 @@
{
//绉婚櫎褰撳墠鐣岄潰锛屾瘡娆¤繑鍥為兘杩斿洖鍒版渶涓婄骇
this.RemoveFromParent();
- var page = new AppUnlockPasswordPage(passwrod,backAction);
+ var page = new AppUnlockPasswordPage(passwrod, backAction);
MainPage.BasePageView.AddChidren(page);
page.LoadPage(optionType);
MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
}
else
{
- if (optionType == "2")
- {
- //绉婚櫎褰撳墠鐣岄潰锛屾瘡娆¤繑鍥為兘杩斿洖鍒版渶涓婄骇
- this.RemoveFromParent();
- var page = new AppUnlockPasswordPage("", backAction);
- MainPage.BasePageView.AddChidren(page);
- page.LoadPage("1");
- MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
- return;
- }
-
- if (optionType == "7")
- {
- if (passwrod == oldPasswrod)
- {
- //MainPage.BasePageView.GetChildren(MainPage.BasePageView.ChildrenCount - 1).RemoveFromParent();
- this.RemoveFromParent();
- backAction();
- return;
- }
- else
- {
- btnTipError.TextID = StringId.AuthenticationFailedPasswordError;
- etPassword.Text = "";
- btnTipError.Visible = true;
- }
- return;
- }
- if (optionType == "3"|| optionType == "4")
- {
- if (passwrod == oldPasswrod)
- {
- if(optionType == "4")
- {
- backAction();
- this.RemoveFromParent();
- return;
- }
- if (OnAppConfig.Instance.appUnlockType.Contains("1"))
- {
- OnAppConfig.Instance.appUnlockType =new System.Collections.Generic.List<string>();//.Remove("1");
- OnAppConfig.Instance.appUnlockPasswrod = "";
- OnAppConfig.Instance.SaveUserConfig();
- this.RemoveFromParent();
- backAction();
- }
- }
- else
- {
- btnTipError.TextID = StringId.AuthenticationFailedPasswordError;
- etPassword.Text = "";
- btnTipError.Visible = true;
- }
- return;
- }
- //鍏抽棴/寮�鍚寚绾规垨鑰呴潰瀹�
- if (optionType == "5" || optionType == "6")//|| optionType == "8" || optionType == "9")
- {
- if (passwrod == oldPasswrod)
- {
- if (optionType == "5")
- {
- if (OnAppConfig.Instance.appUnlockType.Contains("3"))
- OnAppConfig.Instance.appUnlockType.Remove("3");
- else
- OnAppConfig.Instance.appUnlockType.Add("3");
-
- OnAppConfig.Instance.SaveUserConfig();
- this.RemoveFromParent();
- }
- if (optionType == "6")
- {
- if (OnAppConfig.Instance.appUnlockType.Contains("4"))
- OnAppConfig.Instance.appUnlockType.Remove("4");
- else
- OnAppConfig.Instance.appUnlockType.Add("4");
-
- OnAppConfig.Instance.SaveUserConfig();
- this.RemoveFromParent();
- }
- backAction();
- }
- else
- {
- btnTipError.TextID = StringId.AuthenticationFailedPasswordError;
- etPassword.Text = "";
- btnTipError.Visible = true;
- }
- return;
- }
+ //2020-12-11 瀵嗙爜鏍¢獙
if (passwrod == oldPasswrod)
{
- this.RemoveFromParent();
- var page = new OperationResultDisPalyPage();
- page.Show();
-
- page.LoadPage(true, Language.StringByID(StringId.SetSuccessfully), Language.StringByID(StringId.SetSuccessfully), "");
- string tipMsg = TouchIDUtils.getTouchIDSupperType() == TouchIDUtils.TouchIDSupperType.TouchID ? Language.StringByID(StringId.TurnOnFingerprintUnlocking) :
- Language.StringByID(StringId.TurnOnFaceIdUnlocking);
-
- if (TouchIDUtils.getTouchIDSupperType() != TouchIDUtils.TouchIDSupperType.None)
- {
- var unlockType = TouchIDUtils.getTouchIDSupperType() == TouchIDUtils.TouchIDSupperType.TouchID ? "3" : "4";
- Action<bool> action = (result) =>
- {
- if (result)
- {
- if (!OnAppConfig.Instance.appUnlockType.Contains(unlockType))
- {
- OnAppConfig.Instance.appUnlockType.Add(unlockType);
- }
- }
- else
- {
- if (OnAppConfig.Instance.appUnlockType.Contains(unlockType))
- {
- OnAppConfig.Instance.appUnlockType.Remove(unlockType);
- }
- }
- backAction();
- OnAppConfig.Instance.SaveUserConfig();
- };
- page.AdditionalOperations(tipMsg, action);
- }
- if (!OnAppConfig.Instance.appUnlockType.Contains("1"))
- {
- OnAppConfig.Instance.appUnlockType.Add("1");
- }
- OnAppConfig.Instance.appUnlockPasswrod = passwrod;
- OnAppConfig.Instance.SaveUserConfig();
- backAction();
+ //瀵嗙爜楠岃瘉閫氳繃
+ PasswordInputPassed(optionType);
}
else
{
- btnTipError.TextID = StringId.IncorrectRepeatPassword;
- etPassword.Text = "";
- btnTipError.Visible = true;
+ //瀵嗙爜楠岃瘉澶辫触
+ PasswordInputError(optionType);
}
}
break;
}
};
- EventHandler<MouseEventArgs> eventHandler = (sender, e) => {
+ EventHandler<MouseEventArgs> eventHandler = (sender, e) =>
+ {
etPassword.Foucs = true;
};
bodyView.MouseUpEventHandler = eventHandler;
@@ -345,50 +231,273 @@
etPassword.Foucs = true;
-
- if (optionType == "3" || optionType == "5" || optionType == "6" || optionType == "7")
+ if (optionType == "7")
{
- Button btnLoginAccountVerify = new Button()
- {
- Y = Application.GetRealHeight(517),
- Height = Application.GetRealHeight(60),
- TextAlignment = TextAlignment.Center,
- TextSize = CSS_FontSize.TextFontSize,
- TextColor = CSS_Color.MainColor,
- TextID = StringId.EnterLoginPasswordVerification,
- };
- bodyView.AddChidren(btnLoginAccountVerify);
+ //浣跨敤璐︽埛瀵嗙爜鐧诲綍鎸夐挳 鎻愮ず鎸夐挳
+ AddLoginTipButton();
+ }
+ else if (optionType != "1")
+ {
+ //杈撳叆鐧诲綍瀵嗙爜楠岃瘉 鎻愮ず鎸夐挳
+ AddInputPasswordTipButton(optionType);
+ }
+ }
- btnLoginAccountVerify.MouseUpEventHandler = (sender, e) =>
+
+ /// <summary>
+ /// 瀵嗙爜杈撳叆閿欒鏄剧ず閿欒淇℃伅
+ /// </summary>
+ /// <param name="optionType">1:璁剧疆瀵嗙爜锛�2:楠岃瘉瀵嗙爜;3:鍏抽棴瀵嗙爜;4:鍏抽棴瑙i攣璁剧疆;5:鎸囩汗ID寮�鍏筹紱6:闈㈠ID寮�鍏�;7:瑙i攣楠岃瘉</param>
+ void PasswordInputError(string optionType)
+ {
+ int errorTextID = 0;
+ if (optionType == "1")
+ {
+ //涓ゆ杈撳叆瀵嗙爜涓嶄竴鑷达紝璇烽噸鏂拌緭鍏�
+ errorTextID = StringId.IncorrectRepeatPassword;
+ }
+ else
+ {
+ //楠岃瘉澶辫触锛屽瘑鐮侀敊璇�.
+ errorTextID = StringId.AuthenticationFailedPasswordError;
+ }
+
+ btnTipError.TextID = errorTextID;
+ etPassword.Text = "";
+ btnTipError.Visible = true;
+ }
+
+
+
+ /// <summary>
+ /// 瀵嗙爜楠岃瘉閫氳繃鍚庣殑鎿嶄綔
+ /// </summary>
+ /// <param name="optionType">1:璁剧疆瀵嗙爜锛�2:楠岃瘉瀵嗙爜;3:鍏抽棴瀵嗙爜;4:鍏抽棴瑙i攣璁剧疆;5:鎸囩汗ID寮�鍏筹紱6:闈㈠ID寮�鍏�;7:瑙i攣楠岃瘉</param>
+ void PasswordInputPassed(string optionType)
+ {
+ if (optionType == "1")
+ {
+ //璁剧疆瀵嗙爜 楠岃瘉閫氳繃
+ this.RemoveFromParent();
+ var page = new OperationResultDisPalyPage();
+ page.Show();
+
+ page.LoadPage(true, Language.StringByID(StringId.SetSuccessfully), Language.StringByID(StringId.SetSuccessfully), "");
+ string tipMsg = TouchIDUtils.getTouchIDSupperType() == TouchIDUtils.TouchIDSupperType.TouchID ? Language.StringByID(StringId.TurnOnFingerprintUnlocking) :
+ Language.StringByID(StringId.TurnOnFaceIdUnlocking);
+
+ if (TouchIDUtils.getTouchIDSupperType() != TouchIDUtils.TouchIDSupperType.None)
{
- if (optionType == "7")
+ var unlockType = TouchIDUtils.getTouchIDSupperType() == TouchIDUtils.TouchIDSupperType.TouchID ? "3" : "4";
+
+ //濡傛灉涔嬪墠娌¤缃寚绾规垨鑰呴潰瀹笽D鎵嶆樉绀烘槸鍚﹀紑鍚�
+ if (!UserInfo.Current.appUnlockType.Contains(unlockType))
{
- MainPage.GoLoginPage( UserInfo.Current);
- }
- else
- {
- Action<string> action = (pw) => {
- var resultObj = new HttpServerRequest().LoginByPassword( UserInfo.Current.AccountString, pw);
- if (resultObj.Code.ToUpper() == StateCode.SUCCESS)
+ Action<bool> action = (result) =>
+ {
+ if (result)
{
- OnAppConfig.Instance.appUnlockPasswrod = "";
- OnAppConfig.Instance.appUnlockType = new System.Collections.Generic.List<string>();
- OnAppConfig.Instance.SaveUserConfig();
- this.RemoveFromParent();
- backAction();
+ if (!UserInfo.Current.appUnlockType.Contains(unlockType))
+ {
+ UserInfo.Current.appUnlockType.Add(unlockType);
+ }
}
else
{
- //鐧诲綍澶辫触
- IMessageCommon.Current.ShowErrorInfoAlter(resultObj.Code);
+ if (UserInfo.Current.appUnlockType.Contains(unlockType))
+ {
+ UserInfo.Current.appUnlockType.Remove(unlockType);
+ }
}
-
+ backAction();
+ UserInfo.Current.SaveUserInfo();
};
- new PublicAssmebly().LoadDialog_EditParater(StringId.EnterLoginPasswordVerification, "", action, StringId.PlsEntryPassword, 0, new System.Collections.Generic.List<string>(), true);
- }
- };
- }
+
+ page.AdditionalOperations(tipMsg, action);
+ }
+ }
+ if (!UserInfo.Current.appUnlockType.Contains("1"))
+ {
+ UserInfo.Current.appUnlockType.Add("1");
+ }
+ UserInfo.Current.appUnlockPasswrod = passwrod;
+ UserInfo.Current.SaveUserInfo();
+ backAction();
+ }
+ else if (optionType == "2")
+ {
+ //楠岃瘉瀵嗙爜閫氳繃
+ //绉婚櫎褰撳墠鐣岄潰锛屾瘡娆¤繑鍥為兘杩斿洖鍒版渶涓婄骇
+ this.RemoveFromParent();
+ var page = new AppUnlockPasswordPage("", backAction);
+ MainPage.BasePageView.AddChidren(page);
+ page.LoadPage("1");
+ MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+ }
+ else if (optionType == "3" || optionType == "4")
+ {
+ //3:鍏抽棴瀵嗙爜;4:鍏抽棴瑙i攣璁剧疆 閫氳繃
+ if (optionType == "4")
+ {
+ backAction();
+ this.RemoveFromParent();
+ return;
+ }
+ if (UserInfo.Current.appUnlockType.Contains("1"))
+ {
+ UserInfo.Current.appUnlockType = new System.Collections.Generic.List<string>();//.Remove("1");
+ UserInfo.Current.appUnlockPasswrod = "";
+ UserInfo.Current.SaveUserInfo();
+ this.RemoveFromParent();
+ backAction();
+ }
+ }
+ else if (optionType == "5")
+ {
+ //5:鎸囩汗ID寮�鍏� 閫氳繃
+ if (UserInfo.Current.appUnlockType.Contains("3"))
+ {
+ UserInfo.Current.appUnlockType.Remove("3");
+ }
+ else
+ {
+ UserInfo.Current.appUnlockType.Add("3");
+ }
+ UserInfo.Current.SaveUserInfo();
+ this.RemoveFromParent();
+ backAction();
+ }
+ else if (optionType == "6")
+ {
+ //6:闈㈠ID寮�鍏� 閫氳繃
+ if (UserInfo.Current.appUnlockType.Contains("4"))
+ {
+ UserInfo.Current.appUnlockType.Remove("4");
+ }
+ else
+ {
+ UserInfo.Current.appUnlockType.Add("4");
+ }
+ UserInfo.Current.SaveUserInfo();
+ this.RemoveFromParent();
+ backAction();
+ }
+ else if (optionType == "7")
+ {
+ //7:瑙i攣楠岃瘉 閫氳繃
+ this.RemoveFromParent();
+ backAction();
+ }
+ }
+
+
+ /// <summary>
+ /// 浣跨敤璐︽埛瀵嗙爜鐧诲綍鎸夐挳 鎻愮ず鎸夐挳
+ /// </summary>
+ void AddLoginTipButton()
+ {
+ Button btnLoginAccountVerify = new Button()
+ {
+ Y = Application.GetRealHeight(517),
+ Height = Application.GetRealHeight(60),
+ TextAlignment = TextAlignment.Center,
+ TextSize = CSS_FontSize.TextFontSize,
+ TextColor = CSS_Color.MainColor,
+ TextID = StringId.LogWithAccountAndPassword,
+ };
+ bodyView.AddChidren(btnLoginAccountVerify);
+
+ btnLoginAccountVerify.MouseUpEventHandler = (sender, e) =>
+ {
+ //閫�鍑虹櫥褰�
+ HDLCommon.Current.Logout();
+ };
+ }
+
+ /// <summary>
+ /// 杈撳叆鐧诲綍瀵嗙爜楠岃瘉 鎻愮ず鎸夐挳
+ /// </summary>
+ void AddInputPasswordTipButton(string optionType)
+ {
+ Button btnLoginAccountVerify = new Button()
+ {
+ Y = Application.GetRealHeight(517),
+ Height = Application.GetRealHeight(60),
+ TextAlignment = TextAlignment.Center,
+ TextSize = CSS_FontSize.TextFontSize,
+ TextColor = CSS_Color.MainColor,
+ TextID = StringId.EnterLoginPasswordVerification,
+ };
+ bodyView.AddChidren(btnLoginAccountVerify);
+
+ btnLoginAccountVerify.MouseUpEventHandler = (sender, e) =>
+ {
+ //杈撳叆鐧诲綍瀵嗙爜楠岃瘉
+ Action<string> action = (pw) =>
+ {
+ AuthenticationByLoginPassword(pw, optionType);
+ //var resultObj = new HttpServerRequest().LoginByPassword(UserInfo.Current.AccountString, pw);
+ //if (resultObj.Code == StateCode.SUCCESS)
+ //{
+ // PasswordInputPassed(optionType);
+ //}
+ //else
+ //{
+ // Application.RunOnMainThread(() =>
+ // {
+ // Utlis.ShowTip(Language.StringByID(StringId.AuthenticationFailedPasswordError));
+ // });
+
+ //}
+
+ };
+ new PublicAssmebly().LoadDialog_EditParater(StringId.EnterLoginPasswordVerification, "", action, StringId.PlsEntryPassword, 0, new System.Collections.Generic.List<string>(), true);
+ };
+ }
+
+ /// <summary>
+ /// 鐧诲綍瀵嗙爜楠岃瘉
+ /// </summary>
+ /// <param name="pw"></param>
+ /// <param name="optionType"></param>
+ void AuthenticationByLoginPassword(string pw, string optionType)
+ {
+ var waitPage = new Loading();
+ bodyView.AddChidren(waitPage);
+ waitPage.Start(Language.StringByID(StringId.PleaseWait));
+
+ new System.Threading.Thread(() =>
+ {
+ try
+ {
+ var resultObj = new HttpServerRequest().LoginByPassword(UserInfo.Current.AccountString, pw);
+ Application.RunOnMainThread(() =>
+ {
+ if (resultObj.Code == StateCode.SUCCESS)
+ {
+ PasswordInputPassed(optionType);
+ }
+ else
+ {
+ Utlis.ShowTip(Language.StringByID(StringId.AuthenticationFailedPasswordError));
+ }
+ });
+ }
+ catch { }
+ finally
+ {
+ Application.RunOnMainThread(() =>
+ {
+ if (waitPage != null)
+ {
+ waitPage.RemoveFromParent();
+ waitPage = null;
+ }
+ });
+ }
+ })
+ { IsBackground = true }.Start();
}
}
}
--
Gitblit v1.8.0