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/CommonBase/Controls/NormalControls/MessageManagementControl.cs |   69 +++++++++++++++++++++++++++++++++-
 1 files changed, 67 insertions(+), 2 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/NormalControls/MessageManagementControl.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/NormalControls/MessageManagementControl.cs
old mode 100755
new mode 100644
index aa41b6f..b202963
--- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/NormalControls/MessageManagementControl.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/NormalControls/MessageManagementControl.cs
@@ -14,17 +14,22 @@
         /// </summary>
         public MessageManagementControl()
         {
+
             this.Height = Application.GetMinRealAverage(69);
             this.Width = Application.GetMinRealAverage(69);
             this.UnSelectedImagePath = "Item/MessageManagement.png";
             this.SelectedImagePath = "Item/MessageManagementSelected.png";
             this.ButtonClickEvent += (sender, e) =>
             {
+                //鐐瑰嚮鍚�,娓呯┖鐘舵��
                 this.IsSelected = false;
+                ControlCommonResourse.HadNewMessage = false;
 
                 var form = new UserMain.MessageManagementForm();
                 form.AddForm();
             };
+            //娣诲姞缂撳瓨
+            ControlCommonResourse.listMessageManaContr.Add(this);
             //鍒锋柊鐘舵��
             this.RefreshStatu();
         }
@@ -34,8 +39,68 @@
         /// </summary>
         public void RefreshStatu()
         {
-            //鏆傛椂娴嬭瘯
-            this.IsSelected = true;
+            if (ControlCommonResourse.HadNewMessage == true)
+            {
+                //濡傛灉宸茬粡鏈夋柊娑堟伅杩囨潵浜�,灏变笉鐢ㄨ浜�
+                ControlCommonResourse.ReadMessageAgain = false;
+                this.IsSelected = true;
+                return;
+            }
+            if (ControlCommonResourse.ReadMessageAgain == false)
+            {
+                //鏃犻渶鍐嶆璇诲彇
+                return;
+            }
+            ControlCommonResourse.ReadMessageAgain = false;
+
+            HdlThreadLogic.Current.RunThread(async () =>
+            {
+                string nowHomeId = Common.Config.Instance.Home.Id;
+                var pra = new MessageInfoPra();
+                pra.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
+
+                var result = await UserCenterLogic.GetResponseDataByRequestHttps("MessageCenter/GetMessageCenterPagger", false, pra, new List<string>() { "NotSetAgain", "NotCheck" });
+                if (string.IsNullOrEmpty(result) == true)
+                {
+                    //鍑洪敊锛岄渶瑕侀噸鏂拌鍙�
+                    ControlCommonResourse.ReadMessageAgain = true;
+                    return;
+                }
+                if (nowHomeId != Common.Config.Instance.Home.Id)
+                {
+                    //妫�娴嬶細鍒囨崲浜嗕綇瀹咃紵锛�
+                    return;
+                }
+                var dataInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<MessageCentetInfo>(result);
+                for (int i = 0; i < dataInfo.PageData.Count; i++)
+                {
+                    if (dataInfo.PageData[i].IsReading == false)
+                    {
+                        if (dataInfo.PageData[i].Topic == "/DoorLock/DoorLockOperatingEventNotificationCommand")
+                        {
+                            //鏆傛椂涓嶅鐞嗚繖涓富棰�
+                            continue;
+                        }
+                        ControlCommonResourse.HadNewMessage = true;
+                        Application.RunOnMainThread(() =>
+                        {
+                            //鏈夋柊娑堟伅
+                            this.IsSelected = true;
+                        });
+                        break;
+                    }
+                }
+            });
+        }
+
+        /// <summary>
+        /// 鎺т欢绉婚櫎
+        /// </summary>
+        public override void RemoveFromParent()
+        {
+            ControlCommonResourse.listMessageManaContr.Remove(this);
+            
+            base.RemoveFromParent();
         }
     }
 }

--
Gitblit v1.8.0