MailMailPanelItemCtrl.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /// #pkgName FGUI包名
  2. /// #panelName UIPanel名字
  3. /// #UIName = $"{#pkgName}{#panelName}" UIKey名字
  4. /// 该脚本由模板创建
  5. /// created by cb 2024
  6. using FL.Data;
  7. using FL.Data.Items;
  8. using FL.Network;
  9. using System;
  10. using System.Collections.Generic;
  11. using XGame.Database;
  12. using XGame.Framework.UI;
  13. using Item = FL.Data.Items.ItemBase;
  14. namespace FL.FGUI
  15. {
  16. /// <summary>
  17. /// UI逻辑处理类
  18. /// </summary>
  19. /// <typeparam name=""></typeparam>
  20. public partial class MailMailPanelItemCtrl : UIController<MailMailPanelItemVM>
  21. {
  22. private MailInfo _mailInfo;
  23. private string _mailId;
  24. private List<IItemBase> _itemDataList;
  25. protected override void OnEnable(object intent)
  26. {
  27. AddUIListenres();
  28. }
  29. protected override void OnDisable()
  30. {
  31. RemoveUIListenres();
  32. }
  33. #region UI事件
  34. private void AddUIListenres()
  35. {
  36. }
  37. private void RemoveUIListenres()
  38. {
  39. }
  40. public void OnRefresh(int index, MailInfo mailInfo)
  41. {
  42. if (_itemDataList == null) _itemDataList = new List<IItemBase>();
  43. _mailInfo = mailInfo;
  44. _mailId = mailInfo.id;
  45. VM.IsGet.selectedIndex = _mailInfo.rts > 0 ? 1 : 0;
  46. VM.HasItem.selectedIndex = _mailInfo.items.Count > 0 ? 1 : 0;
  47. VM.TitleLabel.text = _mailInfo.title;
  48. VM.TimeLabel.text = mailInfo.ets.ToTimeYMDHM(); ;
  49. VM.ContentLabel.text = _mailInfo.items.Count > 0 ? "" : _mailInfo.content;
  50. if (_mailInfo.items.Count > 0)
  51. {
  52. _itemDataList.Clear();
  53. for (int i = 0; i < _mailInfo.items.Count; i++)
  54. {
  55. IItemBase _item = ItemService.Instance.GetItemBase(mailInfo.items[i].id, mailInfo.items[i].count, mailInfo.items[i].kind);
  56. _itemDataList.Add(_item);
  57. }
  58. ShowItemsUI(_itemDataList);
  59. }
  60. }
  61. private void ShowItemsUI(List<IItemBase> dataList)
  62. {
  63. VM.ItemList.BindDatas(dataList);
  64. }
  65. #endregion
  66. }
  67. }