JLChen
2021-09-14 12bda302564e919a0ba8157957df3d2ee7382909
HDL_ON/UI/UI2/1-HomePage/MessageCenterPage.cs
@@ -27,16 +27,17 @@
        /// <summary>
        /// menuView
        /// </summary>
        FrameLayout menuView;
        HorizontalScrolViewLayout menuView;//2021-08-27 增加多了一个菜单按钮所以改为滚动控件
        MenuButton allMenuButton;
        MenuButton shareMenuButton;
        MenuButton alarmMenuButton;
        MenuButton systemMenuButton;
        MenuButton propertyMenuButton;//增加物业通知按钮
        FrameLayout messageView;
        /// <summary>
        /// 显示的消息类型
        /// 0全部 1分享与功能 2报警类 3系统信息
        /// 0全部 1分享与功能 2报警类 3系统信息 4物业公告
        /// </summary>
        int showMesType = 0;
        /// <summary>
@@ -44,11 +45,16 @@
        /// </summary>
        List<PushMessageInfo> PushMessageInfoList = new List<PushMessageInfo>();
        /// <summary>
        /// 页面关闭时间
        /// </summary>
        Action backAction;
        public override void RemoveFromParent()
        {
            UnregisterGetPushMessageAction();
            base.RemoveFromParent();
            backAction?.Invoke();
        }
        /// <summary>
@@ -66,7 +72,8 @@
        /// <param name="backAction"></param>
        public void LoadPage(Action backAction)
        {
            new TopViewDiv(bodyView, Language.StringByID(StringId.MessageCenter)).LoadTopView(backAction);
            this.backAction = backAction;
            new TopViewDiv(bodyView, Language.StringByID(StringId.MessageCenter)).LoadTopView();
            AddTopMenuView();
            AddMessageView();
@@ -83,14 +90,21 @@
        void AddTopMenuView()
        {
            menuView = new FrameLayout()
            menuView = new HorizontalScrolViewLayout()
            {
                Y = Application.GetRealHeight(64),
                Height = Application.GetRealWidth(117),
                BackgroundColor = CSS_Color.MainBackgroundColor,
                HorizontalScrollBarEnabled = false//隐藏滚动条
            };
            bodyView.AddChidren(menuView);
            //左padding View
            menuView.AddChidren(new Button()
            {
                Width = Application.GetRealWidth(15),
                BackgroundColor = CSS_Color.viewTranslucence
            });
            #region 全部按钮
            allMenuButton = new MenuButton()
@@ -126,9 +140,9 @@
#endif
            };
#endregion
            #endregion
#region 分享与功能
            #region 分享与功能
            shareMenuButton = new MenuButton()
            {
                X = allMenuButton.Right,
@@ -138,14 +152,15 @@
            shareMenuButton.ImageButton.SelectedImagePath = "Collection/MesCenter/ShareOn.png";
            shareMenuButton.ImageButton.UnSelectedImagePath = "Collection/MesCenter/Share.png";
            shareMenuButton.TextButton.TextID = StringId.SharingAndFunctionality;
            shareMenuButton.TextButton.IsMoreLines = true;
            Action shateAction = () =>
            {
                MenuButtonSelect(1);
            };
            shareMenuButton.SelectAction = shateAction;
#endregion
            #endregion
#region 报警类
            #region 报警类
            alarmMenuButton = new MenuButton()
            {
                X = shareMenuButton.Right,
@@ -160,9 +175,9 @@
                MenuButtonSelect(2);
            };
            alarmMenuButton.SelectAction = alarmAction;
#endregion
            #endregion
#region 系统信息
            #region 系统信息
            systemMenuButton = new MenuButton()
            {
                X = alarmMenuButton.Right,
@@ -177,7 +192,33 @@
                MenuButtonSelect(3);
            };
            systemMenuButton.SelectAction = systemAction;
#endregion
            #endregion
            #region 物业通知
            propertyMenuButton = new MenuButton()
            {
                X = systemMenuButton.Right,
                Y = Application.GetRealWidth(16),
            };
            menuView.AddChidren(propertyMenuButton); //先屏蔽
            propertyMenuButton.ImageButton.SelectedImagePath = "Collection/MesCenter/SystemOn.png";
            propertyMenuButton.ImageButton.UnSelectedImagePath = "Collection/MesCenter/System.png";
            propertyMenuButton.TextButton.TextID = StringId.Propertynotice;
            propertyMenuButton.TextButton.IsMoreLines = true;
            Action propertyAction = () =>
            {
                MenuButtonSelect(4);
            };
            propertyMenuButton.SelectAction = propertyAction;
            #endregion
            //先屏蔽
            //右paddingView
            menuView.AddChidren(new Button()
            {
                Width = Application.GetRealWidth(15),
                BackgroundColor = CSS_Color.viewTranslucence
            });
        }
@@ -207,7 +248,7 @@
        /// <summary>
        /// 
        /// </summary>
        /// <param name="selectId">0全部 1分享与功能 2报警类 3系统信息</param>
        /// <param name="selectId">0全部 1分享与功能 2报警类 3系统信息 4物业通知</param>
        void MenuButtonSelect(int selectId)
        {
            showMesType = selectId;
@@ -215,9 +256,10 @@
            if (selectId == 0)
            {
                allMenuButton.IsSelected = true;
                shareMenuButton.IsSelected = false;
                alarmMenuButton.IsSelected = false;
                systemMenuButton.IsSelected = false;
                shareMenuButton.IsSelected = true;
                alarmMenuButton.IsSelected = true;
                systemMenuButton.IsSelected = true;
                propertyMenuButton.IsSelected = true;
            }
            else if (selectId == 1)
@@ -226,6 +268,7 @@
                shareMenuButton.IsSelected = true;
                alarmMenuButton.IsSelected = false;
                systemMenuButton.IsSelected = false;
                propertyMenuButton.IsSelected = false;
            }
            else if (selectId == 2)
@@ -234,6 +277,7 @@
                shareMenuButton.IsSelected = false;
                alarmMenuButton.IsSelected = true;
                systemMenuButton.IsSelected = false;
                propertyMenuButton.IsSelected = false;
            }
            else if (selectId == 3)
            {
@@ -241,8 +285,20 @@
                shareMenuButton.IsSelected = false;
                alarmMenuButton.IsSelected = false;
                systemMenuButton.IsSelected = true;
                propertyMenuButton.IsSelected = false;
            }
            else if (selectId == 4)
            {
                allMenuButton.IsSelected = false;
                shareMenuButton.IsSelected = false;
                alarmMenuButton.IsSelected = false;
                systemMenuButton.IsSelected = false;
                propertyMenuButton.IsSelected = true;
            }
            menuView.ScrollToX(selectId * Application.GetRealWidth(40));
            GetPushMessageList(showMesType);
        }
@@ -287,21 +343,27 @@
            VerticalScrolViewMiddle.AddChidren(rowView);
            //标题
            var btnTilte = new Button()
            var btnTilte = new TextButton()
            {
                X = Application.GetRealWidth(16),
                Y = Application.GetRealHeight(12),
                Width = Application.GetRealWidth(320),
                Height = Application.GetRealHeight(20),
                Width = Application.GetRealWidth(343),
                Height = Application.GetRealWidth(20),
                TextAlignment = TextAlignment.CenterLeft,
                TextColor = CSS_Color.FirstLevelTitleColor,
                TextSize = CSS_FontSize.TextFontSize,
                Text = pushMessageInfo.messageTitle
                Text = pushMessageInfo.messageContent,
                //IsMoreLines = true,
            };
            rowView.AddChidren(btnTilte);
            //
            var needHeight = btnTilte.GetMoreLineNeedHeight();
            btnTilte.IsMoreLines = true;
            btnTilte.Height = needHeight;
            rowView.Height = Application.GetRealHeight(45) + needHeight;
            //副标题
            var btnSubtitle = new Button()
            var btnSubtitle = new TextButton()
            {
                X = Application.GetRealWidth(16),
                Y = btnTilte.Bottom + Application.GetRealHeight(4),
@@ -310,7 +372,7 @@
                TextAlignment = TextAlignment.CenterLeft,
                TextColor = CSS_Color.PromptingColor1,
                TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
                Text = pushMessageInfo.messageContent
                Text = pushMessageInfo.messageTitle
            };
            rowView.AddChidren(btnSubtitle);
@@ -346,13 +408,16 @@
            btnDatetime.Text = GetUnixToDateTime(pushMessageInfo.createTime);
            EventHandler<MouseEventArgs> eventHandler = (sender, e) =>
            {
                new Alert(pushMessageInfo.messageTitle, pushMessageInfo.messageContent, Language.StringByID(StringId.Close)).Show();
            };
            rowView.MouseUpEventHandler = eventHandler;
            btnTilte.MouseUpEventHandler = eventHandler;
            btnSubtitle.MouseUpEventHandler = eventHandler;
            //2020-12-23 去掉点击弹窗事件
            //EventHandler<MouseEventArgs> eventHandler = (sender, e) =>
            //{
            //    new Alert(pushMessageInfo.messageTitle, pushMessageInfo.messageContent, Language.StringByID(StringId.Close)).Show();
            //};
            //rowView.MouseUpEventHandler = eventHandler;
            //btnTilte.MouseUpEventHandler = eventHandler;
            //btnSubtitle.MouseUpEventHandler = eventHandler;
        }
        /// <summary>
@@ -386,7 +451,13 @@
            {
                try
                {
                    var result = new HttpServerRequest().PushSerivceDeleteMessage(pushMessageInfo.id);
                    var delPush = new PushMsgIdObj()
                    {
                        msgId = pushMessageInfo.id,
                        pushType = pushMessageInfo.pushType
                    };
                    var result = new HttpServerRequest().PushSerivceDeleteMessage(delPush);
                    if (result)
                    {
                        PushMessageInfoList.Remove(pushMessageInfo);
@@ -429,7 +500,7 @@
            };
            VerticalScrolViewMiddle.AddChidren(bgView);
            var yearBtn = new Button()
            var yearBtn = new TextButton()
            {
                X = Application.GetRealWidth(16),
                Y = Application.GetRealHeight(16),
@@ -439,9 +510,9 @@
                TextColor = CSS_Color.FirstLevelTitleColor,
                TextSize = CSS_FontSize.EmphasisFontSize_FirstLevel,
                IsBold = true,
                Text = yearStr
            };
            bgView.AddChidren(yearBtn);
            yearBtn.Text = yearStr + Language.StringByID(StringId.Years);
        }
        /// <summary>
@@ -451,7 +522,15 @@
        void GetPushMessageList(int queryType = 0)
        {
            bodyScrolView.RemoveAll();
            PushMessageInfoList.Clear();
            if (PushMessageInfoList == null)
            {
                PushMessageInfoList = new List<PushMessageInfo>();
            }
            else
            {
                PushMessageInfoList.Clear();
            }
            YearMark = "";//标记清空
            if (string.IsNullOrEmpty(OnAppConfig.Instance.PushId))
            {
@@ -470,7 +549,14 @@
                    var result = new HttpServerRequest().PushSerivceGetPushmessagelist(queryType);
                    if (result.Code == StateCode.SUCCESS)
                    {
                        PushMessageInfoList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<PushMessageInfo>>(result.Data.ToString());
                        //PushMessageInfoList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<PushMessageInfo>>(result.Data.ToString());
                        //2021-08-28 改为分页接口
                        var mPushMesList = Newtonsoft.Json.JsonConvert.DeserializeObject<PushMessageInfoList>(result.Data.ToString());
                        if (mPushMesList != null)
                        {
                            PushMessageInfoList = mPushMesList.list;
                        }
                        Application.RunOnMainThread(() =>
                        {
                            if (PushMessageInfoList != null && PushMessageInfoList.Count > 0)
@@ -538,7 +624,7 @@
            }
        }
#region 测试
        #region 测试
#if DEBUG
        /// <summary>
        /// 
@@ -613,7 +699,7 @@
#endif
#endregion
        #endregion
        /// <summary>
        /// 标记所有推送消息已读
@@ -642,14 +728,14 @@
        /// </summary>
        void RegisterGetPushMessageAction()
        {
            //HDLCommon.GetPushMessageAction = () =>
            //{
            //    if (bodyView != null)
            //    {
            //        Utlis.WriteLine("GetPushMessageAction M收到推送");
            //        GetPushMessageList(showMesType);
            //    }
            //};
            HDLCommon.GetPushMessageAction = () =>
            {
                if (bodyView != null)
                {
                    //Utlis.WriteLine("GetPushMessageAction M收到推送");
                    GetPushMessageList(showMesType);
                }
            };
        }
        /// <summary>
@@ -657,7 +743,7 @@
        /// </summary>
        void UnregisterGetPushMessageAction()
        {
            //HDLCommon.GetPushMessageAction = null;
            HDLCommon.GetPushMessageAction = null;
        }
#if DEBUG
@@ -721,4 +807,14 @@
        public long createTime;
    }
    /// <summary>
    // 推送消息分页对象
    /// </summary>
    public class PushMessageInfoList : BasePagingObj
    {
        public List<PushMessageInfo> list = new List<PushMessageInfo>();
    }
}