using UnityEngine; using FairyGUI; using UI.Notice; using System.Collections.Generic; using ET; namespace GFGGame { public class NoticeView : BaseWindow { private UI_NoticeUI _ui; private EffectUI _effectUI1; private EffectUI _effectUI2; private AdCfg[] activitydata; private List showActivity = new List(); public override void Dispose() { EffectUIPool.Recycle(_effectUI1); _effectUI1 = null; EffectUIPool.Recycle(_effectUI2); _effectUI2 = null; if (_ui != null) { _ui.Dispose(); _ui = null; } base.Dispose(); } protected override void Init() { base.Init(); packageName = UI_NoticeUI.PACKAGE_NAME; _ui = UI_NoticeUI.Create(); this.viewCom = _ui.target; this.viewCom.Center(); this.modal = true; viewAnimationType = EnumViewAnimationType.ZOOM_CENTER; //isReturnView = true; } protected override void OnInit() { base.OnInit(); _ui.m_listActivity.itemRenderer = ListActivityItemRender; //_ui.m_listActivity.onClick.Add(OnListActivityClick); _ui.m_listNotice.itemRenderer = ListNoticeItemRender; _ui.m_c1.onChanged.Add(OnCtrlChange); AddEffect(); } protected override void AddEventListener() { base.AddEventListener(); EventAgent.AddEventListener(ConstMessage.NOTICE_SYSTOM_ADD, OnCtrlChange); EventAgent.AddEventListener(ConstMessage.NOTICE_SYSTOM_REMOVE, OnCtrlChange); EventAgent.AddEventListener(ConstMessage.SHOW_SYSTEM_NOTICE, UpdateView); } protected override void OnShown() { base.OnShown(); if (backRefresh) { _ui.m_c1.selectedIndex = 0; } UpdateView(); } protected override void OnHide() { base.OnHide(); } protected override void RemoveEventListener() { base.RemoveEventListener(); EventAgent.RemoveEventListener(ConstMessage.NOTICE_SYSTOM_ADD, OnCtrlChange); EventAgent.RemoveEventListener(ConstMessage.NOTICE_SYSTOM_REMOVE, OnCtrlChange); EventAgent.RemoveEventListener(ConstMessage.SHOW_SYSTEM_NOTICE, UpdateView); } private void AddEffect() { //邊框左上角特效 _effectUI1 = EffectUIPool.CreateEffectUI(_ui.m_holderLeftTop, "ui_Activity", "Com_window_L_up"); //邊框右下角特效 _effectUI2 = EffectUIPool.CreateEffectUI(_ui.m_holderRightDowm, "ui_Activity", "Com_window_R_Down"); } private void OnCtrlChange() { if (_ui.m_c1.selectedIndex == 0) { UpdateInfo(); _ui.m_listActivity.numItems = showActivity.Count; _ui.m_txtTips.visible = _ui.m_listActivity.numItems == 0; } else if (_ui.m_c1.selectedIndex == 1) { _ui.m_listNotice.numItems = NoticeDataManager.Instance.NoticeInfos.Count; _ui.m_txtTips.visible = _ui.m_listNotice.numItems == 0; } } /// /// 活动公告 0 /// /// /// private void ListActivityItemRender(int index, GObject obj) { UI_ListActivityItem item = UI_ListActivityItem.Proxy(obj); item.m_loaShow.url = ResPathUtil.GetActivityPath(showActivity[index].NoticeTips, "png"); item.m_txtName.text = ""; long endTime = 0; long curTime = TimeHelper.ServerNow(); if (showActivity.Count > 0) { if (showActivity[index].endTime != "" && showActivity[index].endTime != null) { endTime = TimeUtil.DateTimeToTimestamp(showActivity[0].endTime); } else { ActivityInfo activityInfo = ActivityGlobalDataManager.Instance.GetActivityInfo(showActivity[index].activityId); endTime = activityInfo.EndTime; } } item.m_txtTime.text = string.Format("剩余时间:{0}", TimeUtil.FormattingTimeTo_DDHHmm(endTime - curTime)); item.target.onClick.Add(OnListActivityClick); item.target.data = showActivity[index]; item.m_imgTips.visible = NoticeDataManager.Instance.GetRedDotState(showActivity[index].jumpId, showActivity[index].activityId); UI_ListActivityItem.ProxyEnd(); } private void OnListActivityClick(EventContext context) { AdCfg adCfg = (AdCfg)(context.sender as GObject).data; object[] param = null; int jumpIndex = 0; if (adCfg.jumpId == nameof(LimitChargeView)) { param = new object[] { adCfg.activityId }; } if (adCfg.jumpId == nameof(NewLimitChargeView)) { param = new object[] { adCfg.activityId }; } if (adCfg.jumpId == nameof(LuckyBoxView)) { jumpIndex = adCfg.jumpParamArr[0]; } if (jumpIndex != 0) { ViewManager.Show($"GFGGame.{adCfg.jumpId}", jumpIndex, false, false); //Hide(); } else { ViewManager.Show($"GFGGame.{adCfg.jumpId}", param, false, false); //Hide(); } } public override void Refresh() { base.Refresh(); Debug.LogError(1); } /// /// 系统公告 1 /// /// /// private void ListNoticeItemRender(int index, GObject obj) { NoticeInfo noticeInfo = NoticeDataManager.Instance.NoticeInfos[index]; UI_ListNoticeItem item = UI_ListNoticeItem.Proxy(obj); item.m_txtTitle.text = noticeInfo.title; item.m_txtTime.text = TimeUtil.FormattingTimeTo_yyyMMdd0(noticeInfo.time); // item.m_imgTips.visible = !noticeInfo.readStatus; RedDotController.Instance.SetComRedDot(item.target, !noticeInfo.readStatus, "gg_gg_hdhdgth", -40, 32); if (item.m_btnGo.data == null) { item.m_btnGo.onClick.Add(OnListNoticeBtnGoClick); } item.m_btnGo.data = noticeInfo; UI_ListNoticeItem.ProxyEnd(); } private async void OnListNoticeBtnGoClick(EventContext context) { _ui.m_listActivity.visible = false; _ui.m_listNotice.visible = false; _ui.m_buttonCom.visible = false; NoticeInfo noticeInfo = (context.sender as GObject).data as NoticeInfo; if (noticeInfo.content == "") { bool result = await NoticeSProxy.ReqSystemNotice(noticeInfo.noticeId); if (result) { ViewManager.Show(NoticeDataManager.Instance.GetNoticeInfoById(noticeInfo.noticeId), false, false); } } else { ViewManager.Show(noticeInfo, false, false); } } private void UpdateInfo() { showActivity = NoticeDataManager.Instance.UpdateShowActivity(); } private void UpdateTitleRedDot() { RedDotController.Instance.SetComRedDot(_ui.m_btnActivity, false); RedDotController.Instance.SetComRedDot(_ui.m_btnNotice, false); // 活动公告 for (int i = 0; i < showActivity.Count; i++) { if (NoticeDataManager.Instance.GetRedDotState(showActivity[i].jumpId, showActivity[i].activityId)) { RedDotController.Instance.SetComRedDot(_ui.m_btnActivity, true, "", -25); break; } } // 系统公告 for (int i = 0; i < NoticeDataManager.Instance.NoticeInfos.Count; i++) { if (!NoticeDataManager.Instance.NoticeInfos[i].readStatus) { RedDotController.Instance.SetComRedDot(_ui.m_btnNotice, true, "", -25); break; } } } private void UpdateView() { _ui.m_listActivity.visible = true; _ui.m_listNotice.visible = true; _ui.m_buttonCom.visible = true; OnCtrlChange(); UpdateInfo(); UpdateTitleRedDot(); } } }