From ffdeae1a43e1539f9533f93d64089994db6c742b Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期三, 09 六月 2021 17:23:01 +0800
Subject: [PATCH] Merge branch 'tzy2' into wxr6

---
 HDL_ON/UI/UI0-Stan/Logic/HdlCheckLogic.cs |  246 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 246 insertions(+), 0 deletions(-)

diff --git a/HDL_ON/UI/UI0-Stan/Logic/HdlCheckLogic.cs b/HDL_ON/UI/UI0-Stan/Logic/HdlCheckLogic.cs
new file mode 100644
index 0000000..fcc986b
--- /dev/null
+++ b/HDL_ON/UI/UI0-Stan/Logic/HdlCheckLogic.cs
@@ -0,0 +1,246 @@
+锘縰sing Shared;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace HDL_ON.Stan
+{
+    /// <summary>
+    /// 鍏遍�氭娴嬮�昏緫
+    /// </summary>
+    public class HdlCheckLogic
+    {
+        #region 鈻� 鍙橀噺澹版槑___________________________
+
+        /// <summary>
+        /// 鍏遍�氭娴嬮�昏緫
+        /// </summary>
+        private static HdlCheckLogic m_Current = null;
+        /// <summary>
+        /// 鍏遍�氭娴嬮�昏緫
+        /// </summary>
+        public static HdlCheckLogic Current
+        {
+            get
+            {
+                if (m_Current == null)
+                {
+                    m_Current = new HdlCheckLogic();
+                }
+                return m_Current;
+            }
+        }
+
+        /// <summary>
+        /// 楠岃瘉璁よ瘉鐨勬鏁�
+        /// </summary>
+        private int checkSecurityCount = 3;
+
+        #endregion
+
+        #region 鈻� 楠岃瘉瑙i攣璁よ瘉_______________________
+
+        /// <summary>
+        /// 楠岃瘉瑙i攣璁よ瘉
+        /// </summary>
+        /// <param name="addTopFrame">楠岃瘉鐣岄潰鏄惁娣诲姞澶撮儴Frame(鍙鎵嬪娍瀵嗙爜鍜屾暟瀛楀瘑鐮佹湁鏁�)</param>
+        /// <param name="successEvent">楠岃瘉鎴愬姛涔嬪悗鐨勫洖璋冨嚱鏁�,澶辫触涓嶄細鍥炶皟(0:娌℃湁璁剧疆鏈夐獙璇� 1:楠岃瘉鎴愬姛锛�</param>
+        /// <param name="loadPageBeforEvent">鍔犺浇鎸囧畾瑙i攣璁よ瘉鐣岄潰涔嬪墠鐨勪簨浠�,0:鍙栨秷褰撳墠楠岃瘉骞跺垏鎹㈠埌鍏朵粬鏂瑰紡,1:鏁板瓧瀵嗙爜,2:鎵嬪娍瀵嗙爜,3:鎸囩汗瀵嗙爜,4:闈㈠ID</param>
+        public void CheckUnlockSecurity(bool addTopFrame, Action<int> successEvent, Action<string> loadPageBeforEvent = null)
+        {
+            //楠岃瘉鎸囩汗鍜岄潰瀹筰d閮戒娇鐢ㄦ寚绾归獙璇�
+            if (UserInfo.Current.appUnlockType.Contains("3") || UserInfo.Current.appUnlockType.Contains("4"))
+            {
+                //鍏堟妸杩欎釜涓滆タ缃┖
+                TouchIDUtils.Instance.OnHDLTouchIDStateBackEvent = null;
+
+                TouchIDUtils.TouchIDSupperType type = TouchIDUtils.getTouchIDSupperType();
+                if (type == TouchIDUtils.TouchIDSupperType.TouchID)
+                {
+                    //閫氱煡浣跨敤鎸囩汗楠岃瘉
+                    loadPageBeforEvent?.Invoke("3");
+
+                    //Touch ID楠岃瘉
+                    TouchIDUtils.Instance.OnHDLTouchIDStateBackEvent += (sender2, e2) =>
+                    {
+                        if (e2 == TouchIDUtils.TouchIDState.Success)
+                        {
+                            //娆℃暟杩樺師
+                            this.checkSecurityCount = 3;
+
+                            //TouchID楠岃瘉鎴愬姛
+                            successEvent?.Invoke(1);
+                            successEvent = null;
+                            loadPageBeforEvent = null;
+                            TouchIDUtils.Instance.OnHDLTouchIDStateBackEvent = null;
+                        }
+                        else if (e2 == TouchIDUtils.TouchIDState.InputPassword)
+                        {
+                            //閫氱煡鍙栨秷浜嗛獙璇�,鍒囨崲涓哄叾浠栭獙璇�
+                            loadPageBeforEvent?.Invoke("0");
+
+                            //浣跨敤瀵嗙爜鎴栬�呮墜鍔垮瘑鐮佽В閿佽璇�
+                            this.CheckUnlockSecurityByPassword(addTopFrame, successEvent, loadPageBeforEvent);
+                        }
+                    };
+                    //鎻愮ず鏁板瓧瀵嗙爜楠岃瘉杩樻槸缁樺埗鎵嬪娍楠岃瘉
+                    string strTitle = this.GetVerificationTitleString();
+
+                    TouchIDUtils.Instance.showTouchIDWithDescribe(strTitle, Language.StringByID(StringId.PleaseVerifyTheFingerprint));
+                }
+                //浠栧叧闂簡鎵嬫満鐨勬寚绾归獙璇�
+                else
+                {
+                    //浣跨敤瀵嗙爜鎴栬�呮墜鍔垮瘑鐮佽В閿佽璇�
+                    this.CheckUnlockSecurityByPassword(addTopFrame, successEvent, loadPageBeforEvent);
+                }
+            }
+            else
+            {
+                //浣跨敤瀵嗙爜鎴栬�呮墜鍔垮瘑鐮佽В閿佽璇�
+                this.CheckUnlockSecurityByPassword(addTopFrame, successEvent, loadPageBeforEvent);
+            }
+        }
+
+        /// <summary>
+        /// 浣跨敤瀵嗙爜鎴栬�呮墜鍔垮瘑鐮佽В閿佽璇�
+        /// </summary>
+        /// <param name="addTopFrame">楠岃瘉鐣岄潰鏄惁娣诲姞澶撮儴Frame(鍙鎵嬪娍瀵嗙爜鍜屾暟瀛楀瘑鐮佹湁鏁�)</param>
+        /// <param name="successEvent">楠岃瘉鎴愬姛涔嬪悗鐨勫洖璋冨嚱鏁�,澶辫触涓嶄細鍥炶皟(0:娌℃湁璁剧疆鏈夐獙璇� 1:楠岃瘉鎴愬姛锛�</param>
+        /// <param name="loadPageBeforEvent">鍔犺浇鎸囧畾瑙i攣璁よ瘉鐣岄潰涔嬪墠鐨勪簨浠�,1:鏁板瓧瀵嗙爜,2:鎵嬪娍瀵嗙爜,3:鎸囩汗瀵嗙爜,4:闈㈠ID</param>
+        private void CheckUnlockSecurityByPassword(bool addTopFrame, Action<int> successEvent, Action<string> loadPageBeforEvent = null)
+        {
+            if (UserInfo.Current.appUnlockType.Contains("1"))
+            {
+                //閫氱煡浣跨敤鏁板瓧瀵嗙爜楠岃瘉
+                loadPageBeforEvent?.Invoke("1");
+
+                //鏄剧ず鏁板瓧瀵嗙爜瑙i攣璁よ瘉鐣岄潰
+                this.ShowAppNumPasswordSecurityForm(addTopFrame, successEvent);
+            }
+            else if (UserInfo.Current.appUnlockType.Contains("2"))
+            {
+                //閫氱煡浣跨敤鎵嬪娍瀵嗙爜楠岃瘉
+                loadPageBeforEvent?.Invoke("2");
+
+                //鏄剧ず鎵嬪娍瀵嗙爜瑙i攣璁よ瘉鐣岄潰
+                this.ShowAppGestureSecurityForm(addTopFrame, successEvent);
+            }
+            else
+            {
+                //娌℃湁璁剧疆鏈夐獙璇�
+                successEvent?.Invoke(0);
+                successEvent = null;
+            }
+        }
+
+        /// <summary>
+        /// 鏄剧ず鏁板瓧瀵嗙爜瑙i攣璁よ瘉鐣岄潰
+        /// </summary>
+        /// <param name="addTopFrame">楠岃瘉鐣岄潰鏄惁娣诲姞澶撮儴Frame(鍙鎵嬪娍瀵嗙爜鍜屾暟瀛楀瘑鐮佹湁鏁�)</param>
+        /// <param name="successEvent">楠岃瘉鎴愬姛涔嬪悗鐨勫洖璋冨嚱鏁�,澶辫触涓嶄細鍥炶皟(0:娌℃湁璁剧疆鏈夐獙璇� 1:楠岃瘉鎴愬姛锛�</param>
+        private void ShowAppNumPasswordSecurityForm(bool addTopFrame, Action<int> successEvent)
+        {
+            var form = new AppNumPasswordSecurityForm();
+            form.AddForm(addTopFrame, Language.StringByID(StringId.PlsEntryPassword), string.Empty);
+            form.ActionEvent += (div, password) =>
+            {
+                //瀵嗙爜杈撳叆缁撴潫
+                if (div == 1)
+                {
+                    //瀵嗙爜姝g‘
+                    if (UserInfo.Current.appUnlockPasswrod == password)
+                    {
+                        //娆℃暟杩樺師
+                        this.checkSecurityCount = 3;
+
+                        form.CloseForm();
+                        //鍥炶皟
+                        successEvent?.Invoke(1);
+                        successEvent = null;
+                    }
+                    else
+                    {
+                        this.checkSecurityCount--;
+                        if (this.checkSecurityCount == 0)
+                        {
+                            //绠$悊鍛樿韩浠介獙璇佸け璐�,璇烽噸鏂扮櫥褰�
+                            HdlMessageLogic.Current.ShowMassage(ShowMsgType.Tip, Language.StringByID(StringId.CheckAdminFailAndLoginAgain));
+                            HDLCommon.Current.Logout();
+
+                            this.checkSecurityCount = 3;
+                            return;
+                        }
+                        //楠岃瘉澶辫触锛屽瘑鐮侀敊璇�.
+                        form.ShowErrorMsg(Language.StringByID(StringId.AuthenticationFailedPasswordError));
+                    }
+                }
+            };
+        }
+
+        /// <summary>
+        /// 鏄剧ず鎵嬪娍瀵嗙爜瑙i攣璁よ瘉鐣岄潰
+        /// </summary>
+        /// <param name="addTopFrame">楠岃瘉鐣岄潰鏄惁娣诲姞澶撮儴Frame(鍙鎵嬪娍瀵嗙爜鍜屾暟瀛楀瘑鐮佹湁鏁�)</param>
+        /// <param name="successEvent">楠岃瘉鎴愬姛涔嬪悗鐨勫洖璋冨嚱鏁�,澶辫触涓嶄細鍥炶皟(0:娌℃湁璁剧疆鏈夐獙璇� 1:楠岃瘉鎴愬姛锛�</param>
+        private void ShowAppGestureSecurityForm(bool addTopFrame, Action<int> successEvent)
+        {
+            var form = new AppGestureSecurityForm();
+            form.AddForm(addTopFrame, Language.StringByID(StringId.VerifyGesturePassword), string.Empty);
+            form.SetTitleText(string.Empty);
+            form.ActionEvent += (div, password) =>
+            {
+                //瀵嗙爜杈撳叆缁撴潫
+                if (div == 1)
+                {
+                    //瀵嗙爜姝g‘
+                    if (UserInfo.Current.appUnlockPasswrod == password)
+                    {
+                        //娆℃暟杩樺師
+                        this.checkSecurityCount = 3;
+
+                        form.CloseForm();
+                        //鍥炶皟
+                        successEvent?.Invoke(1);
+                        successEvent = null;
+                    }
+                    else
+                    {
+                        this.checkSecurityCount--;
+                        if (this.checkSecurityCount == 0)
+                        {
+                            //绠$悊鍛樿韩浠介獙璇佸け璐�,璇烽噸鏂扮櫥褰�
+                            HdlMessageLogic.Current.ShowMassage(ShowMsgType.Tip, Language.StringByID(StringId.CheckAdminFailAndLoginAgain));
+                            HDLCommon.Current.Logout();
+
+                            this.checkSecurityCount = 3;
+                            return;
+                        }
+
+                        //楠岃瘉澶辫触锛屽瘑鐮侀敊璇�.
+                        form.ShowErrorMsg(Language.StringByID(StringId.AuthenticationFailedPasswordError));
+                    }
+                }
+            };
+        }
+
+        /// <summary>
+        /// 鍒ゆ柇鏄惁鏁板瓧楠岃瘉銆佸惁鍒欑粯鍒舵墜鍔块獙璇�
+        /// </summary>
+        /// <returns></returns>
+        private string GetVerificationTitleString()
+        {
+            //浼樺厛浣跨敤瀵嗙爜楠岃瘉,瀵嗙爜楠岃瘉鍜屾墜鍔块獙璇佷笉鍏卞瓨
+            if (UserInfo.Current.appUnlockType.Contains("1") == true)
+            {
+                return Language.StringByID(StringId.PasswordVerification);
+            }
+            else
+            {
+                return Language.StringByID(StringId.GestureVerification);
+            }
+        }
+
+        #endregion
+    }
+}

--
Gitblit v1.8.0