NoticeView.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. }
  38. protected override void OnHide()
  39. {
  40. base.OnHide();
  41. }
  42. private void OnCtrlChange()
  43. {
  44. if (_ui.m_c1.selectedIndex == 0)
  45. {
  46. }
  47. else if (_ui.m_c1.selectedIndex == 1)
  48. {
  49. _ui.m_listNotice.numItems = NoticeDataManager.Instance.NoticeInfos.Count;
  50. _ui.m_txtTips.visible = _ui.m_listNotice.numItems == 0;
  51. }
  52. }
  53. private void ListActivityItemRender(int index, GObject obj)
  54. {
  55. UI_ListActivityItem item = UI_ListActivityItem.Proxy(obj);
  56. item.m_loaShow.url = ResPathUtil.GetActivityPath("");
  57. item.target.data = index;
  58. }
  59. private void OnListActivityClick(EventContext context)
  60. {
  61. _ui.m_listActivity.visible = false;
  62. _ui.m_listNotice.visible = false;
  63. // int noticeId = (int)(context.data as GObject).data;
  64. ViewManager.Show<NoticeActivityShowView>(null, new object[] { typeof(NoticeView).Name, this.viewData });
  65. }
  66. private void ListNoticeItemRender(int index, GObject obj)
  67. {
  68. NoticeInfo noticeInfo = NoticeDataManager.Instance.NoticeInfos[index];
  69. UI_ListNoticeItem item = UI_ListNoticeItem.Proxy(obj);
  70. item.m_txtTitle.text = noticeInfo.title;
  71. item.m_txtTime.text = TimeUtil.FormattingTime((int)noticeInfo.time);
  72. item.m_imgTips.visible = !noticeInfo.readStatus;
  73. if (item.m_btnGo.data == null)
  74. {
  75. item.m_btnGo.onClick.Add(OnListNoticeBtnGoClick);
  76. }
  77. item.m_btnGo.data = noticeInfo;
  78. }
  79. private async void OnListNoticeBtnGoClick(EventContext context)
  80. {
  81. _ui.m_listActivity.visible = false;
  82. _ui.m_listNotice.visible = false;
  83. NoticeInfo noticeInfo = (context.data as GObject).data as NoticeInfo;
  84. if (noticeInfo.content == "")
  85. {
  86. bool result = await NoticeSProxy.ReqSystemNotice(noticeInfo.noticeId);
  87. if (result)
  88. {
  89. ViewManager.Show<NoticeSystemShowView>(NoticeDataManager.Instance.GetNoticeInfoById(noticeInfo.noticeId), new object[] { typeof(NoticeView).Name, this.viewData });
  90. }
  91. }
  92. else
  93. {
  94. ViewManager.Show<NoticeSystemShowView>(noticeInfo, new object[] { typeof(NoticeView).Name, this.viewData });
  95. }
  96. }
  97. }
  98. }