ChargeStoreView.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 ChargeStoreView : BaseWindow
  9. {
  10. private UI_ChargeStoreUI _ui;
  11. private List<ShopCfg> _shopCfgs;
  12. public override void Dispose()
  13. {
  14. if (_ui != null)
  15. {
  16. _ui.Dispose();
  17. }
  18. _ui = null;
  19. base.Dispose();
  20. }
  21. protected override void OnInit()
  22. {
  23. base.OnInit();
  24. packageName = UI_ChargeStoreUI.PACKAGE_NAME;
  25. _ui = UI_ChargeStoreUI.Create();
  26. this.viewCom = _ui.target;
  27. isfullScreen = true;
  28. this.clickBlankToClose = false;
  29. _ui.m_list.itemRenderer = ListItemRenderer;
  30. }
  31. protected override void AddEventListener()
  32. {
  33. base.AddEventListener();
  34. EventAgent.AddEventListener(ConstMessage.NUMERIC_CHANGE, UpdateVipProgressCom);
  35. }
  36. protected override void OnShown()
  37. {
  38. base.OnShown();
  39. _shopCfgs = ShopCfgArray.Instance.GetCfgsBymenu1Andmenu2(ConstStoreTabId.STORE_CHARGE, ConstStoreSubId.STORE_CHARGE);
  40. _ui.m_list.numItems = _shopCfgs.Count;
  41. UpdateVipProgressCom();
  42. }
  43. private void UpdateVipProgressCom()
  44. {
  45. ShopViewManager.Instance.UpdateVipProgressCom(_ui.m_comVipLv.target);
  46. }
  47. protected override void OnHide()
  48. {
  49. base.OnHide();
  50. }
  51. protected override void RemoveEventListener()
  52. {
  53. base.RemoveEventListener();
  54. EventAgent.RemoveEventListener(ConstMessage.NUMERIC_CHANGE, UpdateVipProgressCom);
  55. }
  56. private void ListItemRenderer(int index, GObject obj)
  57. {
  58. ShopCfg itemData = _shopCfgs[index];
  59. UI_ListChargeItem item = UI_ListChargeItem.Proxy(obj);
  60. item.m_btnBuy.m_c1.selectedIndex = 1;
  61. item.m_btnBuy.m_txtTitle.text = itemData.price.ToString();
  62. if (item.target.data == null)
  63. {
  64. item.target.onClick.Add(OnClickBtnBuy);
  65. // item.target.onClick.Add(() =>
  66. // {
  67. // if (!AntiAddictionController.CheckAntiAddictionRecharge(itemData.price))
  68. // {
  69. // RechargeSProxy.ReqRecharge(itemData.id).Coroutine();
  70. // LogServerHelper.SendPlayParticipationLog((int)PlayParticipationEnum.SHANG_CHENG, 2);
  71. // }
  72. // });
  73. }
  74. item.target.data = index;
  75. item.m_txtName.text = string.Format("{0}{1}", itemData.itemNum, itemData.itemName);
  76. item.m_txtDesc.text = string.Format("首充赠送+{0}{1}", itemData.itemNum, itemData.itemName);
  77. bool isDouble = ShopDataManager.Instance.GetRechargeBuyNumById(itemData.id) < itemData.doubleTimes;
  78. item.m_imgDouble.visible = isDouble;
  79. item.m_txtDesc.visible = isDouble;
  80. item.m_icon.url = "ui://Store/sc_zizhuan_" + (index + 1);
  81. UI_ListChargeItem.ProxyEnd();
  82. }
  83. private void OnClickBtnBuy(EventContext context)
  84. {
  85. GObject obj = context.sender as GObject;
  86. int index = (int)obj.data;
  87. ShopCfg itemData = _shopCfgs[index];
  88. if (!AntiAddictionController.CheckAntiAddictionRecharge(itemData.price))
  89. {
  90. RechargeSProxy.ReqRecharge(itemData.id).Coroutine();
  91. LogServerHelper.SendPlayParticipationLog((int)PlayParticipationEnum.SHANG_CHENG, 2);
  92. }
  93. }
  94. }
  95. }