From 1265d531759b5565e9f641b17045896b52dfdba8 Mon Sep 17 00:00:00 2001
From: JLChen <551775569@qq.com>
Date: 星期四, 03 十二月 2020 18:37:47 +0800
Subject: [PATCH] 2020-12-03 1.主页增加未读消息查询和提示处理。2.房间和场景背景上传和下载和读取方法修改处理。3.头像上传和下载方案修改处理。4.增加子账号头像下载。5.Loading 调用方法修复。6.封装ImageUtlis 图片上传和下载管理工具类 7.读取本地住宅增加判空处理。

---
 HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs |  142 ++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 134 insertions(+), 8 deletions(-)

diff --git a/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs b/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs
index 1441781..18e95f8 100644
--- a/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs
+++ b/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs
@@ -1,4 +1,6 @@
 锘縰sing System;
+using System.Collections.Generic;
+using HDL_ON.DAL.Server;
 using HDL_ON.DriverLayer;
 using HDL_ON.Entity;
 using Shared;
@@ -50,7 +52,7 @@
         /// <summary>
         /// 鍔犺浇鍔熻兘鏀惰棌鎸夐挳浜嬩欢
         /// </summary>
-        void LoadEvent_FunctionCollection(Button btn,Function function)
+        void LoadEvent_FunctionCollection(Button btn, Function function)
         {
             btn.MouseUpEventHandler += (sender, e) =>
             {
@@ -163,7 +165,7 @@
                                         btn.IsSelected = state;
                                         if (btn.Tag != null && btn.Tag.ToString() == "state")
                                         {
-                                            if(function.functionCategory == FunctionCategory.Music)
+                                            if (function.functionCategory == FunctionCategory.Music)
                                             {
                                                 btn.Text = (function as Music.A31MusicModel).A31PlayStatus.Title;
                                             }
@@ -188,9 +190,9 @@
         /// <summary>
         /// 鍔犺浇鍦烘櫙鎺у埗浜嬩欢
         /// </summary>
-        void LoadEvent_ControlScene(Button btnCoverd,Button btnName,Button btnZone ,Scene scene)
+        void LoadEvent_ControlScene(Button btnCoverd, Button btnName, Button btnZone, Scene scene)
         {
-          
+
             EventHandler<MouseEventArgs> eventHandler = (sender, e) =>
             {
                 string msg = scene.name + Language.StringByID(StringId.AlreadyOpened);
@@ -228,9 +230,10 @@
         /// </summary>
         /// <param name="tV"></param>
         /// <param name="button"></param>
-        void LoadEvent_ControlTV(TV tV,Button button)
+        void LoadEvent_ControlTV(TV tV, Button button)
         {
-            button.MouseUpEventHandler = (sender, e) => {
+            button.MouseUpEventHandler = (sender, e) =>
+            {
                 tV.ControlTV(InfraredCode_TV.Power);
             };
         }
@@ -250,7 +253,7 @@
                 curtain.trait_on_off.curValue = "off";
                 curtain.percent = 0;
                 System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
-                d.Add("on_off",curtain.trait_on_off.curValue.ToString());
+                d.Add("on_off", curtain.trait_on_off.curValue.ToString());
                 Control.Ins.SendWriteCommand(curtain, d);
             };
 
@@ -276,9 +279,15 @@
         {
             EventHandler<MouseEventArgs> eventHandler = (sender, e) =>
             {
+
+                //鎴块棿鍒犻櫎浜嬩欢
+                Action backAction = () => {
+                    GetUnreadPushMessages();
+                };
+
                 var skipPage = new MessageCenterPage();
                 MainPage.BasePageView.AddChidren(skipPage);
-                skipPage.LoadPage();
+                skipPage.LoadPage(backAction);
                 MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
             };
             btnMsgBg.MouseUpEventHandler = eventHandler;
@@ -287,5 +296,122 @@
             btnMsgIcon.MouseUpEventHandler = eventHandler;
         }
 
+
+        #region 鏌ヨ鏈璇绘秷鎭垪琛�
+        /// <summary>
+        /// 鏄惁姝e湪璇诲彇
+        /// </summary>
+        bool isGetting;
+        /// <summary>
+        /// 鏌ヨ鏈娑堟伅骞舵樉绀�
+        /// </summary>
+        void GetUnreadPushMessages()
+        {
+            System.Threading.Tasks.Task.Run(() =>
+            {
+                try
+                {
+                    if (isGetting) return;
+
+                    isGetting = true;
+
+                    var result = new HttpServerRequest().PushSerivceGetPushmessagelist();
+                    if (result.Code == StateCode.SUCCESS)
+                    {
+                        //鏈鐨勬秷鎭垪琛�
+                        var unreadList = new List<PushMessageInfo>();
+
+                        var pushMessageInfoList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<PushMessageInfo>>(result.Data.ToString());
+
+                        if (pushMessageInfoList != null && pushMessageInfoList.Count > 0)
+                        {
+                            foreach (var info in pushMessageInfoList)
+                            {
+                                if (!info.isRead)
+                                {
+                                    unreadList.Add(info);
+                                    break; // 璺冲嚭寰幆
+                                }
+                            }
+
+                            if (unreadList != null && unreadList.Count > 0)
+                            {
+                                Application.RunOnMainThread(() =>
+                                {
+                                    ShowMesBtnState(unreadList[0], false);
+                                });
+                            }
+                            else
+                            {
+                                Application.RunOnMainThread(() =>
+                                {
+                                    ShowMesBtnState(pushMessageInfoList[0], true);
+                                });
+                               
+                            }
+
+                        }
+
+                    }
+                    else
+                    {
+
+                    }
+                }
+                catch (Exception ex)
+                {
+                }
+                finally
+                {
+                    isGetting = false;
+                }
+
+            });
+
+        }
+
+        /// <summary>
+        /// 鏄剧ず鏈璇绘秷鎭�
+        /// </summary>
+        /// <param name="pushMessageInfo"></param>
+        /// <param name="allRead">鎵�鏈夐兘宸茶</param>
+        void ShowMesBtnState(PushMessageInfo pushMessageInfo, bool allRead)
+        {
+            if (bodyView == null) return;
+            btnMsg.Text = pushMessageInfo.messageTitle + ": " + pushMessageInfo.messageContent;
+            btnMsgTime.Text = GetUnixToDateTime(pushMessageInfo.createTime);
+            btnMsgIcon.IsSelected = !allRead;
+        }
+
+        /// <summary>
+        /// 閲嶇疆鏈娑堟伅鎺т欢
+        /// </summary>
+        void ResetMesBtnRead()
+        {
+            if (bodyView == null) return;
+            btnMsg.Text = "...";
+            btnMsgTime.Text = "00:00";
+            btnMsgIcon.IsSelected = false;
+        }
+
+        /// <summary>
+        /// 鏃堕棿鏍煎紡杞崲澶勭悊
+        /// </summary>
+        /// <param name="time">姣鏃堕棿鎴�</param>
+        /// <returns></returns>
+        string GetUnixToDateTime(long time)
+        {
+            try
+            {
+                return Utlis.UnixToDateTimeWithFormatMS(time, "HH:mm");
+            }
+            catch (Exception ex)
+            {
+                return "";
+            }
+        }
+
+        #endregion
+
     }
 }

--
Gitblit v1.8.0