From 66a9965c44ecc32a6696abca876ab9d1cd091584 Mon Sep 17 00:00:00 2001
From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local>
Date: 星期五, 28 二月 2020 15:25:13 +0800
Subject: [PATCH] 2020.2.28

---
 ZigbeeApp/Shared/Phone/UserCenter/Member/MemberListForm.cs |  161 ++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 145 insertions(+), 16 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Member/MemberListForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Member/MemberListForm.cs
index c013c61..bf52d7e 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Member/MemberListForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Member/MemberListForm.cs
@@ -15,6 +15,14 @@
         /// 鍒楄〃鎺т欢
         /// </summary>
         private VerticalListControl listView = null;
+        /// <summary>
+        /// 鎴愬憳澶村儚鎺т欢
+        /// </summary>
+        private Dictionary<string, ImageView> dicIconControl = new Dictionary<string, ImageView>();
+        /// <summary>
+        /// 鎴愬憳鐨勮处鍙�(鑾峰彇澶村儚鐢�)
+        /// </summary>
+        private Dictionary<string, string> dicMemberAccount = new Dictionary<string, string>();
 
         #endregion
 
@@ -34,13 +42,23 @@
             titleIcon.InitControl();
             titleIcon.ButtonClickEvent += (sender, e) =>
             {
-                var menuContr = new TopRightMenuControl(this, 2, 449);
+                var menuContr = new TopRightMenuControl(2, 2);
                 //鎵弿浜岀淮鐮�
                 string msg1 = Language.StringByID(R.MyInternationalizationString.uScanQRcode);
                 menuContr.AddRowMenu(msg1, "Item/ScanQRcodeIcon.png", "Item/ScanQRcodeIconSelected.png", () =>
                 {
-                    var form = new AddMemberByIdForm();
-                    form.AddForm();
+                    QRCode.ScanQRcode((qrCode) =>
+                    {
+                        if (string.IsNullOrEmpty(qrCode) == true)
+                        {
+                            return;
+                        }
+                        //鎼滅储ID
+                        this.SearchMemberInfo(qrCode);
+                    }, 
+                    Language.StringByID(R.MyInternationalizationString.uCancel),
+                    Language.StringByID(R.MyInternationalizationString.uFlashlamp),
+                    msg1);
                 });
                 //杈撳叆璐﹀彿
                 string msg2 = Language.StringByID(R.MyInternationalizationString.uInputAccount);
@@ -86,11 +104,13 @@
             bodyFrameLayout.AddChidren(frameBack);
 
             //鐢ㄦ埛鍥炬爣
-            var btnUserIcon = new PicViewControl(207, 207);
-            btnUserIcon.Y = Application.GetRealHeight(46);
+            var btnUserIcon = new ImageView();
+            btnUserIcon.Height = Application.GetMinRealAverage(207);
+            btnUserIcon.Width = Application.GetMinRealAverage(207);
             btnUserIcon.Radius = (uint)Application.GetMinRealAverage(207) / 2;
+            btnUserIcon.ImagePath = UserCenterResourse.UserInfo.UserIconFile;
+            btnUserIcon.Y = Application.GetRealHeight(46);
             btnUserIcon.Gravity = Gravity.CenterHorizontal;
-            btnUserIcon.UnSelectedImagePath = "Center/Admin.png";
             frameBack.AddChidren(btnUserIcon);
 
             //鏄电О
@@ -142,7 +162,7 @@
             listView.Y = frameBack.Bottom;
             bodyFrameLayout.AddChidren(listView);
 
-            HdlThreadLogic.Current.RunMainInThread(() =>
+            HdlThreadLogic.Current.RunThread(() =>
             {
                 //鎬讳箣鍏堟竻绌哄叡浜枃浠跺す鍑嗘病閿�
                 HdlShardLogic.Current.ClearShardDirectory();
@@ -192,12 +212,17 @@
             {
                 if (listCheck.Contains(infoRes.DistributedMark) == true
                     || infoRes.Account == UserCenterResourse.UserInfo.Phone
-                    || infoRes.Account == UserCenterResourse.UserInfo.Email
-                    || infoRes.AccountType != 0)
+                    || infoRes.Account == UserCenterResourse.UserInfo.Email)
                 {
-                    //濡傛灉鏄畠鑷繁鐨勮瘽,鎴栬�呮潈闄愮瓑绾ф瘮浠栭珮鐨勶紝涓嶆樉绀�
+                    //濡傛灉鏄畠鑷繁鐨勮瘽锛屼笉鏄剧ず
                     continue;
                 }
+                if (UserCenterResourse.UserInfo.AuthorityNo != 1 && infoRes.AccountType != 0)
+                {
+                    //涓嶈兘澶熻幏鍙栨潈闄愮瓑绾ф瘮浠栭珮鐨�(涓讳汉鑷繁鍙互鏃犺杩欎釜鍒ゆ柇)
+                    continue;
+                }
+
                 listCheck.Add(infoRes.DistributedMark);
                 //娣诲姞鎴愬憳淇℃伅鐨勭紦瀛�
                 UserCenterResourse.ListMemberInfo.Add(infoRes);
@@ -209,9 +234,11 @@
             {
                 return;
             }
-
-            //娣诲姞鎴愬憳鍒楄〃
-            this.AddMemberListRowByData();
+            HdlThreadLogic.Current.RunMain(() =>
+            {
+                //娣诲姞鎴愬憳鍒楄〃
+                this.AddMemberListRowByData();
+            });
         }
 
         /// <summary>
@@ -233,6 +260,8 @@
             }
             //璋冩暣鍒楄〃鎺т欢鐨勯珮搴�
             listView.AdjustRealHeight(Application.GetRealHeight(23));
+            //鑾峰彇鎴愬憳澶村儚
+            this.GetMemberIcon();
         }
 
         #endregion
@@ -252,14 +281,29 @@
             listView.AddChidren(rowlayout);
 
             //鎴愬憳澶村儚鍥炬爣
-            var btnIcon = rowlayout.AddLeftIcon(115);
-            btnIcon.Radius = (uint)btnIcon.IconSize / 2;
-            btnIcon.UnSelectedImagePath = "Center/Admin.png";
+            string iconPath = System.IO.Path.Combine(UserCenterResourse.Option.UserPictruePath, info.DistributedMark + ".png");
+            var btnIcon = new ImageView();
+            btnIcon.X = ControlCommonResourse.XXLeft;
+            btnIcon.Gravity = Gravity.CenterVertical;
+            btnIcon.Height = Application.GetMinRealAverage(115);
+            btnIcon.Width = Application.GetMinRealAverage(115);
+            btnIcon.Radius = (uint)Application.GetMinRealAverage(115) / 2;
+            if (System.IO.File.Exists(iconPath) == true)
+            {
+                btnIcon.ImagePath = iconPath;
+            }
+            else
+            {
+                btnIcon.ImagePath = "Center/Admin.png";
+                this.dicIconControl[info.DistributedMark] = btnIcon;
+                this.dicMemberAccount[info.DistributedMark] = info.Account;
+            }
             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);
 
@@ -275,6 +319,54 @@
                 var form = new MemberManagementForm();
                 form.AddForm(info);
             };
+        }
+
+        #endregion
+
+        #region 鈻� 鑾峰彇鎴愬憳澶村儚_______________________
+
+        /// <summary>
+        /// 鑾峰彇鎴愬憳澶村儚
+        /// </summary>
+        private void GetMemberIcon()
+        {
+            if (dicIconControl.Count == 0)
+            {
+                return;
+            }
+            HdlThreadLogic.Current.RunThread(async () =>
+            {
+                var pra = new AccountInfoPra();
+                foreach (var keys in dicMemberAccount.Keys)
+                {
+                    if (this.Parent == null)
+                    {
+                        return;
+                    }
+                    pra.Account = dicMemberAccount[keys];
+                    var result = await UserCenterLogic.GetByteResponseDataByRequestHttps("ZigbeeUsers/GetSubAccountInfo", false, pra, new List<string>() { "NotSetAgain" });
+                    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.Option.UserPictruePath, keys + ".png");
+                        Shared.IO.FileUtils.WriteFileByBytes(iconPath, infoResult.HeadImage);
+                        HdlThreadLogic.Current.RunMain(() =>
+                        {
+                            dicIconControl[keys].ImageBytes = Shared.IO.FileUtils.ReadFile(iconPath);
+                        });
+                    }
+                }
+            });
         }
 
         #endregion
@@ -304,6 +396,43 @@
 
         #endregion
 
+        #region 鈻� 鎼滅储ID_____________________________
+
+        /// <summary>
+        /// 鎼滅储鎸囧畾ID鐨勪俊鎭�
+        /// </summary>
+        /// <param name="accountId">鎴愬憳ID</param>
+        /// <param name="txtMsg">淇℃伅鎺т欢</param>
+        private async void SearchMemberInfo(string accountId)
+        {
+            var pra = new AccountInfoPra();
+            pra.Account = accountId;
+            string result = await UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeUsers/GetSubAccountInfo", false, pra, new List<string>() { "AccountNoExists" });
+            if (result == null)
+            {
+                //寮傚父
+                return;
+            }
+            if (result == string.Empty)
+            {
+                //鎴愬憳涓嶅瓨鍦�
+                var form = new MemberNotEsixtForm();
+                form.AddForm();
+                return;
+            }
+
+            var infoResult = Newtonsoft.Json.JsonConvert.DeserializeObject<AccountInfoResult>(result);
+            infoResult.Account = accountId;
+
+            Application.RunOnMainThread(() =>
+            {
+                var form = new AddMemberInfoForm();
+                form.AddForm(infoResult);
+            });
+        }
+
+        #endregion
+
         #region 鈻� 鐣岄潰閲嶆柊婵�娲讳簨浠禵__________________
 
         /// <summary>

--
Gitblit v1.8.0