StoreChargeView.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. using UI.Store;
  2. using UI.CommonGame;
  3. using FairyGUI;
  4. using System.Collections.Generic;
  5. using ET;
  6. namespace GFGGame
  7. {
  8. public class StoreChargeView : BaseWindow
  9. {
  10. private UI_StoreChargeUI _ui;
  11. private ValueBarController _valueBarController;
  12. private List<ShopCfg> _shopCfgs;
  13. public override void Dispose()
  14. {
  15. if (_valueBarController != null)
  16. {
  17. _valueBarController.Dispose();
  18. _valueBarController = null;
  19. }
  20. if (_ui != null)
  21. {
  22. _ui.Dispose();
  23. }
  24. _ui = null;
  25. base.Dispose();
  26. }
  27. protected override void OnInit()
  28. {
  29. base.OnInit();
  30. packageName = UI_StoreChargeUI.PACKAGE_NAME;
  31. _ui = UI_StoreChargeUI.Create();
  32. this.viewCom = _ui.target;
  33. isfullScreen = true;
  34. this.clickBlankToClose = false;
  35. this.bringToFontOnClick = false;
  36. _ui.m_list.itemRenderer = ListItemRenderer;
  37. _valueBarController = new ValueBarController(_ui.m_valueBar);
  38. }
  39. protected override void AddEventListener()
  40. {
  41. base.AddEventListener();
  42. EventAgent.AddEventListener(ConstMessage.SHOP_BUY, UpdateView);
  43. }
  44. protected override void OnShown()
  45. {
  46. base.OnShown();
  47. _shopCfgs = ShopCfgArray.Instance.GetCfgsBymenu1Andmenu2(ConstStoreTabId.STORE_CHARGE, ConstStoreSubId.STORE_CHARGE);
  48. _valueBarController.OnShown();
  49. _ui.m_comVipLv.m_loaIcon.url = ResPathUtil.GetIconPath("tb_yajizijin", "png");
  50. UpdateView();
  51. }
  52. private void UpdateView()
  53. {
  54. _ui.m_list.numItems = _shopCfgs.Count;
  55. ShopViewManager.Instance.UpdateVipProgressCom(_ui.m_comVipLv.target);
  56. }
  57. protected override void OnHide()
  58. {
  59. base.OnHide();
  60. _valueBarController.OnHide();
  61. }
  62. protected override void RemoveEventListener()
  63. {
  64. base.RemoveEventListener();
  65. EventAgent.RemoveEventListener(ConstMessage.SHOP_BUY, UpdateView);
  66. }
  67. private void ListItemRenderer(int index, GObject obj)
  68. {
  69. ShopCfg shopCfg = _shopCfgs[index];
  70. UI_ListChargeItem item = UI_ListChargeItem.Proxy(obj);
  71. item.m_btnBuy.m_c1.selectedIndex = 1;
  72. item.m_btnBuy.m_txtTitle.text = shopCfg.price.ToString();
  73. if (item.target.data == null)
  74. {
  75. item.target.onClick.Add(OnClickBtnBuy);
  76. }
  77. item.target.data = index;
  78. ItemCfg doubleItem = ItemCfgArray.Instance.GetCfg(shopCfg.doubleItemId);
  79. item.m_txtName.text = string.Format("{0}{1}", shopCfg.itemNum, doubleItem.name);
  80. item.m_txtDesc.text = string.Format("首充赠送+{0}{1}", shopCfg.itemNum, doubleItem.name);
  81. bool isDouble = ShopDataManager.Instance.GetGoodsBuyNumById(shopCfg.id) < shopCfg.doubleTimes;
  82. item.m_grpDouble.visible = isDouble;
  83. item.m_txtDesc.visible = isDouble;
  84. item.m_icon.url = "ui://Store/sc_zizhuan_" + (index + 1);
  85. UI_ListChargeItem.ProxyEnd();
  86. }
  87. private void OnClickBtnBuy(EventContext context)
  88. {
  89. GObject obj = context.sender as GObject;
  90. int index = (int)obj.data;
  91. ShopCfg itemData = _shopCfgs[index];
  92. if (!AntiAddictionController.CheckAntiAddictionRecharge(itemData.price))
  93. {
  94. ShopSProxy.ReqShopBuy(itemData.id, 1).Coroutine();
  95. LogServerHelper.SendPlayParticipationLog((int)PlayParticipationEnum.SHANG_CHENG, 2);
  96. }
  97. }
  98. }
  99. }