WeekGiftView.cs 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. using System.Collections.Generic;
  2. using System.Threading.Tasks;
  3. using cfg.GfgCfg;
  4. using ET;
  5. using FairyGUI;
  6. using UI.Store;
  7. namespace GFGGame
  8. {
  9. public class WeekGiftView : BaseWindow
  10. {
  11. private UI_WeekGiftUI _ui;
  12. private int _vipLv;
  13. public override void Dispose()
  14. {
  15. if (_ui != null)
  16. {
  17. _ui.Dispose();
  18. }
  19. _ui = null;
  20. base.Dispose();
  21. }
  22. protected override void OnHide()
  23. {
  24. base.OnHide();
  25. }
  26. protected override void OnInit()
  27. {
  28. base.OnInit();
  29. packageName = UI_WeekGiftUI.PACKAGE_NAME;
  30. _ui = UI_WeekGiftUI.Create();
  31. this.viewCom = _ui.target;
  32. this.viewCom.Center();
  33. this.modal = true;
  34. _ui.m_listWeekGiftBag.itemRenderer = ListRewardItemRender;
  35. _ui.m_btnGetWeekGiftBag.onClick.Add(OnBtnGetWeekGiftBagClick);
  36. }
  37. protected override void OnShown()
  38. {
  39. base.OnShown();
  40. _vipLv = (int)this.viewData;
  41. VipCfg vipCfg = CommonDataManager.Tables.TblVipCfg.DataList[_vipLv];
  42. _ui.m_txtWeekGiftBag.SetVar("value", vipCfg.Id.ToString()).FlushVars();
  43. _ui.m_listWeekGiftBag.data = vipCfg.BonusWeek.ToGfgGameItemParam();
  44. _ui.m_listWeekGiftBag.numItems = vipCfg.BonusWeek.Count;
  45. }
  46. private void ListRewardItemRender(int index, GObject obj)
  47. {
  48. List<ItemParamProto> rewards = (List<ItemParamProto>)obj.parent.data;
  49. if (obj.data == null)
  50. {
  51. obj.data = new ItemView(obj as GComponent);
  52. }
  53. ItemData itemData = ItemUtil.createItemData(rewards[index]);
  54. (obj.data as ItemView).SetData(itemData);
  55. (obj.data as ItemView).ChangeTxtCountStyle();
  56. }
  57. private void OnBtnGetWeekGiftBagClick(EventContext context)
  58. {
  59. if (GameGlobal.myNumericComponent.GetAsInt(NumericType.VipWeekGetStatus) == 1)
  60. {
  61. PromptController.Instance.ShowFloatTextPrompt("会员每周礼包已领取");
  62. return;
  63. }
  64. if (RoleDataManager.vipLv < _vipLv)
  65. {
  66. PromptController.Instance.ShowFloatTextPrompt("会员等级不足");
  67. return;
  68. }
  69. //AlertUI.Show("提升VIP等级能领取更高级的礼包,是否继续领取当前等级的VIP礼包?", "(该礼包每周只能领取1次)")
  70. // .SetLeftButton(true, "否").SetRightButton(true, "是", async (object data) =>
  71. // {
  72. GetVipWeekGiftBag();
  73. //});
  74. }
  75. private async void GetVipWeekGiftBag()
  76. {
  77. ViewManager.Hide<WeekGiftView>();
  78. bool result = await ShopSProxy.ReqGetVipWeekGiftBag(_vipLv);
  79. if (result)
  80. {
  81. }
  82. }
  83. }
  84. }