PartnerEpiPlanLineItemCtrl.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /// #pkgName FGUI包名
  2. /// #panelName UIPanel名字
  3. /// #UIName = $"{#pkgName}{#panelName}" UIKey名字
  4. /// 该脚本由模板创建
  5. /// created by cb 2024
  6. using FairyGUI;
  7. using FL.Data;
  8. using System.Collections.Generic;
  9. using XGame.Framework.UI;
  10. namespace FL.FGUI
  11. {
  12. /// <summary>
  13. /// UI逻辑处理类
  14. /// </summary>
  15. /// <typeparam name=""></typeparam>
  16. public partial class PartnerEpiPlanLineItemCtrl : UIController<PartnerEpiPlanLineItemVM>
  17. {
  18. private int _planId;
  19. protected override void OnEnable(object intent)
  20. {
  21. AddUIListenres();
  22. }
  23. protected override void OnDisable()
  24. {
  25. RemoveUIListenres();
  26. }
  27. #region UI事件
  28. private void AddUIListenres()
  29. {
  30. VM.ChangeLineupPlanBtn.onClick.Add(OnClickChangeLineupPlanBtn);
  31. VM.EditBtn.onClick.Add(OnClickEdit);
  32. }
  33. private void RemoveUIListenres()
  34. {
  35. VM.ChangeLineupPlanBtn.onClick.Remove(OnClickChangeLineupPlanBtn);
  36. VM.EditBtn.onClick.Remove(OnClickEdit);
  37. }
  38. private void OnClickEdit(EventContext context)
  39. {
  40. Context.UI.OpenAsync(UIKeys.PartnerPlanRenamePanel, _planId);
  41. }
  42. private void OnClickChangeLineupPlanBtn(EventContext context)
  43. {
  44. if (_planId == PartnersData.Instance.CurUsePlan.Id)
  45. {
  46. Context.ShowTips(StringDefine.PartnerCurPlanTips);
  47. return;
  48. }
  49. PartnersService.Instance.RequestChangePlan(_planId);
  50. }
  51. #endregion
  52. public void OnRefresh(int index, PartnerPlan plan)
  53. {
  54. VM.ShowLine.selectedIndex = index > 0 ? 0 : 1;
  55. VM.CurPlan.selectedIndex = plan.Id == PartnersData.Instance.UsePlanId ? 1 : 0;
  56. _planId = plan.Id;
  57. VM.NameLabel.text = plan.Name.Length > 0 ? plan.Name : string.Format(StringDefine.partnerInitPlanName, plan.Id);
  58. var dataList = new List<PartnerPlanParam>();
  59. for (int i = 0; i < PartnersData.GoneUpLimit; i++)
  60. {
  61. var param = new PartnerPlanParam()
  62. {
  63. planId = plan.Id,
  64. slotId = i,
  65. };
  66. dataList.Add(param);
  67. }
  68. VM.PartnerList.BindDatas(dataList);
  69. }
  70. }
  71. }