From eda3fb873e59544ff36301b51e05aef64f87b0f9 Mon Sep 17 00:00:00 2001
From: wei <kaede@kaededeMacBook-Air.local>
Date: 星期五, 27 八月 2021 13:21:21 +0800
Subject: [PATCH] Merge branch 'newBranch1' of http://172.16.1.23:6688/r/~wxr/HDL_APP_Project into newBranch1

---
 HDL_ON/UI/UI2/4-PersonalCenter/FaceManagement/FacePassagePage.cs |  448 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 422 insertions(+), 26 deletions(-)

diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/FaceManagement/FacePassagePage.cs b/HDL_ON/UI/UI2/4-PersonalCenter/FaceManagement/FacePassagePage.cs
index 3285aae..99cbb0c 100644
--- a/HDL_ON/UI/UI2/4-PersonalCenter/FaceManagement/FacePassagePage.cs
+++ b/HDL_ON/UI/UI2/4-PersonalCenter/FaceManagement/FacePassagePage.cs
@@ -1,4 +1,7 @@
 锘縰sing System;
+using System.Threading;
+using HDL_ON.DAL.Server;
+using HDL_ON.Entity;
 using HDL_ON.UI.CSS;
 using Shared;
 
@@ -7,10 +10,44 @@
     public class FacePassagePage : FrameLayout
     {
         FrameLayout bodyView;
+
+        FrameLayout contentView;
+        Button btnCommunityAccessControlIcon;
+
+        Button btnSetFaceId;
+
+        Button btnEraseData;
+
+        #region 鍥炬爣閫夋嫨閮ㄥ垎鍥炬爣
         /// <summary>
-        /// 闈㈠id
+        /// 鑳屾櫙鍥鹃�夐」鍖哄煙
         /// </summary>
-        string faceid = "";
+        FrameLayout pictureOptionView;
+        /// <summary>
+        /// 鑳屾櫙鍥鹃�夐」閫夋嫨鍖哄煙
+        /// </summary>
+        VerticalScrolViewLayout optionView;
+        /// <summary>
+        /// 鎷嶇収鎸夐挳
+        /// </summary>
+        Button btnTakePicture;
+        /// <summary>
+        /// 鐩稿唽鎸夐挳
+        /// </summary>
+        Button btnAlbum;
+        /// <summary>
+        /// 鍙栨秷鎸夐挳
+        /// </summary>
+        Button btnCancel;
+        #endregion
+
+
+
+
+        /// <summary>
+        /// 浣忔埛璇︽儏
+        /// </summary>
+        CustomerObj customerObj = new CustomerObj();
 
         public FacePassagePage()
         {
@@ -23,7 +60,7 @@
             bodyView.BackgroundColor = CSS_Color.BackgroundColor;
 
 
-            var contentView = new FrameLayout()
+            contentView = new FrameLayout()
             {
                 Y = Application.GetRealHeight(64),
                 Height = Application.GetRealHeight(667-64),
@@ -82,7 +119,7 @@
             communityRow.AddChidren(btnCommunityTitle);
 
 
-            var btnCommunityAccessControlIcon = new Button()
+            btnCommunityAccessControlIcon = new Button()
             {
                 X = Application.GetRealWidth(314),
                 Gravity = Gravity.CenterVertical,
@@ -93,7 +130,20 @@
             };
             communityRow.AddChidren(btnCommunityAccessControlIcon);
 
+            btnCommunityAccessControlIcon.MouseUpEventHandler = (sender, e) => {
+                if(customerObj.faceClose == 3)//娌℃湁浜鸿劯鏁版嵁涓嶈兘寮�鍚汉鑴搁�氳鍔熻兘
+                {
+                    return;
+                }
+                btnCommunityAccessControlIcon.IsSelected = !btnCommunityAccessControlIcon.IsSelected;
+                int switchStatus = btnCommunityAccessControlIcon.IsSelected == true ? 1 :2;
 
+                //澶辫触鍥炶皟
+                Action action = () => {
+                    btnCommunityAccessControlIcon.IsSelected = !btnCommunityAccessControlIcon.IsSelected;
+                };
+                editFaceInfo(switchStatus,action);
+            };
 
             #endregion
 
@@ -110,7 +160,7 @@
             contentView.AddChidren(btnTip);
 
 
-            var btnSetFaceId = new Button()
+            btnSetFaceId = new Button()
             {
                 Y = Application.GetRealHeight(539),
                 Gravity = Gravity.CenterHorizontal,
@@ -125,32 +175,378 @@
                 IsBold = true,
             };
             contentView.AddChidren(btnSetFaceId);
+            btnSetFaceId.MouseUpEventHandler = (sender, e) => {
+                LoadPictureOptionView();
+            };
 
-            if (string.IsNullOrEmpty(faceid))
+            btnEraseData = new Button()
             {
-            }
-            else
-            {
-                btnSetFaceId.TextID = StringId.ResetFace;
-
-                var btnEraseData = new Button()
-                {
-                    Y = Application.GetRealHeight(481),
-                    Gravity = Gravity.CenterHorizontal,
-                    Width = Application.GetRealWidth(220),
-                    Height = Application.GetRealWidth(44),
-                    Radius = (uint)Application.GetRealWidth(22),
-                    BackgroundColor = CSS_Color.WarningColor,
-                    TextID = StringId.EraseData,
-                    TextSize = CSS_FontSize.SubheadingFontSize,
-                    TextColor = CSS_Color.MainBackgroundColor,
-                    TextAlignment = TextAlignment.Center,
-                    IsBold = true,
+                Y = Application.GetRealHeight(481),
+                Gravity = Gravity.CenterHorizontal,
+                Width = Application.GetRealWidth(220),
+                Height = Application.GetRealWidth(44),
+                Radius = (uint)Application.GetRealWidth(22),
+                BackgroundColor = CSS_Color.WarningColor,
+                TextID = StringId.EraseData,
+                TextSize = CSS_FontSize.SubheadingFontSize,
+                TextColor = CSS_Color.MainBackgroundColor,
+                TextAlignment = TextAlignment.Center,
+                IsBold = true,
+            };
+            btnEraseData.MouseUpEventHandler = (sender,e) => {
+                Action action = () => {
+                    initButtonStatus();
                 };
-                contentView.AddChidren(btnEraseData);
-            }
+                editFaceInfo(3,action);
+            };
 
+            ReadFaceInfo();
+        }
+
+        /// <summary>
+        /// 鑾峰彇浜鸿劯淇℃伅
+        /// </summary>
+        void ReadFaceInfo()
+        {
+            var waitPage = new Loading();
+            waitPage.Start();
+            new Thread(() =>
+            {
+                try
+                {
+                    var hsr = new HttpServerRequest();
+                    var pack = hsr.GetCustomerInfo();
+                    if (pack != null)
+                    {
+                        if (pack.Code == StateCode.SUCCESS)
+                        {
+                            var cus = Newtonsoft.Json.JsonConvert.DeserializeObject<CustomerObj>(pack.Data.ToString());
+                            if (cus != null)
+                            {
+                                customerObj = cus;
+                                Application.RunOnMainThread(() =>
+                                {
+                                    initButtonStatus();
+                                });
+                            }
+
+                        }
+                    }
+                }catch(Exception ex)
+                {
+                    MainPage.Log($"璇诲彇浜鸿劯淇℃伅寮傚父:{ex.Message}");
+                }
+                finally
+                {
+                    Application.RunOnMainThread(() => {
+                        if (waitPage != null)
+                        {
+                            waitPage.RemoveFromParent();
+                            waitPage = null;
+                        }
+                    });
+                }
+            })
+            { IsBackground = true }.Start();
+        }
+        /// <summary>
+        /// 娓呴櫎浜鸿劯鏁版嵁
+        /// </summary>
+        void editFaceInfo(int status,Action action)
+        {
+            var waitPage = new Loading();
+            waitPage.Start();
+            new Thread(() =>
+            {
+                try
+                {
+                    var hsr = new HttpServerRequest();
+                    var pack = hsr.EditFaceFunction(status);
+                    if (pack != null)
+                    {
+                        if (pack.Code == StateCode.SUCCESS)
+                        {
+                            customerObj.faceClose = status;
+                        }
+                        else
+                        {
+                            Application.RunOnMainThread(() =>
+                            {
+                                IMessageCommon.Current.ShowErrorInfoAlter(pack.Code);
+                            });
+                        }
+                    }
+                }
+                catch (Exception ex)
+                {
+                    MainPage.Log($"娓呴櫎浜鸿劯淇℃伅寮傚父:{ex.Message}");
+                }
+                finally
+                {
+                    Application.RunOnMainThread(() => {
+                        if (waitPage != null)
+                        {
+                            waitPage.RemoveFromParent();
+                            waitPage = null;
+                        }
+                        action?.Invoke();
+                    });
+                }
+            })
+            { IsBackground = true }.Start();
+        }
+
+        /// <summary>
+        /// 鍒濆鍖栧簳閮ㄦ寜閽�
+        /// </summary>
+        void initButtonStatus()
+        {
+            if (customerObj.faceClose == 1 || customerObj.faceClose == 2)//浜鸿劯鏁版嵁宸茬粡瀛樺湪1:浜鸿劯閫氳寮�鍚紱2锛氬叧闂�
+            {
+                if (customerObj.faceStatus == 2)//浜鸿劯鏁版嵁涓嬪彂闂ㄥ彛鏈烘垚鍔�
+                {
+                    btnCommunityAccessControlIcon.IsSelected = customerObj.faceClose == 1;//浜鸿劯閫氳鍔熻兘鏄惁寮�鍚�
+                    contentView.AddChidren(btnEraseData);
+                    btnSetFaceId.TextID = StringId.ResetFace;
+                    return;
+                }
+            }
+                btnCommunityAccessControlIcon.IsSelected = false;
+                btnEraseData.RemoveFromParent();
+                btnSetFaceId.TextID = StringId.SetFace;
+        }
+
+
+
+
+        /// <summary>
+        /// 鍔犺浇鍥炬爣閫夋嫨閫夐」
+        /// </summary>
+        void LoadPictureOptionView()
+        {
+            var pView = new FrameLayout()
+            {
+                BackgroundColor = CSS_Color.DialogTransparentColor1,
+            };
+            bodyView.AddChidren(pView);
+
+            pictureOptionView = new FrameLayout()
+            {
+                Y = Application.GetRealHeight(445+50),
+                Height = Application.GetRealHeight(250),
+                AnimateSpeed = 0.3f,
+                Animate = Animate.DownToUp,
+            };
+            pView.AddChidren(pictureOptionView);
+
+            optionView = new VerticalScrolViewLayout()
+            {
+                Gravity = Gravity.CenterHorizontal,
+                Width = Application.GetRealWidth(343),
+                Height = Application.GetRealHeight(100),
+                BackgroundColor = CSS_Color.MainBackgroundColor,
+                Radius = (uint)Application.GetRealWidth(12),
+            };
+            pictureOptionView.AddChidren(optionView);
+
+            btnTakePicture = new Button()
+            {
+                Height = Application.GetRealHeight(50),
+                TextAlignment = TextAlignment.Center,
+                TextColor = CSS_Color.TextualColor,
+                SelectedTextColor = CSS_Color.MainColor,
+                TextSize = CSS_FontSize.SubheadingFontSize,
+                TextID = StringId.TakePicture,
+            };
+            optionView.AddChidren(btnTakePicture);
+
+            optionView.AddChidren(new Button() { Height = Application.GetRealHeight(1), Width = Application.GetRealWidth(343), BackgroundColor = CSS_Color.DividingLineColor });
+
+            btnAlbum = new Button()
+            {
+                Height = Application.GetRealHeight(50),
+                TextAlignment = TextAlignment.Center,
+                TextColor = CSS_Color.TextualColor,
+                SelectedTextColor = CSS_Color.MainColor,
+                TextSize = CSS_FontSize.SubheadingFontSize,
+                TextID = StringId.Album,
+            };
+            optionView.AddChidren(btnAlbum);
+
+            optionView.AddChidren(new Button() { Height = Application.GetRealHeight(1), Width = Application.GetRealWidth(343), BackgroundColor = CSS_Color.DividingLineColor });
+
+            btnCancel = new Button()
+            {
+                Gravity = Gravity.CenterHorizontal,
+                Y = Application.GetRealHeight(8) + optionView.Bottom,
+                Width = Application.GetRealWidth(343),
+                Height = Application.GetRealHeight(50),
+                BackgroundColor = CSS_Color.MainBackgroundColor,
+                Radius = (uint)Application.GetRealWidth(12),
+                TextID = StringId.Cancel,
+                TextColor = CSS_Color.WarningColor,
+                TextSize = CSS_FontSize.SubheadingFontSize,
+            };
+            pictureOptionView.AddChidren(btnCancel);
+
+
+            LoadEvent_PictureOptionViewEventList(pView);
+        }
+
+        /// <summary>
+        /// 鍔犺浇鑳屾櫙鍥鹃�夋嫨鍖哄煙浜嬩欢鍒楄〃
+        /// </summary>
+        void LoadEvent_PictureOptionViewEventList(FrameLayout pView)
+        {
+            pictureOptionView.MouseUpEventHandler = (sender, e) =>
+            {
+                pictureOptionView.Parent.RemoveFromParent();
+            };
+            pView.MouseUpEventHandler = (sender, e) =>
+            {
+                pictureOptionView.Parent.RemoveFromParent();
+            };
+
+            btnCancel.MouseUpEventHandler = (sender, e) =>
+            {
+                pictureOptionView.Parent.RemoveFromParent();
+            };
+            btnTakePicture.MouseDownEventHandler = (sender, e) => {
+                btnTakePicture.IsSelected = true;
+            };
+            btnTakePicture.MouseUpEventHandler = (sender, e) =>
+            {
+                btnTakePicture.IsSelected = false;
+                var imageName = Guid.NewGuid().ToString();
+                CropImage.TakePicture((imagePath) =>
+                {
+                    CropImageCallBack(imagePath,1,imageName);
+                }, imageName, 4, 6, 1000);
+
+                pictureOptionView.Parent.RemoveFromParent();
+            };
+            btnAlbum.MouseDownEventHandler = (sender, e) => {
+                btnAlbum.IsSelected = true;
+            };
+
+            btnAlbum.MouseUpEventHandler = (sender, e) =>
+            {
+                btnAlbum.IsSelected = false;
+                //浠庣浉鍐岄�夋嫨鍥剧墖瑁佸壀
+                var imageName = Guid.NewGuid().ToString();
+                //var imageName = scene.sid;
+                CropImage.SelectPicture((imagePath) =>
+                {
+                    CropImageCallBack(imagePath,2,imageName);
+                }, imageName, 4, 6,1000);
+
+                pictureOptionView.Parent.RemoveFromParent();
+            };
 
         }
+
+
+
+
+        /// <summary>
+        /// 瑁佸壀瀹岀収鐗囧洖璋冿紝缁熶竴澶勭悊
+        /// </summary>
+        /// <param name="imagePath">瑁佸壀鍚庣殑鐪熷疄璺緞</param>
+        /// <param name="imageSource">鐓х墖鏉ユ簮锛�1锛氭媿鐓э紱2锛氬浘搴�</param>
+        void CropImageCallBack(string selectImagePath,int imageSource,string imageName)
+        {
+            if (string.IsNullOrEmpty(selectImagePath) == true)
+            {
+                return;
+            }
+            //涓婁紶鎴愬姛鍒板洖璋�
+            Action<bool> uploadSuccessAction = (isSuccess) =>
+            {
+                Action action = () => {
+                    if (!isSuccess)
+                    {
+                        if (imageSource == 1)
+                        {
+                            CropImage.TakePicture((imagePath) =>
+                            {
+                                CropImageCallBack(imagePath, 2, imageName);
+                            }, imageName, 4, 6);
+                        }
+                        else
+                        {
+                            CropImage.SelectPicture((imagePath) =>
+                            {
+                                CropImageCallBack(imagePath, 1,imageName);
+                            }, imageName, 4, 6);
+                        }
+                    }else
+                    {
+                        ReadFaceInfo();
+                    }
+                };
+                Application.RunOnMainThread(() =>
+                {
+                    var page = new FaceSettingResultPage(action);
+                    MainPage.BasePageView.AddChidren(page);
+                    page.LoadPage(isSuccess);
+                    MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+                });
+            };
+            //涓婁紶鍥剧墖鍒颁簯绔�
+            UploadImage(selectImagePath, uploadSuccessAction);
+        }
+
+        /// <summary>
+        /// 涓婁紶鍥剧墖鏂规硶
+        /// </summary>
+        /// <param name="selectImagePath">瑁佸壀鍚庣殑鍥剧墖璺緞</param>
+        /// <param name="imageView"></param>
+        /// <param name="uploadResultAction"></param>
+        void UploadImage(string selectImagePath, Action<bool> uploadResultAction)
+        {
+            try
+            {
+                //1.璇诲彇瑁佸壀鍚庣殑鍥剧墖锛岀劧鍚庡垹闄�
+                var imageBytes = Shared.IO.FileUtils.ReadFile(selectImagePath);
+                System.IO.File.Delete(selectImagePath);
+
+                var waitPage = new Loading();
+                bodyView.AddChidren(waitPage);
+                waitPage.Start(Language.StringByID(StringId.PleaseWait));
+                //寮�濮嬩笂浼�
+                new Thread(() =>
+                {
+                    try
+                    {
+                        string base64string = Convert.ToBase64String(imageBytes);
+                        var pack = new HttpServerRequest().FaceSetting(base64string);
+                        if (pack != null)
+                        {
+                            uploadResultAction?.Invoke(pack.Code == StateCode.SUCCESS);
+                        }
+
+                    }
+                    catch (Exception ex)
+                    {
+                    }
+                    finally
+                    {
+                        Application.RunOnMainThread(() =>
+                        {
+                            if (waitPage != null)
+                            {
+                                waitPage.RemoveFromParent();
+                                waitPage = null;
+                            }
+                        });
+                    }
+                })
+                { IsBackground = true }.Start();
+            }
+            catch { }
+        }
+
+
     }
+
 }

--
Gitblit v1.8.0