| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 | 
							- using System.Collections;
 
- using System.Collections.Generic;
 
- using UnityEngine;
 
- using UI.Mail;
 
- using FairyGUI;
 
- using ET;
 
- namespace GFGGame
 
- {
 
-     public class MailView : BaseWindow
 
-     {
 
-         private UI_MailUI _ui;
 
-         private MailDataManager mailDataMgr;
 
-         private const int _maxMailCount = 300;
 
-         private const int _retainDay = 30;//邮件保存时间
 
-         private const int _showCount = 5;//列表展示数量
 
-         public bool _canShowContent = false;//获取内容数据返回前不可查看
 
-         public List<MailInfo> mailInfos = new List<MailInfo>();
 
-         public override void Dispose()
 
-         {
 
-             base.Dispose();
 
-         }
 
-         protected override void OnInit()
 
-         {
 
-             base.OnInit();
 
-             packageName = UI_MailUI.PACKAGE_NAME;
 
-             _ui = UI_MailUI.Create();
 
-             this.viewCom = _ui.target;
 
-             this.viewCom.Center();
 
-             this.modal = true;
 
-             viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
 
-             _ui.m_list.itemRenderer = RenderListItem;
 
-             _ui.m_list.SetVirtual();
 
-             _ui.m_btnGet.onClick.Add(OnClickBtnGet);
 
-             _ui.m_btnDelete.onClick.Add(OnClickBtnDelete);
 
-             EventAgent.AddEventListener(ConstMessage.MAIL_REFRESH, RefreshList);
 
-             EventAgent.AddEventListener(ConstMessage.MAIL_REWARD, RefreshList);
 
-             EventAgent.AddEventListener(ConstMessage.MAIL_ALLREWARD, UpdateNormal);
 
-             EventAgent.AddEventListener(ConstMessage.MAIL_DELETE, UpdateNormal);
 
-             EventAgent.AddEventListener(ConstMessage.MAIL_AllDELETE, UpdateNormal);
 
-             EventAgent.AddEventListener(ConstMessage.MAIL_CHANGE, UpdateNormal);
 
-             mailDataMgr = MailDataManager.Instance;
 
-         }
 
-         protected override void OnShown()
 
-         {
 
-             base.OnShown();
 
-             UpdateNormal();
 
-         }
 
-         private void UpdateNormal()
 
-         {
 
-             _ui.m_list.numItems = mailDataMgr.TotolCount;
 
-             _ui.m_txtTips.visible = mailDataMgr.TotolCount == 0 ? true : false;
 
-             _ui.m_txtCount.text = string.Format("当前邮件:{0}/{1}", StringUtil.GetColorText(mailDataMgr.TotolCount.ToString(), mailDataMgr.TotolCount >= _maxMailCount ? "#B19977" : "#E27D78"), _maxMailCount);
 
-             _ui.m_txtMaxCount.text = string.Format("最高可储存{0}封邮箱,请及时查看", _maxMailCount);
 
-             RefreshMailInfo(0, true);
 
-         }
 
-         private void RenderListItem(int index, GObject obj)
 
-         {
 
-             UI_ListItem item = UI_ListItem.Proxy(obj);
 
-             if (index + 1 > mailInfos.Count) return;
 
-             MailInfo data = mailInfos[index];
 
-             item.m_c1.selectedIndex = mailDataMgr.GetMailState(data);
 
-             item.m_txtTitle.text = data.title;
 
-             string str = TimeUtil.FormattingTime(TimeHelper.ServerNowSecs, ((int)data.timeSec + _retainDay * TimeUtil.SECOND_PER_DAY));
 
-             item.m_txtTime.text = string.Format("剩余时间:{0}", str);
 
-             if (item.m_btnLook.data == null)
 
-             {
 
-                 item.m_btnLook.onClick.Add(OnClickBtnLook);
 
-             }
 
-             item.m_btnLook.data = index;
 
-         }
 
-         private async void OnClickBtnLook(EventContext context)
 
-         {
 
-             int index = (int)(context.sender as GObject).data;
 
-             bool result = await MailSProxy.ReqMailContent(mailInfos[index].mailId);
 
-             if (result)
 
-             {
 
-                 ViewManager.Show<MailContentView>(mailInfos[index].mailId);
 
-             }
 
-         }
 
-         private async void RefreshMailInfo(int index, bool needSort)
 
-         {
 
-             if (mailDataMgr.TotolCount == 0) return;
 
-             if (needSort)
 
-             {
 
-                 _ui.m_list.ScrollToView(0);
 
-             }
 
-             bool result = await MailSProxy.ReqMailList(index, mailDataMgr.TotolCount, needSort);
 
-             if (result)
 
-             {
 
-                 mailInfos = mailDataMgr.GetMailInfos(index, mailDataMgr.TotolCount);
 
-                 RefreshList();
 
-                 _canShowContent = true;
 
-             }
 
-         }
 
-         private void RefreshList()
 
-         {
 
-             _ui.m_list.RefreshVirtualList();
 
-         }
 
-         private void OnClickBtnGet()
 
-         {
 
-             MailSProxy.ReqAllMailRewards().Coroutine();
 
-         }
 
-         private void OnClickBtnDelete()
 
-         {
 
-             if (mailDataMgr.TotolCount == 0)
 
-             {
 
-                 PromptController.Instance.ShowFloatTextPrompt("暂无邮件可删除");
 
-                 return;
 
-             }
 
-             Alert.Show("是否删除所有已读文件?").SetLeftButton(true).SetRightButton(true, "确认", (object data) =>
 
-             {
 
-                 SendDeleteAll();
 
-             });
 
-         }
 
-         private void SendDeleteAll()
 
-         {
 
-             MailSProxy.ReqDeleteAllMails().Coroutine();
 
-         }
 
-         protected override void OnHide()
 
-         {
 
-             base.OnHide();
 
-         }
 
-     }
 
- }
 
 
  |