From d21ef6135c295e9bfa5ac7c0858ef55f5627479c Mon Sep 17 00:00:00 2001
From: Tong <1025782220@qq.com>
Date: 星期二, 31 八月 2021 10:04:05 +0800
Subject: [PATCH] 修改全局秘钥
---
HDL_ON/UI/UI2/4-PersonalCenter/FaceManagement/FacePassagePage.cs | 467 +++++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 441 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..2d86ddd 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,10 +60,10 @@
bodyView.BackgroundColor = CSS_Color.BackgroundColor;
- var contentView = new FrameLayout()
+ contentView = new FrameLayout()
{
Y = Application.GetRealHeight(64),
- Height = Application.GetRealHeight(667-64),
+ Height = Application.GetRealHeight(667 - 64),
};
bodyView.AddChidren(contentView);
@@ -59,7 +96,7 @@
};
topView.AddChidren(btnText1);
- topView.AddChidren(new Button() { Height = 1,BackgroundColor = CSS_Color.DividingLineColor,Y = Application.GetRealHeight(188) ,X = Application.GetRealWidth(16),Width = Application.GetRealWidth(359)});
+ topView.AddChidren(new Button() { Height = 1, BackgroundColor = CSS_Color.DividingLineColor, Y = Application.GetRealHeight(188), X = Application.GetRealWidth(16), Width = Application.GetRealWidth(359) });
#region 绀惧尯闂ㄧ閫氳
var communityRow = new FrameLayout()
@@ -82,7 +119,7 @@
communityRow.AddChidren(btnCommunityTitle);
- var btnCommunityAccessControlIcon = new Button()
+ btnCommunityAccessControlIcon = new Button()
{
X = Application.GetRealWidth(314),
Gravity = Gravity.CenterVertical,
@@ -93,7 +130,22 @@
};
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 = () =>
+ {
+ initButtonStatus();
+ };
+ editFaceInfo(switchStatus, action);
+ };
#endregion
@@ -110,7 +162,7 @@
contentView.AddChidren(btnTip);
- var btnSetFaceId = new Button()
+ btnSetFaceId = new Button()
{
Y = Application.GetRealHeight(539),
Gravity = Gravity.CenterHorizontal,
@@ -125,32 +177,395 @@
IsBold = true,
};
contentView.AddChidren(btnSetFaceId);
-
- if (string.IsNullOrEmpty(faceid))
+ btnSetFaceId.MouseUpEventHandler = (sender, e) =>
{
- }
- else
- {
- btnSetFaceId.TextID = StringId.ResetFace;
+ LoadPictureOptionView();
+ };
- var btnEraseData = new Button()
+ 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,
+ };
+ btnEraseData.MouseUpEventHandler = (sender, e) =>
+ {
+ Action action = () =>
{
- 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,
+ initButtonStatus();
};
- contentView.AddChidren(btnEraseData);
+ editFaceInfo(3, action);
+ };
+
+ ReadFaceInfo();
+ }
+
+ /// <summary>
+ /// 鑾峰彇浜鸿劯淇℃伅
+ /// </summary>
+ void ReadFaceInfo(bool isLoading = true)
+ {
+ Loading waitPage = null;
+ if (isLoading)
+ {
+ 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, 400);
+
+ 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, 400);//OutputYSize鐩墠浠呭Android鏈変簺 400浠h〃Y鐨勬渶澶氬垎杈ㄧ巼锛屾墍浠ユ渶缁堝緱鍒板浘鐗囩殑鍒嗚鲸鐜囦负锛�266*400
+
+ 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, 400);
+ }
+ else
+ {
+ CropImage.SelectPicture((imagePath) =>
+ {
+ CropImageCallBack(imagePath, 1, imageName);
+ }, imageName, 4, 6, 400);
+ }
+ }
+ };
+
+ if (isSuccess)
+ {
+ ReadFaceInfo(false);
+ }
+
+ 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)
+ {
+ Utlis.WriteLine("涓婁紶缁撴灉锛�" + pack.message);
+ 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