| | |
| | | using UnityEngine; |
| | | namespace vnxbqy.UI |
| | | public class MailInfoWin : UIBase |
| | | { |
| | | public class MailInfoWin : UIBase |
| | | [SerializeField] TextEx txtDate; |
| | | [SerializeField] TextEx txtTitle; |
| | | [SerializeField] Transform transNoAward; |
| | | [SerializeField] RichText txtNoAwardInfo; |
| | | [SerializeField] Transform transAward; |
| | | [SerializeField] RichText txtAwardInfo; |
| | | [SerializeField] ScrollerController scrAwardItem; |
| | | [SerializeField] TextEx txtExpiryDate; |
| | | [SerializeField] ButtonEx btnHave; |
| | | [SerializeField] ButtonEx btnDelete; |
| | | MailData nowMailData; |
| | | bool isHasAward = false; |
| | | MailManager model { get { return MailManager.Instance; } } |
| | | |
| | | protected override void InitComponent() |
| | | { |
| | | [SerializeField] TextEx txtDate; |
| | | [SerializeField] TextEx txtTitle; |
| | | [SerializeField] Transform transNoAward; |
| | | [SerializeField] RichText txtNoAwardInfo; |
| | | [SerializeField] Transform transAward; |
| | | [SerializeField] RichText txtAwardInfo; |
| | | [SerializeField] ScrollerController scrAwardItem; |
| | | [SerializeField] TextEx txtExpiryDate; |
| | | [SerializeField] ButtonEx btnHave; |
| | | [SerializeField] ButtonEx btnDelete; |
| | | MailData nowMailData; |
| | | bool isHasAward = false; |
| | | MailManager model { get { return MailManager.Instance; } } |
| | | base.InitComponent(); |
| | | btnHave.SetListener(OnClickHaveButton); |
| | | btnDelete.SetListener(OnClickDeleteButton); |
| | | } |
| | | |
| | | protected override void InitComponent() |
| | | protected override void OnPreOpen() |
| | | { |
| | | scrAwardItem.OnRefreshCell += OnRefreshLowRewardCell; |
| | | model.OnUpdateMailListEvent += OnUpdateMailListEvent; |
| | | model.OnUpdateMailStateChangeEvent += OnUpdateMailStateChangeEvent; |
| | | } |
| | | |
| | | protected override void OnOpen() |
| | | { |
| | | UpdateDataInfo(); |
| | | Display(); |
| | | CreateScrAward(); |
| | | } |
| | | |
| | | protected override void OnPreClose() |
| | | { |
| | | scrAwardItem.OnRefreshCell -= OnRefreshLowRewardCell; |
| | | model.OnUpdateMailListEvent -= OnUpdateMailListEvent; |
| | | model.OnUpdateMailStateChangeEvent -= OnUpdateMailStateChangeEvent; |
| | | } |
| | | |
| | | private void OnClickHaveButton() |
| | | { |
| | | if (model.nowUuid == null || model.nowUuid == string.Empty) |
| | | { |
| | | base.InitComponent(); |
| | | btnHave.SetListener(OnClickHaveButton); |
| | | btnDelete.SetListener(OnClickDeleteButton); |
| | | Debug.Log("当前查看的邮件没有UUID"); |
| | | return; |
| | | } |
| | | |
| | | protected override void OnPreOpen() |
| | | model.ClaimMail(model.nowUuid); |
| | | } |
| | | private void OnClickDeleteButton() |
| | | { |
| | | if (model.nowUuid == null || model.nowUuid == string.Empty) |
| | | { |
| | | scrAwardItem.OnRefreshCell += OnRefreshLowRewardCell; |
| | | model.OnUpdateMailListEvent += OnUpdateMailListEvent; |
| | | model.OnUpdateMailStateChangeEvent += OnUpdateMailStateChangeEvent; |
| | | Debug.Log("当前查看的邮件没有UUID"); |
| | | return; |
| | | } |
| | | model.DeleteMail(model.nowUuid); |
| | | UIManager.Instance.CloseWindow<MailInfoWin>(); |
| | | //邮件删除成功 |
| | | SysNotifyMgr.Instance.ShowTip("Mail01"); |
| | | } |
| | | |
| | | protected override void OnOpen() |
| | | { |
| | | UpdateDataInfo(); |
| | | Display(); |
| | | CreateScrAward(); |
| | | } |
| | | private void OnUpdateMailStateChangeEvent() |
| | | { |
| | | UpdateDataInfo(); |
| | | Display(); |
| | | CreateScrAward(); |
| | | } |
| | | |
| | | protected override void OnPreClose() |
| | | { |
| | | scrAwardItem.OnRefreshCell -= OnRefreshLowRewardCell; |
| | | model.OnUpdateMailListEvent -= OnUpdateMailListEvent; |
| | | model.OnUpdateMailStateChangeEvent -= OnUpdateMailStateChangeEvent; |
| | | } |
| | | private void OnUpdateMailListEvent() |
| | | { |
| | | UpdateDataInfo(); |
| | | Display(); |
| | | CreateScrAward(); |
| | | } |
| | | |
| | | private void OnClickHaveButton() |
| | | private void OnRefreshLowRewardCell(ScrollerDataType type, CellView cell) |
| | | { |
| | | var _cell = cell.GetComponent<MailInfoAwardItemCell>(); |
| | | _cell?.Display(cell.index, cell); |
| | | } |
| | | |
| | | private void CreateScrAward() |
| | | { |
| | | scrAwardItem.Refresh(); |
| | | if (isHasAward) |
| | | { |
| | | if (model.nowUuid == null || model.nowUuid == string.Empty) |
| | | for (int i = 0; i < nowMailData.Items.Count; i++) |
| | | { |
| | | Debug.Log("当前查看的邮件没有UUID"); |
| | | return; |
| | | CellInfo cellInfo = new CellInfo(); |
| | | cellInfo.infoInt1 = nowMailData.MailState; |
| | | scrAwardItem.AddCell(ScrollerDataType.Header, i); |
| | | } |
| | | model.ClaimMail(model.nowUuid); |
| | | } |
| | | private void OnClickDeleteButton() |
| | | { |
| | | if (model.nowUuid == null || model.nowUuid == string.Empty) |
| | | { |
| | | Debug.Log("当前查看的邮件没有UUID"); |
| | | return; |
| | | } |
| | | model.DeleteMail(model.nowUuid); |
| | | UIManager.Instance.CloseWindow<MailInfoWin>(); |
| | | //邮件删除成功 |
| | | SysNotifyMgr.Instance.ShowTip("Mail01"); |
| | | } |
| | | scrAwardItem.Restart(); |
| | | } |
| | | |
| | | private void OnUpdateMailStateChangeEvent() |
| | | { |
| | | UpdateDataInfo(); |
| | | Display(); |
| | | CreateScrAward(); |
| | | } |
| | | |
| | | private void OnUpdateMailListEvent() |
| | | { |
| | | UpdateDataInfo(); |
| | | Display(); |
| | | CreateScrAward(); |
| | | } |
| | | |
| | | private void OnRefreshLowRewardCell(ScrollerDataType type, CellView cell) |
| | | { |
| | | var _cell = cell.GetComponent<MailInfoAwardItemCell>(); |
| | | _cell?.Display(cell.index, cell); |
| | | } |
| | | |
| | | private void CreateScrAward() |
| | | { |
| | | scrAwardItem.Refresh(); |
| | | if (isHasAward) |
| | | { |
| | | for (int i = 0; i < nowMailData.Items.Count; i++) |
| | | { |
| | | CellInfo cellInfo = new CellInfo(); |
| | | cellInfo.infoInt1 = nowMailData.MailState; |
| | | scrAwardItem.AddCell(ScrollerDataType.Header, i); |
| | | } |
| | | } |
| | | scrAwardItem.Restart(); |
| | | } |
| | | |
| | | private void Display() |
| | | { |
| | | if (nowMailData == null) |
| | | return; |
| | | transNoAward.SetActive(!isHasAward); |
| | | transAward.SetActive(isHasAward); |
| | | txtDate.text = model.FormatCreateMailTime(nowMailData.CreateDateTime); |
| | | private void Display() |
| | | { |
| | | if (nowMailData == null) |
| | | return; |
| | | transNoAward.SetActive(!isHasAward); |
| | | transAward.SetActive(isHasAward); |
| | | txtDate.text = model.FormatCreateMailTime(nowMailData.CreateDateTime); |
| | | |
| | | if (nowMailData.IsTemplateMail()) |
| | | if (nowMailData.IsTemplateMail()) |
| | | { |
| | | string key = nowMailData.GetTemplateKey(); |
| | | if (MailConfig.HasKey(key)) |
| | | { |
| | | string key = nowMailData.GetTemplateKey(); |
| | | if (MailConfig.HasKey(key)) |
| | | { |
| | | MailConfig config = MailConfig.Get(key); |
| | | var templateParams = nowMailData.GetTemplateParams(); |
| | | string content = string.Format(config.Content, templateParams.ToArray()); |
| | | txtTitle.text = config.Title; |
| | | txtNoAwardInfo.text = content; |
| | | txtAwardInfo.text = content; |
| | | } |
| | | else |
| | | { |
| | | txtTitle.text = nowMailData.Title; |
| | | txtNoAwardInfo.text = nowMailData.Text; |
| | | txtAwardInfo.text = nowMailData.Text; |
| | | } |
| | | MailConfig config = MailConfig.Get(key); |
| | | var templateParams = nowMailData.GetTemplateParams(); |
| | | string content = string.Format(config.Content, templateParams.ToArray()); |
| | | txtTitle.text = config.Title; |
| | | txtNoAwardInfo.text = content; |
| | | txtAwardInfo.text = content; |
| | | } |
| | | else |
| | | { |
| | |
| | | txtNoAwardInfo.text = nowMailData.Text; |
| | | txtAwardInfo.text = nowMailData.Text; |
| | | } |
| | | |
| | | int expiryDays = model.GetMailExpiryDays(nowMailData.CreateDateTime, nowMailData.LimitDays); |
| | | txtExpiryDate.text = expiryDays > 0 ? Language.Get("Mail07", expiryDays) : string.Empty; |
| | | |
| | | } |
| | | |
| | | private void UpdateDataInfo() |
| | | else |
| | | { |
| | | if (!model.TryGetMailData(model.nowUuid, out nowMailData)) |
| | | { |
| | | UIManager.Instance.CloseWindow<MailInfoWin>(); |
| | | } |
| | | isHasAward = nowMailData != null && nowMailData.Items != null; |
| | | txtTitle.text = nowMailData.Title; |
| | | txtNoAwardInfo.text = nowMailData.Text; |
| | | txtAwardInfo.text = nowMailData.Text; |
| | | } |
| | | |
| | | int expiryDays = model.GetMailExpiryDays(nowMailData.CreateDateTime, nowMailData.LimitDays); |
| | | txtExpiryDate.text = expiryDays > 0 ? Language.Get("Mail07", expiryDays) : string.Empty; |
| | | |
| | | } |
| | | |
| | | private void UpdateDataInfo() |
| | | { |
| | | if (!model.TryGetMailData(model.nowUuid, out nowMailData)) |
| | | { |
| | | UIManager.Instance.CloseWindow<MailInfoWin>(); |
| | | } |
| | | isHasAward = nowMailData != null && nowMailData.Items != null; |
| | | } |
| | | } |
| | | |