From f60b17fa18701c2cee017a5117e96510f54b44cf Mon Sep 17 00:00:00 2001
From: wxr <wxr@hdlchina.com.cn>
Date: 星期一, 02 十二月 2024 16:05:44 +0800
Subject: [PATCH] 更新功能

---
 HDL_ON/UI/UI2/1-HomePage/MessageCenterPage.cs |  339 ++++++++++++++++++++++++++------------------------------
 1 files changed, 157 insertions(+), 182 deletions(-)

diff --git a/HDL_ON/UI/UI2/1-HomePage/MessageCenterPage.cs b/HDL_ON/UI/UI2/1-HomePage/MessageCenterPage.cs
index 0ed2008..f57254a 100644
--- a/HDL_ON/UI/UI2/1-HomePage/MessageCenterPage.cs
+++ b/HDL_ON/UI/UI2/1-HomePage/MessageCenterPage.cs
@@ -4,9 +4,7 @@
 using System.Collections.Generic;
 using System.Threading;
 using HDL_ON.DAL.Server;
-//#if DEBUG
-//using Xamarin.Essentials;
-//#endif
+
 namespace HDL_ON.UI
 {
     /// <summary>
@@ -81,9 +79,6 @@
             AddMessageView();
             MenuButtonSelect(showMesType);
             RegisterGetPushMessageAction();
-            //娴嬭瘯浠g爜
-            //AddEmptyTipView();
-            //TestLoad();
         }
 
         /// <summary>
@@ -91,10 +86,9 @@
         /// </summary>
         void AddTopMenuView()
         {
-
             menuView = new HorizontalScrolViewLayout()
             {
-                Y = Application.GetRealHeight(64+10),
+                Y = Application.GetRealHeight(64 + 10),
                 Height = Application.GetRealWidth(117),
                 BackgroundColor = CSS_Color.MainBackgroundColor,
                 HorizontalScrollBarEnabled = false//闅愯棌婊氬姩鏉�
@@ -126,10 +120,10 @@
             //娴嬭瘯鎻愬墠褰撳墠鎺ㄩ�両D
             allMenuButton.ImageButton.MouseLongEventHandler = (sender, e) =>
             {
-//#if DEBUG
+                //#if DEBUG
 
-//                CopyToClipboard("鎺ㄩ�両D锛�" + OnAppConfig.Instance.PushId);
-//#else
+                //                CopyToClipboard("鎺ㄩ�両D锛�" + OnAppConfig.Instance.PushId);
+                //#else
                 //妫�娴嬫槸鍚﹁幏鍙栨帹閫両D鎴愬姛锛屾彁绀烘帹閫佹敞鍐屾槸鍚︽甯�
                 if (string.IsNullOrEmpty(OnAppConfig.Instance.PushId))
                 {
@@ -139,7 +133,7 @@
                 {
                     Utlis.ShowTip(Language.StringByID(StringId.PushNormal));
                 }
-//#endif
+                //#endif
 
             };
             #endregion
@@ -202,7 +196,7 @@
                 X = systemMenuButton.Right,
                 Y = Application.GetRealWidth(16),
             };
-            menuView.AddChidren(propertyMenuButton); 
+            menuView.AddChidren(propertyMenuButton);
             propertyMenuButton.ImageButton.SelectedImagePath = "Collection/MesCenter/PropertyOn.png";
             propertyMenuButton.ImageButton.UnSelectedImagePath = "Collection/MesCenter/Property.png";
             propertyMenuButton.TextButton.TextID = StringId.Propertynotice;
@@ -304,8 +298,6 @@
             GetPushMessageList(showMesType);
         }
 
-
-
         /// <summary>
         /// 娣诲姞鍐呭涓虹┖鎻愮ず椤甸潰
         /// </summary>
@@ -338,7 +330,7 @@
         {
             var rowView = new RowLayout()
             {
-                Height = Application.GetRealHeight(65),
+                Height = Application.GetRealWidth(76),
                 LineColor = CSS_Color.MainBackgroundColor,
             };
             VerticalScrolViewMiddle.AddChidren(rowView);
@@ -347,29 +339,29 @@
             var btnTilte = new TextButton()
             {
                 X = Application.GetRealWidth(16),
-                Y = Application.GetRealHeight(12),
-                Width = Application.GetRealWidth(343),
-                Height = Application.GetRealWidth(20),
+                Width = Application.GetRealWidth(258),
+                Height = Application.GetRealWidth(20 + 23),
                 TextAlignment = TextAlignment.CenterLeft,
                 TextColor = CSS_Color.FirstLevelTitleColor,
                 TextSize = CSS_FontSize.TextFontSize,
                 Text = pushMessageInfo.messageContent,
-                //IsMoreLines = true,
+                IsMoreLines = true,
             };
             rowView.AddChidren(btnTilte);
-            //
-            var needHeight = btnTilte.GetMoreLineNeedHeight();
-            btnTilte.IsMoreLines = true;
-            btnTilte.Height = needHeight;
-            rowView.Height = Application.GetRealHeight(45) + needHeight;
+
+            //var needHeight = btnTilte.GetMoreLineNeedHeight();
+            //btnTilte.IsMoreLines = true;
+            //btnTilte.Height = needHeight;
+            //rowView.Height = Application.GetRealWidth(45) + needHeight;
+
 
             //鍓爣棰�
             var btnSubtitle = new TextButton()
             {
                 X = Application.GetRealWidth(16),
-                Y = btnTilte.Bottom + Application.GetRealHeight(4),
-                Width = Application.GetRealWidth(240),
-                Height = Application.GetRealHeight(17),
+                Y = btnTilte.Bottom + Application.GetRealWidth(4),
+                Width = Application.GetRealWidth(258),
+                Height = Application.GetRealWidth(17),
                 TextAlignment = TextAlignment.CenterLeft,
                 TextColor = CSS_Color.PromptingColor1,
                 TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
@@ -406,8 +398,6 @@
             {
                 DeleteThePush(pushMessageInfo, rowView);
             };
-
-
             btnDatetime.Text = GetUnixToDateTime2(pushMessageInfo.createTime);
 
             EventHandler<MouseEventArgs> eventHandler = (sender, e) =>
@@ -419,6 +409,55 @@
             btnTilte.MouseUpEventHandler = eventHandler;
             btnSubtitle.MouseUpEventHandler = eventHandler;
 
+            if (!string.IsNullOrEmpty(pushMessageInfo.messageExpandInfo.ExpantContentInfo.picUrl) &&
+                pushMessageInfo.messageExpandInfo.ExpantContentInfo.picUrl != "null")
+            {
+                ImageView imageView = new ImageView()
+                {
+                    X = Application.GetRealWidth(291),
+                    Y = Application.GetRealWidth(8),
+                    Width = Application.GetRealWidth(52),
+                    Height = Application.GetRealWidth(32),
+                    Radius = (uint)Application.GetRealWidth(4),
+                    BorderColor = 0x00FFFFFF,
+                    BorderWidth = 1,
+                    ImagePath = "Collection/MesCenter/default_image.png"
+                };
+                rowView.AddChidren(imageView);
+
+                imageView.MouseUpEventHandler = (sender, e) => {
+                    Dialog dialog = new Dialog();
+
+                    var dialogView = new FrameLayout();
+                    dialog.AddChidren(dialogView);
+                    dialogView.MouseUpEventHandler = (sender, e) => {
+                        dialog.Close();
+                    };
+                    var dialogContentView = new ImageView()
+                    {
+                        Width = Application.GetRealWidth(375),
+                        Height = Application.GetRealWidth(211),
+                        ImageBytes = imageView.ImageBytes,
+                        Gravity = Gravity.Center,
+                    };
+                    dialogView.AddChidren(dialogContentView);
+
+                    dialog.Show();
+                };
+
+                new Thread(() => {
+                    var headImageBytes = HttpUtil.HttpsDownload(pushMessageInfo.messageExpandInfo.ExpantContentInfo.picUrl);
+                    if (headImageBytes != null && headImageBytes.Length > 0)
+                    {
+                        Application.RunOnMainThread(() =>
+                        {
+                            imageView.ImageBytes = headImageBytes;
+                        });
+                    }
+                })
+                { IsBackground = true }.Start();
+
+            }
 
         }
 
@@ -570,6 +609,7 @@
                     {
                         //PushMessageInfoList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<PushMessageInfo>>(result.Data.ToString());
                         //2021-08-28 鏀逛负鍒嗛〉鎺ュ彛
+                        MainPage.Log(result.Data.ToString());
                         var mPushMesList = Newtonsoft.Json.JsonConvert.DeserializeObject<PushMessageInfoList>(result.Data.ToString());
                         if (mPushMesList != null)
                         {
@@ -580,7 +620,6 @@
                         {
                             if (PushMessageInfoList != null && PushMessageInfoList.Count > 0)
                             {
-
                                 ParseAndDisplayPushList();
                                 PushSerivceMarkAllMessageRead();
                             }
@@ -601,6 +640,7 @@
                 }
                 catch (Exception ex)
                 {
+                    MainPage.Log("Error", $"鑾峰彇鎺ㄩ�佹秷鎭垪琛ㄥ紓甯�:{ex.StackTrace}");
                 }
                 finally
                 {
@@ -622,6 +662,7 @@
         /// </summary>
         void ParseAndDisplayPushList()
         {
+            bodyScrolView.RemoveAll();
             foreach (var info in PushMessageInfoList)
             {
                 //骞翠唤瑙f瀽 鍒ゆ柇鏄惁闇�瑕佹坊鍔犲勾浠芥爣棰�
@@ -694,18 +735,23 @@
         /// <param name="pushMessageInfo"></param>
         void OnClickPushMessageInfo(PushMessageInfo pushMessageInfo)
         {
-
             if (pushMessageInfo.pushType == PushType.Notice.ToString())
             {
-                //Utlis.WriteLine("鐗╀笟閫氱煡");
-                string noticeId = GetNoticeId(pushMessageInfo.messageExpand);
-                if (!string.IsNullOrEmpty(noticeId))
+                try
                 {
-                    GetPropertyNoticeDetails(noticeId);
+                    //Utlis.WriteLine("鐗╀笟閫氱煡");
+                    if (!string.IsNullOrEmpty(pushMessageInfo.messageExpand))
+                    {
+                        GetPropertyNoticeDetails(pushMessageInfo.messageExpandInfo.targetId);
+                    }
+                    else
+                    {
+                        Utlis.WriteLine("noticeId null");
+                    }
                 }
-                else
+                catch (Exception ex)
                 {
-                    Utlis.WriteLine("noticeId null");
+                    MainPage.Log("Error", $"閫氱煡淇℃伅鐐瑰嚮浜嬩欢:{ex.StackTrace}");
                 }
             }
             else
@@ -713,112 +759,6 @@
                 Utlis.WriteLine("鍏跺畠閫氱煡绫诲瀷");
             }
         }
-
-        /// <summary>
-        /// 瑙f瀽messageExpand 鎻愬彇targetId
-        /// </summary>
-        /// <param name="messageExpand"></param>
-        /// <returns></returns>
-        string GetNoticeId(string messageExpand)
-        {
-            try
-            {
-                if (!string.IsNullOrEmpty(messageExpand))
-                {
-                    var mMessageExpandInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<MessageExpandInfo>(messageExpand);
-                    if (mMessageExpandInfo != null)
-                    {
-                        var mExpantContentInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<ExpantContentInfo>(mMessageExpandInfo.expantContent);
-                        if(mExpantContentInfo != null)
-                        {
-                            return mExpantContentInfo.targetId;
-                        }
-                    }
-                }
-                return null;
-            }
-            catch
-            {
-                return null;
-            }
-        }
-
-        #region 娴嬭瘯
-#if DEBUG
-        /// <summary>
-        /// 
-        /// </summary>
-        void TestLoad()
-        {
-            PushMessageInfoList.Add(new PushMessageInfo()
-            {
-                messageTitle = "鎶ヨ淇℃伅",
-                messageContent = "闂ㄩ攣琚墦寮�",
-                createTime = 1606900275,
-            });
-
-            PushMessageInfoList.Add(new PushMessageInfo()
-            {
-                messageTitle = "鎶ヨ淇℃伅1",
-                messageContent = "闂ㄩ攣琚墦寮�",
-                createTime = 1606895454,
-            });
-
-            PushMessageInfoList.Add(new PushMessageInfo()
-            {
-                messageTitle = "鎶ヨ淇℃伅2",
-                messageContent = "闂ㄩ攣琚墦寮�",
-                createTime = 1606895454,
-            });
-
-            PushMessageInfoList.Add(new PushMessageInfo()
-            {
-                messageTitle = "鎶ヨ淇℃伅2019",
-                messageContent = "闂ㄩ攣琚墦寮�",
-                createTime = 1575277874,
-            });
-
-            PushMessageInfoList.Add(new PushMessageInfo()
-            {
-                messageTitle = "鎶ヨ淇℃伅2019",
-                messageContent = "闂ㄩ攣琚墦寮�",
-                createTime = 1572685874,
-            });
-
-            PushMessageInfoList.Add(new PushMessageInfo()
-            {
-                messageTitle = "鎶ヨ淇℃伅2018",
-                messageContent = "闂ㄩ攣琚墦寮�",
-                createTime = 1541149874,
-            });
-
-            PushMessageInfoList.Add(new PushMessageInfo()
-            {
-                messageTitle = "鎶ヨ淇℃伅2017",
-                messageContent = "闂ㄩ攣琚墦寮�",
-                createTime = 1509613874,
-            });
-
-            PushMessageInfoList.Add(new PushMessageInfo()
-            {
-                messageTitle = "鎶ヨ淇℃伅2017",
-                messageContent = "闂ㄩ攣琚墦寮�",
-                createTime = 1509613874,
-            });
-
-            PushMessageInfoList.Add(new PushMessageInfo()
-            {
-                messageTitle = "鎶ヨ淇℃伅2017",
-                messageContent = "闂ㄩ攣琚墦寮�",
-                createTime = 1506935474,
-            });
-
-            ParseAndDisplayPushList();
-        }
-
-#endif
-
-        #endregion
 
         /// <summary>
         /// 鏍囪鎵�鏈夋帹閫佹秷鎭凡璇�
@@ -836,8 +776,6 @@
                 {
                     Utlis.WriteLine("鏍囪澶辫触");
                 }
-
-
             })
             { IsBackground = true }.Start();
         }
@@ -851,7 +789,6 @@
             {
                 if (bodyView != null)
                 {
-
                     //Utlis.WriteLine("GetPushMessageAction M鏀跺埌鎺ㄩ��");
                     GetPushMessageList(showMesType);
                 }
@@ -865,19 +802,6 @@
         {
             HDLCommon.GetPushMessageAction = null;
         }
-
-//#if DEBUG
-
-//        /// <summary>
-//        /// 澶嶅埗鍒板壀鍒囨澘
-//        /// </summary>
-//        /// <param name="text"></param>
-//        void CopyToClipboard(string text)
-//        {
-//            Clipboard.SetTextAsync(text);
-//            Utlis.ShowTip(text + "\n" + Language.StringByID(StringId.CopySuccess));
-//        }
-//#endif
 
     }
 
@@ -913,6 +837,25 @@
         /// 鎵╁睍鏁版嵁
         /// </summary>
         public string messageExpand;
+        MessageExpand _messageExpandInfo;
+        public MessageExpand messageExpandInfo
+        {
+            get
+            {
+                if (_messageExpandInfo == null)
+                {
+                    if (!string.IsNullOrEmpty(messageExpand))
+                    {
+                        _messageExpandInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<MessageExpand>(messageExpand);
+                    }
+                    else
+                    {
+                        _messageExpandInfo = new MessageExpand();
+                    }
+                }
+                return _messageExpandInfo;
+            }
+        }
         ///// <summary>
         ///// 娑堟伅绫诲瀷锛�0锛氭彁绀猴紱1锛氭姤璀︼紱2锛氫赴鏋楀彲鏄璁插懠鍙紱3锛氬己鍒朵笅绾挎帹閫�
         ///// </summary>
@@ -927,6 +870,59 @@
         public long createTime;
     }
 
+    [System.Serializable]
+    public class MessageExpand
+    {
+        /// <summary>
+        /// 鎵╁睍鏁版嵁鍐呭
+        /// </summary>
+        public string expantContent;
+        private ExpantContent _expantContent;
+        public ExpantContent ExpantContentInfo
+        {
+            get
+            {
+                if (_expantContent == null)
+                {
+                    if (!string.IsNullOrEmpty(expantContent))
+                    {
+                        _expantContent = Newtonsoft.Json.JsonConvert.DeserializeObject<ExpantContent>(expantContent);
+                    }
+                    else
+                    {
+                        _expantContent = new ExpantContent();
+                    }
+                }
+                return _expantContent;
+            }
+        }
+
+        public string homeId;
+
+        public int messageLevel;
+
+        public string messageType;
+
+        public string targetId;
+
+    }
+
+    [System.Serializable]
+    public class ExpantContent
+    {
+        public string currentTime;
+        public string picUrl;
+        public string devSerial;
+        public string interphoneTypeEnum;
+        public string subToken;
+        public string deviceSid;
+        public string msgId;
+        public string type;
+        public string pushTime;
+        public string extDevId;
+        public string deviceId;
+        public string spk;
+    }
 
     /// <summary>
     // 鎺ㄩ�佹秷鎭垎椤靛璞�
@@ -964,29 +960,8 @@
     [System.Serializable]
     public class MessageExpandInfo
     {
-        /// <summary>
-        /// expantContent
-        /// </summary>
         public string expantContent;
-      
-    }
-
-    /// <summary>
-    /// 鎺ㄩ�佹墿灞曚俊鎭�
-    /// </summary>
-    [System.Serializable]
-    public class ExpantContentInfo
-    {
-        /// <summary>
-        /// targetId
-        /// </summary>
-        public string targetId;
-        /// <summary>
-        /// messageType
-        /// </summary>
-        public string messageType;
-
     }
 
 
-}
+}
\ No newline at end of file

--
Gitblit v1.8.0