WeekGiftView.cs 2.7 KB

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