| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 | 
							- 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;//?б???????
 
-         private int _firstPage = 0;//当前页面
 
-         private int _endPage = 0;//当前页面
 
-         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_list.scrollPane.onScrollEnd.Add(() =>
 
-             {
 
-                 RefreshMailInfo(false);
 
-             });
 
-             // _ui.target.onTouchEnd.Add(() =>
 
-             // {
 
-             //     RefreshMailInfo(false);
 
-             // });
 
-             _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();
 
-             mailDataMgr.CurPage = 0;
 
-             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(true);
 
-         }
 
-         private void RenderListItem(int index, GObject obj)
 
-         {
 
-             // _endPage = index / mailDataMgr.PageCount;
 
-             // ET.Log.Debug("_endPage:" + _endPage + "   index:" + index + "    PageCount:" + mailDataMgr.PageCount);
 
-             UI_ListItem item = UI_ListItem.Proxy(obj);
 
-             long mailId = mailDataMgr.GetMailIdByIndex(index);
 
-             // item.m_btnLook.data = mailId;
 
-             if (mailId < 0)
 
-             {
 
-                 item.m_txtTitle.text = "请稍后...";
 
-                 item.m_txtTime.text = "";
 
-                 return;
 
-             }
 
-             // long mailId = mailDataMgr.MailIds[index];
 
-             MailInfo data = mailDataMgr.GetMailInfoById(mailId);
 
-             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 = mailId;
 
-             UI_ListItem.ProxyEnd();
 
-         }
 
-         private async void OnClickBtnLook(EventContext context)
 
-         {
 
-             // int index = (int)(context.sender as GObject).data;
 
-             long mailId = (long)(context.sender as GObject).data;
 
-             bool result = await MailSProxy.ReqMailContent(mailId);
 
-             if (result)
 
-             {
 
-                 ViewManager.Show<MailContentView>(mailId);
 
-             }
 
-         }
 
-         private async void RefreshMailInfo(bool needSort)
 
-         {
 
-             if (mailDataMgr.TotolCount == 0) return;
 
-             if (needSort)
 
-             {
 
-                 _ui.m_list.ScrollToView(0);
 
-                 MailDataManager.Instance.RefreshMailInfoDic(needSort);
 
-             }
 
-             _firstPage = _ui.m_list.ChildIndexToItemIndex(0) / mailDataMgr.PageCount;
 
-             _endPage = _ui.m_list.ChildIndexToItemIndex(_ui.m_list.numChildren - 1) / mailDataMgr.PageCount;
 
-             ET.Log.Debug("_firstPage:" + _firstPage + "   _endPage:" + _endPage);
 
-             if (mailDataMgr.GetMailIdByPage(_firstPage) != null && mailDataMgr.GetMailIdByPage(_endPage) != null)
 
-             {
 
-                 RefreshList();
 
-                 return;
 
-             }
 
-             if (mailDataMgr.GetMailIdByPage(_firstPage) == null)
 
-             {
 
-                 bool result = await MailSProxy.ReqMailList(_firstPage * mailDataMgr.PageCount, mailDataMgr.PageCount, needSort, _firstPage);
 
-                 if (result)
 
-                 {
 
-                     RefreshList();
 
-                 }
 
-             }
 
-             if (_endPage == _firstPage) return;
 
-             if (mailDataMgr.GetMailIdByPage(_endPage) == null)
 
-             {
 
-                 bool result = await MailSProxy.ReqMailList(_endPage * mailDataMgr.PageCount, mailDataMgr.PageCount, needSort, _endPage);
 
-                 if (result)
 
-                 {
 
-                     RefreshList();
 
-                 }
 
-             }
 
-         }
 
-         private void RefreshList()
 
-         {
 
-             // mailInfos = mailDataMgr.GetMailInfos();
 
-             _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();
 
-         }
 
-     }
 
- }
 
 
  |