MailMailPanelItemCtrl.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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.Collections.Generic;
  10. using XGame.Framework.UI;
  11. namespace FL.FGUI
  12. {
  13. /// <summary>
  14. /// UI逻辑处理类
  15. /// </summary>
  16. /// <typeparam name=""></typeparam>
  17. public partial class MailMailPanelItemCtrl : UIController<MailMailPanelItemVM>
  18. {
  19. private MailInfo _mailInfo;
  20. private string _mailId;
  21. private List<IItemBase> _itemDataList;
  22. protected override void OnEnable(object intent)
  23. {
  24. AddUIListenres();
  25. }
  26. protected override void OnDisable()
  27. {
  28. RemoveUIListenres();
  29. }
  30. #region UI事件
  31. private void AddUIListenres()
  32. {
  33. }
  34. private void RemoveUIListenres()
  35. {
  36. }
  37. public void OnRefresh(int index, MailInfo mailInfo)
  38. {
  39. if (_itemDataList == null) _itemDataList = new List<IItemBase>();
  40. _mailInfo = mailInfo;
  41. _mailId = mailInfo.id;
  42. VM.IsGet.selectedIndex = _mailInfo.rts > 0 ? 1 : 0;
  43. VM.HasItem.selectedIndex = _mailInfo.items.Count > 0 ? 1 : 0;
  44. VM.TitleLabel.text = _mailInfo.title;
  45. VM.TimeLabel.text = mailInfo.ets.ToTimeYMDHM(); ;
  46. VM.ContentLabel.text = _mailInfo.items.Count > 0 ? "" : _mailInfo.content;
  47. if (_mailInfo.items.Count > 0)
  48. {
  49. _itemDataList.Clear();
  50. for (int i = 0; i < _mailInfo.items.Count; i++)
  51. {
  52. IItemBase _item = ItemService.Instance.GetItemBase(mailInfo.items[i].id, mailInfo.items[i].count, mailInfo.items[i].kind);
  53. _itemDataList.Add(_item);
  54. }
  55. ShowItemsUI(_itemDataList);
  56. }
  57. }
  58. private void ShowItemsUI(List<IItemBase> dataList)
  59. {
  60. VM.ItemList.BindDatas(dataList);
  61. }
  62. #endregion
  63. }
  64. }