NoticeView.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. using UnityEngine;
  2. using FairyGUI;
  3. using UI.Notice;
  4. namespace GFGGame
  5. {
  6. public class NoticeView : BaseWindow
  7. {
  8. private UI_NoticeUI _ui;
  9. public override void Dispose()
  10. {
  11. base.Dispose();
  12. }
  13. protected override void Init()
  14. {
  15. base.Init();
  16. packageName = UI_NoticeUI.PACKAGE_NAME;
  17. _ui = UI_NoticeUI.Create();
  18. this.viewCom = _ui.target;
  19. this.viewCom.Center();
  20. this.modal = true;
  21. viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
  22. }
  23. protected override void OnInit()
  24. {
  25. base.OnInit();
  26. _ui.m_listActivity.itemRenderer = ListActivityItemRender;
  27. _ui.m_listActivity.onClick.Add(OnListActivityClick);
  28. _ui.m_listNotice.itemRenderer = ListNoticeItemRender;
  29. _ui.m_c1.onChanged.Add(OnCtrlChange);
  30. }
  31. protected override void OnShown()
  32. {
  33. base.OnShown();
  34. _ui.m_c1.selectedIndex = 1;
  35. _ui.m_listActivity.visible = true;
  36. _ui.m_listNotice.visible = true;
  37. OnCtrlChange();
  38. }
  39. protected override void OnHide()
  40. {
  41. base.OnHide();
  42. }
  43. private void OnCtrlChange()
  44. {
  45. if (_ui.m_c1.selectedIndex == 0)
  46. {
  47. _ui.m_listActivity.numItems = 0;
  48. _ui.m_txtTips.visible = _ui.m_listActivity.numItems == 0;
  49. }
  50. else if (_ui.m_c1.selectedIndex == 1)
  51. {
  52. _ui.m_listNotice.numItems = NoticeDataManager.Instance.NoticeInfos.Count;
  53. _ui.m_txtTips.visible = _ui.m_listNotice.numItems == 0;
  54. }
  55. }
  56. private void ListActivityItemRender(int index, GObject obj)
  57. {
  58. UI_ListActivityItem item = UI_ListActivityItem.Proxy(obj);
  59. item.m_loaShow.url = ResPathUtil.GetActivityPath("");
  60. item.target.data = index;
  61. }
  62. private void OnListActivityClick(EventContext context)
  63. {
  64. _ui.m_listActivity.visible = false;
  65. _ui.m_listNotice.visible = false;
  66. // int noticeId = (int)(context.data as GObject).data;
  67. ViewManager.Show<NoticeActivityShowView>(null, new object[] { typeof(NoticeView).Name, this.viewData });
  68. }
  69. private void ListNoticeItemRender(int index, GObject obj)
  70. {
  71. NoticeInfo noticeInfo = NoticeDataManager.Instance.NoticeInfos[index];
  72. UI_ListNoticeItem item = UI_ListNoticeItem.Proxy(obj);
  73. item.m_txtTitle.text = noticeInfo.title;
  74. item.m_txtTime.text = TimeUtil.FormattingTime(noticeInfo.time);
  75. item.m_imgTips.visible = !noticeInfo.readStatus;
  76. if (item.m_btnGo.data == null)
  77. {
  78. item.m_btnGo.onClick.Add(OnListNoticeBtnGoClick);
  79. }
  80. item.m_btnGo.data = noticeInfo;
  81. }
  82. private async void OnListNoticeBtnGoClick(EventContext context)
  83. {
  84. _ui.m_listActivity.visible = false;
  85. _ui.m_listNotice.visible = false;
  86. NoticeInfo noticeInfo = (context.sender as GObject).data as NoticeInfo;
  87. if (noticeInfo.content == "")
  88. {
  89. bool result = await NoticeSProxy.ReqSystemNotice(noticeInfo.noticeId);
  90. if (result)
  91. {
  92. ViewManager.Show<NoticeSystemShowView>(NoticeDataManager.Instance.GetNoticeInfoById(noticeInfo.noticeId), new object[] { typeof(NoticeView).Name, this.viewData });
  93. }
  94. }
  95. else
  96. {
  97. ViewManager.Show<NoticeSystemShowView>(noticeInfo, new object[] { typeof(NoticeView).Name, this.viewData });
  98. }
  99. }
  100. }
  101. }