From 768287335bee13527b0fa612ec3f209d3c2089e8 Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期四, 13 七月 2023 13:28:50 +0800
Subject: [PATCH] 萤石门锁功能,人脸开锁设置

---
 HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/UnlockSettingFacePage.cs |  155 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 151 insertions(+), 4 deletions(-)

diff --git a/HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/UnlockSettingFacePage.cs b/HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/UnlockSettingFacePage.cs
index bd0cae2..090921c 100644
--- a/HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/UnlockSettingFacePage.cs
+++ b/HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/UnlockSettingFacePage.cs
@@ -1,23 +1,32 @@
 锘縰sing System;
+using HDL_ON.Common;
+using HDL_ON.DAL.Server;
+using HDL_ON.Entity;
 using HDL_ON.UI.CSS;
 using Shared;
 namespace HDL_ON.UI.UI2.FuntionControlView.VideoDoorLock
 {
+    /// <summary>
+    /// 钀ょ煶瑙嗛闂ㄩ攣-浜鸿劯寮�閿佽缃〉闈�
+    /// </summary>
     public class UnlockSettingFacePage : FrameLayout
     {
         FrameLayout bodyView;
         bool faceUnlockSwitch;
 
+        Function device;
 
-        public UnlockSettingFacePage()
+        public UnlockSettingFacePage(Function function)
         {
             bodyView = this;
+            device = function;
         }
 
         public void LoadPage()
         {
-            new TopViewDiv(bodyView, Language.StringByID(StringId.FaceUnlockSetting)).LoadTopView();
+            var faceUnlockSetup = new FaceUnlockSetupObj();
 
+            new TopViewDiv(bodyView, Language.StringByID(StringId.FaceUnlockSetting)).LoadTopView();
 
             var contentView = new VerticalScrolViewLayout()
             {
@@ -58,7 +67,7 @@
                 TextColor = CSS_Color.PromptingColor1,
                 TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
                 IsMoreLines = true,
-                TextID = StringId.FaceUnlockTip
+                TextID = StringId.FaceUnlockOpenTip
             };
             faceUnlockView.AddChidren(btnFaceUnlockTipText);
 
@@ -73,6 +82,68 @@
                 IsSelected = faceUnlockSwitch,
             };
             faceUnlockView.AddChidren(btnFaceUnlockSwitchIcon);
+
+
+
+            var waitPage = new Loading();
+            bodyView.AddChidren(waitPage);
+            waitPage.Start("");
+
+            btnFaceUnlockSwitchIcon.MouseUpEventHandler = (sender, e) =>
+            {
+                waitPage.Start("");
+                bool changeState = false;
+                if (!btnFaceUnlockSwitchIcon.IsSelected)
+                {
+                    btnFaceUnlockSwitchIcon.IsSelected = true;
+                    changeState = true;
+                }
+                new System.Threading.Thread(() =>
+                {
+                    try
+                    {
+                        var pack = ApiUtlis.Ins.HttpRequest.SetFaceUnlockCfg(device.deviceId, changeState, faceUnlockSetup.mode);
+                        if (pack != null && pack.Code == StateCode.SUCCESS)
+                        {
+                            Application.RunOnMainThread(() =>
+                            {
+                                //鏇存柊鐣岄潰
+                                btnFaceUnlockSwitchIcon.IsSelected = changeState;
+                            });
+                        }
+                        else
+                        {
+                            //澶辫触鎻愮ず
+                            Application.RunOnMainThread(() =>
+                            {
+                                if (!string.IsNullOrEmpty(pack.message))
+                                {
+                                    var tip = new Tip()
+                                    {
+                                        MaxWidth = Application.GetRealWidth(300),
+                                        Text = $"{pack.message}({pack.Code})",
+                                        CloseTime = 3,
+                                        Direction = AMPopTipDirection.None
+                                    };
+                                    tip.Show(MainPage.BaseView);
+                                }
+                            });
+                        }
+                    }
+                    catch (Exception ex)
+                    {
+                        MainPage.Log($"btnFaceUnlockSwitchIcon error : {ex.Message}");
+                    }
+                    finally
+                    {
+                        Application.RunOnMainThread(() =>
+                        {
+                            waitPage.Hide();
+                        });
+                    }
+                })
+                { IsBackground = true }.Start();
+            };
             #endregion
 
             contentView.AddChidren(new Button()
@@ -106,7 +177,6 @@
                 TextAlignment = TextAlignment.CenterRight,
                 TextSize = CSS_FontSize.TextFontSize,
                 TextColor = CSS_Color.PromptingColor1,
-                TextID = StringId.ManualTriggering,
             };
             triggerModeView.AddChidren(btnTriggerModeStateText);
 
@@ -122,6 +192,10 @@
 
             btnTriggerModeText.MouseUpEventHandler = (sender, e) =>
             {
+                var page = new VideoDoorlockFaceUnlockTriggerSettingPage(device, faceUnlockSetup);
+                MainPage.BasePageView.AddChidren(page);
+                page.LoadPage();
+                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
 
             };
             #endregion
@@ -170,7 +244,80 @@
 
 
 
+
+
+            new System.Threading.Thread(() => {
+                try
+                {
+                    var pack = ApiUtlis.Ins.HttpRequest.GetFaceUnlockCfg(device.deviceId);
+                    if (pack != null && pack.Code == StateCode.SUCCESS)
+                    {
+                        Application.RunOnMainThread(() =>
+                        {
+                            //鏇存柊鐣岄潰
+                            faceUnlockSetup = Newtonsoft.Json.JsonConvert.DeserializeObject<FaceUnlockSetupObj>(pack.Data.ToString());
+                            btnFaceUnlockSwitchIcon.IsSelected = faceUnlockSetup.enabled;
+
+                            btnTriggerModeStateText.TextID = faceUnlockSetup.mode == 0 ? StringId.AutomaticTriggering : StringId.ManualTriggering;
+                        });
+                    }
+                    else
+                    {
+                        //澶辫触鎻愮ず
+                        Application.RunOnMainThread(() =>
+                        {
+                            if (!string.IsNullOrEmpty(pack.message))
+                            {
+                                var tip = new Tip()
+                                {
+                                    MaxWidth = Application.GetRealWidth(300),
+                                    Text = $"{pack.message}({pack.Code})",
+                                    CloseTime = 3,
+                                    Direction = AMPopTipDirection.None
+                                };
+                                tip.Show(MainPage.BaseView);
+                            }
+                        });
+                    }
+
+
+                }
+                catch (Exception ex)
+                {
+                    MainPage.Log($"UnlockSettingPage error : {ex.Message}");
+                }
+                finally
+                {
+                    Application.RunOnMainThread(() =>
+                    {
+                        waitPage.Hide();
+                    });
+                }
+
+            })
+            { IsBackground = true }.Start();
+
         }
 
     }
+
+    /// <summary>
+    /// 浜鸿劯寮�閿侀厤缃�
+    /// </summary>
+    public class FaceUnlockSetupObj
+    {
+        /// <summary>
+        /// 寮�鍏�
+        /// </summary>
+        public bool enabled;
+        /// <summary>
+        /// 瑙i攣鏂瑰紡 0-鑷姩 1-鎵嬪姩
+        /// </summary>
+        public int mode;
+        /// <summary>
+        /// 鐏垫晱搴� 0-楂� 1-浣�
+        /// </summary>
+        public int sensitivity;
+
+    }
 }

--
Gitblit v1.8.0