|
@@ -8,11 +8,11 @@ using FairyGUI;
|
|
using FL.Data;
|
|
using FL.Data;
|
|
using FL.Data.Items;
|
|
using FL.Data.Items;
|
|
using FL.Network;
|
|
using FL.Network;
|
|
|
|
+using Opencoding.Shared.Utils;
|
|
using System;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
using XGame.Database;
|
|
using XGame.Database;
|
|
using XGame.Framework.UI;
|
|
using XGame.Framework.UI;
|
|
-using static UnityEditor.Progress;
|
|
|
|
|
|
|
|
namespace FL.FGUI
|
|
namespace FL.FGUI
|
|
{
|
|
{
|
|
@@ -23,8 +23,8 @@ namespace FL.FGUI
|
|
public partial class MailMailPanelCtrl : UIController<MailMailPanelVM>
|
|
public partial class MailMailPanelCtrl : UIController<MailMailPanelVM>
|
|
{
|
|
{
|
|
|
|
|
|
- private List<MailInfo> _mailList;
|
|
|
|
- private List<ItemBase> _mailRwdList;
|
|
|
|
|
|
+ private List<MailInfo> _mailList = new List<MailInfo>();
|
|
|
|
+ private List<IItemBase> _mailRwdList;
|
|
private bool _isOpenMail;// 是否打开单封邮件
|
|
private bool _isOpenMail;// 是否打开单封邮件
|
|
private string _mailId;// 当前打开的邮件id
|
|
private string _mailId;// 当前打开的邮件id
|
|
|
|
|
|
@@ -49,8 +49,8 @@ namespace FL.FGUI
|
|
VM.ReadBtn.onClick.Add(OnClickReadBtn);
|
|
VM.ReadBtn.onClick.Add(OnClickReadBtn);
|
|
VM.GetBtn.onClick.Add(OnClickGetBtn);
|
|
VM.GetBtn.onClick.Add(OnClickGetBtn);
|
|
VM.DeleteBtn.onClick.Add(OnClickDeleteBtn);
|
|
VM.DeleteBtn.onClick.Add(OnClickDeleteBtn);
|
|
- Context.AddListener(EventDefine.OpenSingleMail, OpenSingleMail);
|
|
|
|
Context.AddListener(EventDefine.UpMailList, UpMailList);
|
|
Context.AddListener(EventDefine.UpMailList, UpMailList);
|
|
|
|
+ VM.MailList.ItemClickEvent += OnClcikMailListItem;
|
|
|
|
|
|
}
|
|
}
|
|
private void RemoveUIListenres()
|
|
private void RemoveUIListenres()
|
|
@@ -62,28 +62,28 @@ namespace FL.FGUI
|
|
VM.ReadBtn.onClick.Remove(OnClickReadBtn);
|
|
VM.ReadBtn.onClick.Remove(OnClickReadBtn);
|
|
VM.GetBtn.onClick.Remove(OnClickGetBtn);
|
|
VM.GetBtn.onClick.Remove(OnClickGetBtn);
|
|
VM.DeleteBtn.onClick.Remove(OnClickDeleteBtn);
|
|
VM.DeleteBtn.onClick.Remove(OnClickDeleteBtn);
|
|
- Context.RemoveListener(EventDefine.OpenSingleMail, OpenSingleMail);
|
|
|
|
Context.RemoveListener(EventDefine.UpMailList, UpMailList);
|
|
Context.RemoveListener(EventDefine.UpMailList, UpMailList);
|
|
|
|
+ VM.MailList.ItemClickEvent -= OnClcikMailListItem;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
private void Init()
|
|
private void Init()
|
|
{
|
|
{
|
|
if (_mailList == null) _mailList = new List<MailInfo>();
|
|
if (_mailList == null) _mailList = new List<MailInfo>();
|
|
- if (_mailRwdList == null) _mailRwdList = new List<ItemBase>();
|
|
|
|
|
|
+ if (_mailRwdList == null) _mailRwdList = new List<IItemBase>();
|
|
}
|
|
}
|
|
|
|
|
|
private void ShowUI()
|
|
private void ShowUI()
|
|
{
|
|
{
|
|
bool canGet = false;
|
|
bool canGet = false;
|
|
bool canRead = false;
|
|
bool canRead = false;
|
|
- List<MailInfo> dataList = new List<MailInfo>();
|
|
|
|
|
|
+ _mailList.Clear();
|
|
MailInfo mailInfo = null;
|
|
MailInfo mailInfo = null;
|
|
- for (int i = 0; i < MailData.Instance.mailInfo.Count; i++)
|
|
|
|
|
|
+ foreach (var mail in MailData.Instance.mailInfo)
|
|
{
|
|
{
|
|
- if (MailData.Instance.mailInfo[i].rts <= 0)
|
|
|
|
|
|
+ if (mail.Value.rts <= 0)
|
|
{
|
|
{
|
|
- if (MailData.Instance.mailInfo[i].items.Count > 0)
|
|
|
|
|
|
+ if (mail.Value.items.Count > 0)
|
|
{
|
|
{
|
|
canGet = true;
|
|
canGet = true;
|
|
}
|
|
}
|
|
@@ -92,14 +92,14 @@ namespace FL.FGUI
|
|
canRead = true;
|
|
canRead = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if (_isOpenMail && _mailId == MailData.Instance.mailInfo[i].id)
|
|
|
|
|
|
+ if (_isOpenMail && _mailId == mail.Value.id)
|
|
{
|
|
{
|
|
- mailInfo = MailData.Instance.mailInfo[i];
|
|
|
|
|
|
+ mailInfo = mail.Value;
|
|
}
|
|
}
|
|
long nowTime = Context.Time.GetNowTime() / 1000;
|
|
long nowTime = Context.Time.GetNowTime() / 1000;
|
|
- if (MailData.Instance.mailInfo[i].ets >= nowTime)
|
|
|
|
|
|
+ if (mail.Value.ets >= nowTime)
|
|
{
|
|
{
|
|
- dataList.Add(MailData.Instance.mailInfo[i]);
|
|
|
|
|
|
+ _mailList.Add(mail.Value);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
VM.AllReadBtn.visible = !_isOpenMail && canRead;// 一键已读
|
|
VM.AllReadBtn.visible = !_isOpenMail && canRead;// 一键已读
|
|
@@ -119,33 +119,29 @@ namespace FL.FGUI
|
|
VM.GetBtn.visible = _isOpenMail && singleCanGet;// 领取
|
|
VM.GetBtn.visible = _isOpenMail && singleCanGet;// 领取
|
|
VM.DeleteBtn.visible = _isOpenMail && !singleCanGet && !singleCanRead;// 删除
|
|
VM.DeleteBtn.visible = _isOpenMail && !singleCanGet && !singleCanRead;// 删除
|
|
VM.TitleLabel.text = mailInfo.title;
|
|
VM.TitleLabel.text = mailInfo.title;
|
|
- DateTimeOffset dateTime = DateTimeOffset.FromUnixTimeSeconds(mailInfo.ets);
|
|
|
|
- string yearMonthDay = dateTime.ToString("yyyy-MM-dd hh:mm");
|
|
|
|
- VM.TimeLabel.text = yearMonthDay;
|
|
|
|
|
|
+ VM.TimeLabel.text = mailInfo.ets.ToTimeYMDHM();
|
|
VM.ContentLabel.text = mailInfo.content;
|
|
VM.ContentLabel.text = mailInfo.content;
|
|
VM.ItemGrp.visible = hasItem;
|
|
VM.ItemGrp.visible = hasItem;
|
|
if (hasItem)
|
|
if (hasItem)
|
|
{
|
|
{
|
|
_mailRwdList.Clear();
|
|
_mailRwdList.Clear();
|
|
- for (global::System.Int32 i = 0; i < mailInfo.items.Count; i++)
|
|
|
|
|
|
+ for (int i = 0; i < mailInfo.items.Count; i++)
|
|
{
|
|
{
|
|
- ItemTable itemInfo = ItemTableRepo.Get(mailInfo.items[i].id);
|
|
|
|
- ItemBase _item = new ItemBase();
|
|
|
|
- _item.Init(itemInfo.Id, mailInfo.items[i].count);
|
|
|
|
|
|
+ IItemBase _item = ItemService.Instance.GetItemBase(mailInfo.items[i].id, mailInfo.items[i].count, mailInfo.items[i].kind, mailInfo.rts > 0);
|
|
_mailRwdList.Add(_item);
|
|
_mailRwdList.Add(_item);
|
|
}
|
|
}
|
|
ShowItemsUI(_mailRwdList);
|
|
ShowItemsUI(_mailRwdList);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- SetMailList(dataList);
|
|
|
|
|
|
+ SetMailList(_mailList);
|
|
|
|
|
|
}
|
|
}
|
|
// 打开单封邮件
|
|
// 打开单封邮件
|
|
- private void OpenSingleMail(int eventId, object args)
|
|
|
|
|
|
+ private void OpenSingleMail(string mailId)
|
|
{
|
|
{
|
|
_isOpenMail = true;
|
|
_isOpenMail = true;
|
|
- _mailId = args.ToString();
|
|
|
|
|
|
+ _mailId = mailId;
|
|
ShowUI();
|
|
ShowUI();
|
|
}
|
|
}
|
|
//刷新邮件列表
|
|
//刷新邮件列表
|
|
@@ -163,13 +159,19 @@ namespace FL.FGUI
|
|
// 邮件数量
|
|
// 邮件数量
|
|
private void UpMailCount(int num)
|
|
private void UpMailCount(int num)
|
|
{
|
|
{
|
|
- VM.MailCountLabel.text = $"邮件数量:{num}/{KeyValue.mailMax}";
|
|
|
|
|
|
+ VM.MailCountLabel.text = string.Format(StringDefine.MailCountLabel, num, KeyValue.mailMax);
|
|
}
|
|
}
|
|
//单封邮件内的奖励
|
|
//单封邮件内的奖励
|
|
- private void ShowItemsUI(List<ItemBase> dataList)
|
|
|
|
|
|
+ private void ShowItemsUI(List<IItemBase> dataList)
|
|
{
|
|
{
|
|
VM.ItemList.BindDatas(dataList);
|
|
VM.ItemList.BindDatas(dataList);
|
|
}
|
|
}
|
|
|
|
+ //点击邮件列表
|
|
|
|
+ private void OnClcikMailListItem(int index)
|
|
|
|
+ {
|
|
|
|
+ string mailId = _mailList[index].id;
|
|
|
|
+ OpenSingleMail(mailId);
|
|
|
|
+ }
|
|
//一键已读
|
|
//一键已读
|
|
private void OnClickAllReadBtn(EventContext context)
|
|
private void OnClickAllReadBtn(EventContext context)
|
|
{
|
|
{
|