From efad979b6fae76fb37a4de7e94e6bac0a85cb72c Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期二, 30 十一月 2021 13:14:28 +0800 Subject: [PATCH] 2021-11-30 1.修复乐橙Android,没调用拒接接口问题。 --- HDL_ON/UI/UI2/1-HomePage/MessageCenterPage.cs | 521 ++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 475 insertions(+), 46 deletions(-) diff --git a/HDL_ON/UI/UI2/1-HomePage/MessageCenterPage.cs b/HDL_ON/UI/UI2/1-HomePage/MessageCenterPage.cs index 212b147..b2635af 100644 --- a/HDL_ON/UI/UI2/1-HomePage/MessageCenterPage.cs +++ b/HDL_ON/UI/UI2/1-HomePage/MessageCenterPage.cs @@ -4,7 +4,9 @@ using System.Collections.Generic; using System.Threading; using HDL_ON.DAL.Server; - +#if DEBUG +using Xamarin.Essentials; +#endif namespace HDL_ON.UI { /// <summary> @@ -20,21 +22,22 @@ /// <summary> /// 鍐呭涓虹┖鎻愮ずView /// </summary> - EmptyTipView emptyTipView; + FrameLayout emptyTipView; /// <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> @@ -42,6 +45,17 @@ /// </summary> List<PushMessageInfo> PushMessageInfoList = new List<PushMessageInfo>(); + /// <summary> + /// 椤甸潰鍏抽棴鏃堕棿 + /// </summary> + Action backAction; + + public override void RemoveFromParent() + { + UnregisterGetPushMessageAction(); + base.RemoveFromParent(); + backAction?.Invoke(); + } /// <summary> /// @@ -55,13 +69,19 @@ /// <summary> /// /// </summary> - public void LoadPage() + /// <param name="backAction"></param> + public void LoadPage(Action backAction) { + this.backAction = backAction; new TopViewDiv(bodyView, Language.StringByID(StringId.MessageCenter)).LoadTopView(); AddTopMenuView(); AddMessageView(); MenuButtonSelect(showMesType); + RegisterGetPushMessageAction(); + //娴嬭瘯浠g爜 + //AddEmptyTipView(); + //TestLoad(); } /// <summary> @@ -70,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); + //宸adding View + menuView.AddChidren(new Button() + { + Width = Application.GetRealWidth(15), + BackgroundColor = CSS_Color.viewTranslucence + }); #region 鍏ㄩ儴鎸夐挳 allMenuButton = new MenuButton() @@ -94,6 +121,25 @@ MenuButtonSelect(0); }; allMenuButton.SelectAction = allAction; + //娴嬭瘯鎻愬墠褰撳墠鎺ㄩ�両D + allMenuButton.ImageButton.MouseLongEventHandler = (sender, e) => + { +#if DEBUG + + CopyToClipboard("鎺ㄩ�両D锛�" + OnAppConfig.Instance.PushId); +#else + //妫�娴嬫槸鍚﹁幏鍙栨帹閫両D鎴愬姛锛屾彁绀烘帹閫佹敞鍐屾槸鍚︽甯� + if (string.IsNullOrEmpty(OnAppConfig.Instance.PushId)) + { + Utlis.ShowTip(Language.StringByID(StringId.PushException)); + } + else + { + Utlis.ShowTip(Language.StringByID(StringId.PushNormal)); + } +#endif + + }; #endregion #region 鍒嗕韩涓庡姛鑳� @@ -106,6 +152,7 @@ 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); @@ -147,6 +194,31 @@ systemMenuButton.SelectAction = systemAction; #endregion + #region 鐗╀笟閫氱煡 2021-09-15澧炲姞 + propertyMenuButton = new MenuButton() + { + X = systemMenuButton.Right, + Y = Application.GetRealWidth(16), + }; + menuView.AddChidren(propertyMenuButton); + propertyMenuButton.ImageButton.SelectedImagePath = "Collection/MesCenter/PropertyOn.png"; + propertyMenuButton.ImageButton.UnSelectedImagePath = "Collection/MesCenter/Property.png"; + propertyMenuButton.TextButton.TextID = StringId.Propertynotice; + propertyMenuButton.TextButton.IsMoreLines = true; + Action propertyAction = () => + { + MenuButtonSelect(4); + }; + propertyMenuButton.SelectAction = propertyAction; + #endregion + + //鍙硃addingView + menuView.AddChidren(new Button() + { + Width = Application.GetRealWidth(15), + BackgroundColor = CSS_Color.viewTranslucence + }); + } /// <summary> @@ -175,7 +247,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; @@ -183,9 +255,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) @@ -194,6 +267,7 @@ shareMenuButton.IsSelected = true; alarmMenuButton.IsSelected = false; systemMenuButton.IsSelected = false; + propertyMenuButton.IsSelected = false; } else if (selectId == 2) @@ -202,6 +276,7 @@ shareMenuButton.IsSelected = false; alarmMenuButton.IsSelected = true; systemMenuButton.IsSelected = false; + propertyMenuButton.IsSelected = false; } else if (selectId == 3) { @@ -209,8 +284,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); } @@ -222,13 +309,24 @@ /// </summary> void AddEmptyTipView() { - emptyTipView = new EmptyTipView() + emptyTipView = new FrameLayout() + { + Height = bodyScrolView.Height, + Width = bodyScrolView.Width, + }; + bodyScrolView.AddChidren(emptyTipView); + + var tipView = new EmptyTipView() { Gravity = Gravity.Center }; - messageView.AddChidren(emptyTipView); + emptyTipView.AddChidren(tipView); } + /// <summary> + /// 骞翠唤鏍囪 + /// </summary> + string YearMark = ""; /// <summary> /// 鍔犺浇鎶ヨ淇℃伅RowView /// </summary> @@ -244,21 +342,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), @@ -267,7 +371,7 @@ TextAlignment = TextAlignment.CenterLeft, TextColor = CSS_Color.PromptingColor1, TextSize = CSS_FontSize.PromptFontSize_FirstLevel, - Text = pushMessageInfo.messageContent + Text = pushMessageInfo.messageTitle }; rowView.AddChidren(btnSubtitle); @@ -284,7 +388,7 @@ }; rowView.AddChidren(btnDatetime); - var lineView = new LineView(rowView.Height); + var lineView = new LineView(rowView.Height - Application.GetRealHeight(1)); rowView.AddChidren(lineView); //鍒犻櫎鎸夐挳 @@ -302,13 +406,35 @@ }; - btnDatetime.Text = Utlis.UnixToDateTime(pushMessageInfo.createTime).ToString("yyyy/MM/dd HH:mm:ss"); - //EventHandler<MouseEventArgs> eventHandler = (sender, e) => - //{ - //}; + btnDatetime.Text = GetUnixToDateTime(pushMessageInfo.createTime); - //btnTilte.MouseUpEventHandler = eventHandler; - //btnSubtitle.MouseUpEventHandler = eventHandler; + EventHandler<MouseEventArgs> eventHandler = (sender, e) => + { + OnClickPushMessageInfo(pushMessageInfo); + //new Alert(pushMessageInfo.messageTitle, pushMessageInfo.messageContent, Language.StringByID(StringId.Close)).Show(); + }; + rowView.MouseUpEventHandler = eventHandler; + btnTilte.MouseUpEventHandler = eventHandler; + btnSubtitle.MouseUpEventHandler = eventHandler; + + + } + + /// <summary> + /// 鏃堕棿鏍煎紡杞崲澶勭悊 + /// </summary> + /// <param name="time">姣鏃堕棿鎴�</param> + /// <returns></returns> + string GetUnixToDateTime(long time) + { + try + { + return Utlis.UnixToDateTimeWithFormatMS(time, "MM/dd HH:mm"); + } + catch (Exception ex) + { + return ""; + } } /// <summary> @@ -318,13 +444,20 @@ void DeleteThePush(PushMessageInfo pushMessageInfo, RowLayout rowView) { var waitPage = new Loading(); + bodyView.AddChidren(waitPage); waitPage.Start(Language.StringByID(StringId.PleaseWait)); new Thread(() => { 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); @@ -367,7 +500,7 @@ }; VerticalScrolViewMiddle.AddChidren(bgView); - var yearBtn = new Button() + var yearBtn = new TextButton() { X = Application.GetRealWidth(16), Y = Application.GetRealHeight(16), @@ -377,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> @@ -388,10 +521,26 @@ /// <param name="queryType"></param> void GetPushMessageList(int queryType = 0) { - var waitPage = new Loading(); - waitPage.Start(Language.StringByID(StringId.PleaseWait)); bodyScrolView.RemoveAll(); - PushMessageInfoList.Clear(); + if (PushMessageInfoList == null) + { + PushMessageInfoList = new List<PushMessageInfo>(); + } + else + { + PushMessageInfoList.Clear(); + } + + YearMark = "";//鏍囪娓呯┖ + if (string.IsNullOrEmpty(OnAppConfig.Instance.PushId)) + { + AddEmptyTipView(); + return; + } + + var waitPage = new Loading(); + bodyView.AddChidren(waitPage); + waitPage.Start(Language.StringByID(StringId.PleaseWait)); new Thread(() => { @@ -400,13 +549,21 @@ 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) { ParseAndDisplayPushList(); + PushSerivceMarkAllMessageRead(); } else { @@ -448,11 +605,127 @@ { foreach (var info in PushMessageInfoList) { + //骞翠唤瑙f瀽 鍒ゆ柇鏄惁闇�瑕佹坊鍔犲勾浠芥爣棰� + var mesYear = Utlis.UnixToDateTimeYearMS(info.createTime); + if (string.IsNullOrEmpty(YearMark)) + { + //鍒氬紑濮媃earMark鏍囪涓虹┖锛屾坊鍔犵涓�涓勾浠芥爣棰� + YearMark = mesYear; + AddYearRowView(bodyScrolView, YearMark); + } + else if (YearMark != mesYear) + { + //褰撳墠淇℃伅骞翠唤鍜屼箣鍓嶇殑涓嶄竴鏍凤紝閲嶆柊娣诲姞涓�涓勾浠芥爣棰� + YearMark = mesYear; + AddYearRowView(bodyScrolView, YearMark); + } + AddRowView(bodyScrolView, info); } } + /// <summary> + /// 鑾峰彇鐗╀笟閫氱煡璇︽儏 + /// </summary> + /// <param name="noticeId"></param> + void GetPropertyNoticeDetails(string noticeId) + { + var waitPage = new Loading(); + bodyView.AddChidren(waitPage); + waitPage.Start(Language.StringByID(StringId.PleaseWait)); + + new Thread(() => + { + try + { + var result = new HttpServerRequest().GetPropertyNoticeDetails(noticeId); + if (result.Code == StateCode.SUCCESS) + { + var mPushNoticeInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<PushNoticeInfo>(result.Data.ToString()); + if (mPushNoticeInfo != null) + { + Application.RunOnMainThread(() => + { + new WebViewDialog().LoadPageWithHtmlStr(mPushNoticeInfo.title, mPushNoticeInfo.content); + }); + } + } + } + catch (Exception ex) + { + } + finally + { + Application.RunOnMainThread(() => + { + if (waitPage != null) + { + waitPage.RemoveFromParent(); + waitPage = null; + } + }); + } + }) + { IsBackground = true }.Start(); + } + + /// <summary> + /// 閫氱煡淇℃伅鐐瑰嚮浜嬩欢 + /// </summary> + /// <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)) + { + GetPropertyNoticeDetails(noticeId); + } + else + { + Utlis.WriteLine("noticeId null"); + } + } + else + { + 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> @@ -462,7 +735,7 @@ { messageTitle = "鎶ヨ淇℃伅", messageContent = "闂ㄩ攣琚墦寮�", - createTime = 1606895454, + createTime = 1606900275, }); PushMessageInfoList.Add(new PushMessageInfo() @@ -479,19 +752,113 @@ createTime = 1606895454, }); - AddYearRowView(bodyScrolView, "2020骞�"); - foreach (var info in PushMessageInfoList) + PushMessageInfoList.Add(new PushMessageInfo() { - AddRowView(bodyScrolView, info); - } + messageTitle = "鎶ヨ淇℃伅2019", + messageContent = "闂ㄩ攣琚墦寮�", + createTime = 1575277874, + }); - AddYearRowView(bodyScrolView, "2019骞�"); - foreach (var info in PushMessageInfoList) + PushMessageInfoList.Add(new PushMessageInfo() { - AddRowView(bodyScrolView, info); - } + 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> + /// 鏍囪鎵�鏈夋帹閫佹秷鎭凡璇� + /// </summary> + void PushSerivceMarkAllMessageRead() + { + new Thread(() => + { + var result = new HttpServerRequest().PushSerivceMarkAllMessageRead(); + if (result) + { + Utlis.WriteLine("鏍囪鎴愬姛"); + } + else + { + Utlis.WriteLine("鏍囪澶辫触"); + } + + + }) + { IsBackground = true }.Start(); + } + + /// <summary> + /// 娉ㄥ唽鏀跺埌鎺ㄩ�佺洃鍚� + /// </summary> + void RegisterGetPushMessageAction() + { + HDLCommon.GetPushMessageAction = () => + { + if (bodyView != null) + { + //Utlis.WriteLine("GetPushMessageAction M鏀跺埌鎺ㄩ��"); + GetPushMessageList(showMesType); + } + }; + } + + /// <summary> + /// 鍙栨秷鏀跺埌鎺ㄩ�佺洃鍚� + /// </summary> + void UnregisterGetPushMessageAction() + { + 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 + } /// <summary> @@ -513,7 +880,7 @@ /// /// Default锛氬垎浜笌鍔熻兘锛汚larm锛氭姤璀︾被锛汸rompt锛氱郴缁熸秷鎭� /// </summary> - public int pushType; + public string pushType; /// <summary> /// 娑堟伅涓婚 /// </summary> @@ -526,10 +893,10 @@ /// 鎵╁睍鏁版嵁 /// </summary> public string messageExpand; - /// <summary> - /// 娑堟伅绫诲瀷锛�0锛氭彁绀猴紱1锛氭姤璀︼紱2锛氫赴鏋楀彲鏄璁插懠鍙紱3锛氬己鍒朵笅绾挎帹閫� - /// </summary> - public string messageType; + ///// <summary> + ///// 娑堟伅绫诲瀷锛�0锛氭彁绀猴紱1锛氭姤璀︼紱2锛氫赴鏋楀彲鏄璁插懠鍙紱3锛氬己鍒朵笅绾挎帹閫� + ///// </summary> + //public string messageType; /// <summary> /// 鏄惁宸茶 /// </summary> @@ -540,4 +907,66 @@ public long createTime; } + + /// <summary> + // 鎺ㄩ�佹秷鎭垎椤靛璞� + /// </summary> + public class PushMessageInfoList : BasePagingObj + { + public List<PushMessageInfo> list = new List<PushMessageInfo>(); + + } + + + /// <summary> + /// 鐗╀笟鍏憡璇︽儏 + /// </summary> + [System.Serializable] + public class PushNoticeInfo + { + /// <summary> + /// 娑堟伅ID + /// </summary> + public string noticeId; + /// <summary> + /// 娑堟伅鏍囬 + /// </summary> + public string title; + /// <summary> + /// 瀵屾枃鏈唴瀹� + /// </summary> + public string content; + } + + /// <summary> + /// 鎺ㄩ�佹墿灞曚俊鎭� + /// </summary> + [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; + + } + + } -- Gitblit v1.8.0