From 351bdda734832d821a9764b0cde8be5d83c4ec50 Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期四, 01 十二月 2022 09:56:25 +0800
Subject: [PATCH] 2022年12月01日09:56:23

---
 ZigbeeApp/Shared/Phone/UserCenter/Member/MemberListForm.cs |  393 ++++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 269 insertions(+), 124 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Member/MemberListForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Member/MemberListForm.cs
index 31e639d..3075b58 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Member/MemberListForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Member/MemberListForm.cs
@@ -7,18 +7,22 @@
     /// <summary>
     /// 鎴愬憳绠$悊鈽�
     /// </summary>
-    public class MemberListForm : UserCenterCommonForm
+    public class MemberListForm : EditorCommonForm
     {
         #region 鈻� 鍙橀噺澹版槑___________________________
 
         /// <summary>
         /// 鍒楄〃鎺т欢
         /// </summary>
-        private VerticalScrolViewLayout listView = null;
+        private VerticalListControl listView = null;
         /// <summary>
-        /// TopFrameLayout
+        /// 鎴愬憳澶村儚鎺т欢
         /// </summary>
-        private SpecialFrameLayout specialTopFrame = null;
+        private Dictionary<string, ImageView> dicIconControl = new Dictionary<string, ImageView>();
+        /// <summary>
+        /// 鎴愬憳鐨勮处鍙�(鑾峰彇澶村儚鐢�)
+        /// </summary>
+        private Dictionary<string, string> dicMemberAccount = new Dictionary<string, string>();
 
         #endregion
 
@@ -32,29 +36,39 @@
             //璁剧疆鏍囬淇℃伅
             base.SetTitleText(Language.StringByID(R.MyInternationalizationString.MenberManagement));
 
-            //涓轰簡鑳藉鏄剧ず妯″潡鍥炬牱
-            bodyFrameLayout.BackgroundColor = UserCenterColor.Current.TopFrameLayout;
-
-            var titleIcon = new TopLayoutMostRightView();
+            var titleIcon = new MostRightIconControl(69, 69);
             titleIcon.UnSelectedImagePath = "Item/Add.png";
-            titleIcon.SelectedImagePath = "Item/AddSelected.png";
             topFrameLayout.AddChidren(titleIcon);
-            titleIcon.MouseUpEventHandler += (sender, e) =>
+            titleIcon.InitControl();
+            titleIcon.ButtonClickEvent += (sender, e) =>
             {
-                var menuContr = new TopRightMenuControl(this, 2);
+                var menuContr = new TopRightMenuControl(2, 2);
                 //鎵弿浜岀淮鐮�
                 string msg1 = Language.StringByID(R.MyInternationalizationString.uScanQRcode);
-                menuContr.AddRowMenu(msg1, (obj) =>
+                menuContr.AddRowMenu(msg1, "Item/ScanQRcodeIcon.png", "Item/ScanQRcodeIconSelected.png", () =>
                 {
-                    var form = new AddMemberByIdForm();
-                    form.AddForm(form);
+                    QRCode.ScanQRcode((qrCode) =>
+                    {
+                        if (string.IsNullOrEmpty(qrCode) == true)
+                        {
+                            return;
+                        }
+                        //鎼滅储ID
+                        HdlThreadLogic.Current.RunThread(() =>
+                        {
+                            this.SearchMemberInfo(qrCode);
+                        });
+                    }, 
+                    Language.StringByID(R.MyInternationalizationString.uCancel),
+                    Language.StringByID(R.MyInternationalizationString.uFlashlamp),
+                    msg1);
                 });
                 //杈撳叆璐﹀彿
                 string msg2 = Language.StringByID(R.MyInternationalizationString.uInputAccount);
-                menuContr.AddRowMenu(msg2, (obj) =>
+                menuContr.AddRowMenu(msg2, "Item/InputAccountIcon.png", "Item/InputAccountIconSelected.png", () =>
                 {
                     var form = new AddMemberByIdForm();
-                    form.AddForm(form);
+                    form.AddForm();
                 });
             };
 
@@ -68,14 +82,14 @@
         /// </summary>
         private void InitMiddleFrame()
         {
+            //娓呯┖bodyFrame
+            this.ClearBodyFrame();
+
             //鍒濆鍖栫敤鎴峰浘鏍�
             this.InitUserIconControl();
 
             //鍒濆鍖栧垪琛ㄦ帶浠�
             this.InitMemberListControl();
-
-            //鎬讳箣鍏堟竻绌哄叡浜枃浠跺す鍑嗘病閿�
-            HdlShardLogic.Current.ClearShardDirectory();
         }
 
         #endregion
@@ -87,33 +101,37 @@
         /// </summary>
         private void InitUserIconControl()
         {
-            this.specialTopFrame = new SpecialFrameLayout(400, 10);
-            specialTopFrame.BackgroundColor = UserCenterColor.Current.BodyFrameLayout;
-            bodyFrameLayout.AddChidren(specialTopFrame);
+            var frameBack = new FrameLayout();
+            frameBack.BackgroundColor = UserCenterColor.Current.White;
+            frameBack.Height = Application.GetRealHeight(438);
+            bodyFrameLayout.AddChidren(frameBack);
 
             //鐢ㄦ埛鍥炬爣
-            var btnUserIcon = new ProfilePhotoControl();
-            btnUserIcon.Y = Application.GetRealHeight(40);
+            var btnUserIcon = new ImageView();
+            btnUserIcon.Height = this.GetPictrueRealSize(207);
+            btnUserIcon.Width = this.GetPictrueRealSize(207);
+            btnUserIcon.Radius = (uint)this.GetPictrueRealSize(207) / 2;
+            btnUserIcon.ImagePath = UserCenterResourse.UserInfo.UserIconFile;
+            btnUserIcon.Y = Application.GetRealHeight(46);
             btnUserIcon.Gravity = Gravity.CenterHorizontal;
-            btnUserIcon.UnSelectedImagePath = "Account/Admin.png";
-            specialTopFrame.AddChidren(btnUserIcon);
-
-            //韬唤
-            var btnAuthority = new ViewNormalControl(specialTopFrame.Width);
-            btnAuthority.TextAlignment = TextAlignment.Center;
-            btnAuthority.Y = btnUserIcon.Bottom + Application.GetRealHeight(10);
-            btnAuthority.TextColor = UserCenterColor.Current.TextGrayColor;
-            btnAuthority.Gravity = Gravity.CenterHorizontal;
-            btnAuthority.Text = UserCenterResourse.UserInfo.AuthorityText;
-            specialTopFrame.AddChidren(btnAuthority);
+            frameBack.AddChidren(btnUserIcon);
 
             //鏄电О
-            var btnName = new ViewNormalControl(800, true);
+            var btnName = new NormalViewControl(frameBack.Width, Application.GetRealHeight(60), false);
             btnName.TextAlignment = TextAlignment.Center;
-            btnName.Y = btnAuthority.Bottom + Application.GetRealHeight(10);
-            btnName.Gravity = Gravity.CenterHorizontal;
+            btnName.Y = btnUserIcon.Bottom + Application.GetRealHeight(20);
+            btnName.TextSize = 16;
             btnName.Text = UserCenterResourse.UserInfo.UserName; ;
-            specialTopFrame.AddChidren(btnName, HeightAutoMode.IncreaseOnly);
+            frameBack.AddChidren(btnName);
+
+            //韬唤
+            var btnAuthority = new NormalViewControl(frameBack.Width, Application.GetRealHeight(55), false);
+            btnAuthority.TextAlignment = TextAlignment.Center;
+            btnAuthority.Y = btnName.Bottom + Application.GetRealHeight(10);
+            btnAuthority.TextSize = 12;
+            btnAuthority.TextColor = UserCenterColor.Current.TextGrayColor1;
+            btnAuthority.Text = UserCenterResourse.UserInfo.AuthorityText;
+            frameBack.AddChidren(btnAuthority);
         }
 
         #endregion
@@ -125,45 +143,48 @@
         /// </summary>
         private void InitMemberListControl()
         {
-            //鍒涘缓涓�涓狥rameLayout
-            var frameLayout = new FrameLayout();
-            frameLayout.Height = bodyFrameLayout.Height - specialTopFrame.Height - Application.GetRealHeight(50);
-            frameLayout.BackgroundColor = UserCenterColor.Current.BodyFrameLayout;
-            frameLayout.Y = this.specialTopFrame.Bottom + Application.GetRealHeight(50);
-            bodyFrameLayout.AddChidren(frameLayout);
-
             //鏍囬:鎴愬憳鍒楄〃
-            var btnMenberTile = new ViewNormalControl(800, true);
+            var btnMenberTile = new NormalViewControl(800, 60, true);
             btnMenberTile.X = ControlCommonResourse.XXLeft;
-            btnMenberTile.Y = Application.GetRealHeight(20);
+            btnMenberTile.Y = Application.GetRealHeight(480);
+            btnMenberTile.TextColor = UserCenterColor.Current.TextColor1;
             btnMenberTile.TextID = R.MyInternationalizationString.MenberList;
-            frameLayout.AddChidren(btnMenberTile);
+            btnMenberTile.TextSize = 15;
+            bodyFrameLayout.AddChidren(btnMenberTile);
+
+            var frameBack = new FrameLayout();
+            frameBack.Y = btnMenberTile.Bottom + Application.GetRealHeight(23);
+            frameBack.Height = Application.GetRealHeight(11);
+            frameBack.BackgroundColor = UserCenterColor.Current.White;
+            bodyFrameLayout.AddChidren(frameBack);
 
             //娣诲姞鍙互鍚戜笅婊氬姩鐨勬帶浠�
-            listView = new VerticalScrolViewLayout();
-            listView.Y = btnMenberTile.Bottom + Application.GetRealHeight(20);
-            listView.Height = frameLayout.Height - btnMenberTile.Bottom - Application.GetRealHeight(20);
-            frameLayout.AddChidren(listView);
+            listView = new VerticalListControl(12);
+            listView.Height = bodyFrameLayout.Height - frameBack.Bottom;
+            listView.BackgroundColor = UserCenterColor.Current.White;
+            listView.Y = frameBack.Bottom;
+            bodyFrameLayout.AddChidren(listView);
 
-            new System.Threading.Thread(() =>
+            HdlThreadLogic.Current.RunThread(() =>
             {
+                //鎬讳箣鍏堟竻绌哄叡浜枃浠跺す鍑嗘病閿�
+                HdlShardLogic.Current.ClearShardDirectory();
                 //鍒濆鍖栨垚鍛樺垪琛�
                 this.InitMemberList();
-            })
-            { IsBackground = true }.Start();
+            });
         }
 
         /// <summary>
         /// 鍒濆鍖栨垚鍛樺垪琛�
         /// </summary>
-        private async void InitMemberList()
+        private void InitMemberList()
         {
             //寮�鍚繘搴︽潯
             this.ShowProgressBar();
 
             var pra = new MemberListInfoPra();
-            string result = await UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeUsers/GetSubAccountByDistributedMark", pra);
-            if (result == null)
+            string result = UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeUsers/GetSubAccountByDistributedMark", false, pra);
+            if (string.IsNullOrEmpty(result) == true)
             {
                 //鍏抽棴杩涘害鏉�
                 this.CloseProgressBar(ShowReLoadMode.YES);
@@ -181,27 +202,63 @@
             {
                 //鍏抽棴杩涘害鏉�
                 this.CloseProgressBar(ShowReLoadMode.YES);
+                return;
             }
+            //鍏抽棴杩涘害鏉�
+            this.CloseProgressBar();
 
             List<string> listCheck = new List<string>();
+            List<MemberInfoRes> listShowInfo = new List<MemberInfoRes>();
             foreach (MemberInfoRes infoRes in listInfo)
             {
                 if (listCheck.Contains(infoRes.DistributedMark) == true
                     || infoRes.Account == UserCenterResourse.UserInfo.Phone
                     || infoRes.Account == UserCenterResourse.UserInfo.Email)
                 {
+                    //濡傛灉鏄畠鑷繁鐨勮瘽锛屼笉鏄剧ず
                     continue;
                 }
-                listCheck.Add(infoRes.DistributedMark);
-
-                Application.RunOnMainThread(() =>
+                if (UserCenterResourse.UserInfo.AuthorityNo != 1 && infoRes.AccountType != 0)
                 {
-                    //娣诲姞鎴愬憳琛�
-                    this.AddRowLayout(infoRes);
-                });
+                    //涓嶈兘澶熻幏鍙栨潈闄愮瓑绾ф瘮浠栭珮鐨�(涓讳汉鑷繁鍙互鏃犺杩欎釜鍒ゆ柇)
+                    continue;
+                }
+
+                listCheck.Add(infoRes.DistributedMark);
+                //娣诲姞鎴愬憳淇℃伅鐨勭紦瀛�
+                listShowInfo.Add(infoRes);
             }
-            //鍏抽棴杩涘害鏉�
-            this.CloseProgressBar();
+            if (listShowInfo.Count == 0)
+            {
+                return;
+            }
+            HdlThreadLogic.Current.RunMain(() =>
+            {
+                //娣诲姞鎴愬憳鍒楄〃
+                this.AddMemberListRowByData(listShowInfo);
+            });
+        }
+
+        /// <summary>
+        /// 娣诲姞鎴愬憳鍒楄〃
+        /// </summary>
+        private void AddMemberListRowByData(List<MemberInfoRes> listNewInfo)
+        {
+            if (this.Parent == null)
+            {
+                return;
+            }
+
+            int count = listNewInfo.Count - 1;
+            for (int i = 0; i < listNewInfo.Count; i++)
+            {
+                //娣诲姞鎴愬憳琛�
+                this.AddRowLayout(listNewInfo[i], i != count);
+            }
+            //璋冩暣鍒楄〃鎺т欢鐨勯珮搴�
+            listView.AdjustRealHeight(Application.GetRealHeight(23));
+            //鑾峰彇鎴愬憳澶村儚
+            this.GetMemberIcon();
         }
 
         #endregion
@@ -212,52 +269,118 @@
         /// 娣诲姞鎴愬憳琛�
         /// </summary>
         /// <param name="info">Info.</param>
-        private void AddRowLayout(MemberInfoRes info)
+        ///  <param name="addLine">addLine</param>
+        private void AddRowLayout(MemberInfoRes info, bool addLine)
         {
-            var rowlayout = new MemberRow();
-            rowlayout.AccountId = info.Account;
+            var rowlayout = new FrameRowControl(listView.rowSpace / 2);
+            rowlayout.Height = Application.GetRealHeight(138);
+            rowlayout.MainKeys = info.Account;
             listView.AddChidren(rowlayout);
 
             //鎴愬憳澶村儚鍥炬爣
-            var btnIcon = new IconViewControl();
-            btnIcon.Radius = (uint)btnIcon.IconSize / 2;
+            string iconPath = System.IO.Path.Combine(UserCenterResourse.AccountOption.UserPictruePath, info.DistributedMark + ".png");
+            var btnIcon = new ImageView();
             btnIcon.X = ControlCommonResourse.XXLeft;
             btnIcon.Gravity = Gravity.CenterVertical;
-            btnIcon.UnSelectedImagePath = "Account/ProfilePhotoMember.png";
-            btnIcon.SelectedImagePath = "Account/ProfilePhotoMemberSelected.png";
-            rowlayout.AddChidren(btnIcon);
-
-            //鎴愬憳鏄电О
-            var btnName = new RowCenterView();
-            btnName.Text = info.UserName;
-            if (string.IsNullOrEmpty(info.UserName) == true)
+            btnIcon.Height = this.GetPictrueRealSize(115);
+            btnIcon.Width = this.GetPictrueRealSize(115);
+            btnIcon.Radius = (uint)this.GetPictrueRealSize(115) / 2;
+            if (System.IO.File.Exists(iconPath) == true)
             {
-                btnName.Text = info.Account;
-            }
-            rowlayout.AddChidren(btnName);
-
-            //鏉冮檺
-            var btnAuthority = new RowSecondRightTextView();
-            btnAuthority.TextColor = UserCenterColor.Current.TextGrayColor;
-            if (info.AccountType == 1)
-            {
-                //绠$悊鍛�
-                btnAuthority.TextID = R.MyInternationalizationString.Administrator;
+                btnIcon.ImagePath = iconPath;
             }
             else
             {
-                //鎴愬憳
-                btnAuthority.TextID = R.MyInternationalizationString.uMember;
+                btnIcon.ImagePath = "Center/Admin.png";
+                this.dicIconControl[info.DistributedMark] = btnIcon;
+                this.dicMemberAccount[info.DistributedMark] = info.Account;
             }
-            rowlayout.AddChidren(btnAuthority);
+            rowlayout.AddChidren(btnIcon);
 
+            //鎴愬憳鏄电О
+            string memberName = string.IsNullOrEmpty(info.UserName) == true ? info.Account : info.UserName;
+            var btnName = rowlayout.AddLeftCaption(memberName, 600, true);
+            btnName.X = ControlCommonResourse.XXLeft + btnIcon.Height + Application.GetRealWidth(35);
+            btnName.TextSize = 15;
+            rowlayout.AddChidren(btnName);
+
+            if (addLine == true)
+            {
+                //搴曠嚎
+                rowlayout.AddBottomLine();
+            }
             //鍙冲浘鏍�
-            rowlayout.AddRightIconControl();
-            rowlayout.MouseUpEvent += (sender, e) =>
+            rowlayout.AddRightArrow();
+            rowlayout.ButtonClickEvent += (sender, e) =>
             {
                 var form = new MemberManagementForm();
-                this.AddForm(form, info);
+                form.AddForm(info);
             };
+        }
+
+        /// <summary>
+        /// 娣诲姞鎴愬憳琛�(澶栭儴璋冪敤)
+        /// </summary>
+        /// <param name="info"></param>
+        public void AddRowLayoutByOtherForm(MemberInfoRes info)
+        {
+            var myRow = listView.GetChildren(listView.ChildrenCount - 1);
+            if (myRow != null)
+            {
+                //鏈�鍚庝竴琛屽姞搴曠嚎
+                ((FrameRowControl)myRow).AddBottomLine();
+            }
+            this.AddRowLayout(info, false);
+            //璋冩暣鍒楄〃鎺т欢鐨勯珮搴�
+            listView.AdjustRealHeight(Application.GetRealHeight(23));
+        }
+
+        #endregion
+
+        #region 鈻� 鑾峰彇鎴愬憳澶村儚_______________________
+
+        /// <summary>
+        /// 鑾峰彇鎴愬憳澶村儚
+        /// </summary>
+        private void GetMemberIcon()
+        {
+            if (dicIconControl.Count == 0)
+            {
+                return;
+            }
+            HdlThreadLogic.Current.RunThread(() =>
+            {
+                var pra = new AccountInfoPra();
+                foreach (var keys in dicMemberAccount.Keys)
+                {
+                    if (this.Parent == null)
+                    {
+                        return;
+                    }
+                    pra.Account = dicMemberAccount[keys];
+                    var result = UserCenterLogic.GetByteResponseDataByRequestHttps("ZigbeeUsers/GetSubAccountInfo", false, pra, new List<string> { "NotCheck" }, false);
+                    if (result == null)
+                    {
+                        continue;
+                    }
+                    var revertObj = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.ResponseEntity.ResponsePack>(System.Text.Encoding.UTF8.GetString(result));
+                    if (revertObj == null || revertObj.ResponseData == null)
+                    {
+                        continue;
+                    }
+                    var infoResult = Newtonsoft.Json.JsonConvert.DeserializeObject<AccountInfoResult>(revertObj.ResponseData.ToString());
+                    if (infoResult.HeadImage != null)
+                    {
+                        //鍐欏叆澶村儚鍐呭
+                        string iconPath = System.IO.Path.Combine(UserCenterResourse.AccountOption.UserPictruePath, keys + ".png");
+                        Shared.IO.FileUtils.WriteFileByBytes(iconPath, infoResult.HeadImage);
+                        HdlThreadLogic.Current.RunMain(() =>
+                        {
+                            dicIconControl[keys].ImageBytes = Shared.IO.FileUtils.ReadFile(iconPath);
+                        });
+                    }
+                }
+            });
         }
 
         #endregion
@@ -265,24 +388,68 @@
         #region 鈻� 鍒犻櫎鎸囧畾琛宊________________________
 
         /// <summary>
-        /// 鍒犻櫎鎸囧畾琛�
+        /// 鍒犻櫎鎸囧畾琛�(澶栭儴璋冪敤)
         /// </summary>
         /// <param name="accountId"></param>
         public void DeleteRowByAccount(string accountId)
         {
             for (int i = 0; ; i++)
             {
-                var row = (MemberRow)listView.GetChildren(i);
+                var row = (FrameRowControl)listView.GetChildren(i);
                 if (row == null)
                 {
                     break;
                 }
-                if (row.AccountId == accountId)
+                if (row.MainKeys == accountId)
                 {
                     row.RemoveFromParent();
+                    //璋冩暣鍒楄〃鎺т欢鐨勯珮搴�
+                    listView.AdjustRealHeight(Application.GetRealHeight(23));
+
                     break;
                 }
             }
+        }
+
+        #endregion
+
+        #region 鈻� 鎼滅储ID_____________________________
+
+        /// <summary>
+        /// 鎼滅储鎸囧畾ID鐨勪俊鎭�
+        /// </summary>
+        /// <param name="accountId">鎴愬憳ID</param>
+        /// <param name="txtMsg">淇℃伅鎺т欢</param>
+        private void SearchMemberInfo(string accountId)
+        {
+            var pra = new AccountInfoPra();
+            pra.Account = accountId;
+            var byteData = UserCenterLogic.GetByteResponseDataByRequestHttps("ZigbeeUsers/GetSubAccountInfo", false, pra, new List<string>() { "AccountNoExists" });
+            if (byteData == null)
+            {
+                //寮傚父
+                return;
+            }
+            var revertObj = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.ResponseEntity.ResponsePack>(System.Text.Encoding.UTF8.GetString(byteData));
+            if (revertObj.StateCode == "AccountNoExists")
+            {
+                HdlThreadLogic.Current.RunMain(() =>
+                {
+                    //鎴愬憳涓嶅瓨鍦�
+                    var form = new MemberNotEsixtForm();
+                    form.AddForm(Language.StringByID(R.MyInternationalizationString.uMemberInformation));
+                });
+                return;
+            }
+
+            var infoResult = Newtonsoft.Json.JsonConvert.DeserializeObject<AccountInfoResult>(revertObj.ResponseData.ToString());
+            infoResult.Account = accountId;
+
+            HdlThreadLogic.Current.RunMain(() =>
+            {
+                var form = new AddMemberInfoForm();
+                form.AddForm(infoResult);
+            });
         }
 
         #endregion
@@ -292,34 +459,12 @@
         /// <summary>
         /// 鑷韩鐨勪笂灞傜晫闈㈠叧闂悗,瀹冭嚜韬浜庢渶涓婂眰鏃�,瑙﹀彂鐨勪簨浠�
         /// </summary>
-        public override void FormActionAgainEvent()
+        public override int FormActionAgainEvent()
         {
             //娓呯┖鍏变韩鏂囦欢澶�
             HdlShardLogic.Current.ClearShardDirectory();
 
-            this.listView.RemoveAll();
-
-            new System.Threading.Thread(() =>
-            {
-                //鍒濆鍖栨垚鍛樺垪琛�
-                this.InitMemberList();
-            })
-            { IsBackground = true }.Start();
-        }
-
-        #endregion
-
-        #region 鈻� 缁撴瀯浣揰____________________________
-
-        /// <summary>
-        /// 鑷畾涔夋帶浠�
-        /// </summary>
-        private class MemberRow : StatuRowLayout
-        {
-            /// <summary>
-            /// 璐﹀彿ID
-            /// </summary>
-            public string AccountId = string.Empty;
+            return 1;
         }
 
         #endregion

--
Gitblit v1.8.0