123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- using UI.Mail;
- using FairyGUI;
- using UI.CommonGame;
- namespace GFGGame
- {
- public class MailContentView : BaseWindow
- {
- private UI_MailContentUI _ui;
- private int _childIndex;
- private MailInfo mailInfo;
- public override void Dispose()
- {
- base.Dispose();
- }
- protected override void OnInit()
- {
- base.OnInit();
- _ui = UI_MailContentUI.Create();
- this.viewCom = _ui.target;
- this.viewCom.Center();
- this.modal = true;
- viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
- _ui.m_listReward.itemRenderer = RenderListRewardItem;
- _ui.m_btnGet.onClick.Add(OnClickBtnGet);
- _ui.m_btnDelete.onClick.Add(OnClickBtnDelete);
- }
- protected override void AddEventListener()
- {
- EventAgent.AddEventListener(ConstMessage.MAIL_REWARD, UpdateNormal);
- }
- protected override void RemoveEventListener()
- {
- EventAgent.RemoveEventListener(ConstMessage.MAIL_REWARD, UpdateNormal);
- }
- protected override void OnShown()
- {
- base.OnShown();
- // EventAgent.AddEventListener(ConstMessage.MAIL_CHANGE, UpdateNormal);
- long mailId = (long)this.viewData;
- mailInfo = MailDataManager.Instance.GetMailInfoById(mailId);
- _ui.m_c1.selectedIndex = mailInfo.rewards.Count == 0 ? 0 : 1;
- _ui.m_txtTitle.text = mailInfo.title;
- _ui.m_ComContent.target.scrollPane.ScrollTop();
- _ui.m_ComContent.m_txtContent.text = mailInfo.content;
- UpdateNormal();
- }
- private void UpdateNormal()
- {
- _ui.m_btnGet.visible = (ConstMailStatus)mailInfo.state == ConstMailStatus.ReadedButNotGet ? true : false;
- _ui.m_btnDelete.visible = _ui.m_btnGet.visible == true ? false : true;
- _ui.m_listReward.numItems = mailInfo.rewards.Count;
- }
- private void RenderListRewardItem(int index, GObject obj)
- {
- ItemData reward = mailInfo.rewards[index];
- if (obj.data == null)
- {
- obj.data = new ItemView(obj as GComponent);
- }
- (obj.data as ItemView).SetData(reward);
- (obj.data as ItemView).ImgGotVisible = (ConstMailStatus)mailInfo.state == ConstMailStatus.ReadedAndGot ? true : false;
- }
- private async void OnClickBtnGet()
- {
- bool result = await MailSProxy.ReqMailReward(mailInfo.mailId);
- if (result)
- {
- mailInfo = MailDataManager.Instance.GetMailInfoById(mailInfo.mailId);
- UpdateNormal();
- }
- }
- private async void OnClickBtnDelete()
- {
- bool result = await MailSProxy.ReqDeleteMail(mailInfo.mailId);
- if (result)
- {
- this.Hide();
- }
- }
- // protected override void OnHide()
- // {
- // base.OnHide();
- // // EventAgent.RemoveEventListener(ConstMessage.MAIL_CHANGE, UpdateNormal);
- // }
- }
- }
|