StoreChargeView.cs 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 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_StoreChargeUI.PACKAGE_NAME;
  25. _ui = UI_StoreChargeUI.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 shopCfg = _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 = shopCfg.price.ToString();
  62. if (item.target.data == null)
  63. {
  64. item.target.onClick.Add(OnClickBtnBuy);
  65. }
  66. item.target.data = index;
  67. item.m_txtName.text = string.Format("{0}{1}", shopCfg.itemNum, shopCfg.itemName);
  68. item.m_txtDesc.text = string.Format("首充赠送+{0}{1}", shopCfg.itemNum, shopCfg.itemName);
  69. bool isDouble = ShopDataManager.Instance.GetGoodsBuyNumById(shopCfg.id) < shopCfg.doubleTimes;
  70. item.m_imgDouble.visible = isDouble;
  71. item.m_txtDesc.visible = isDouble;
  72. item.m_icon.url = "ui://Store/sc_zizhuan_" + (index + 1);
  73. UI_ListChargeItem.ProxyEnd();
  74. }
  75. private void OnClickBtnBuy(EventContext context)
  76. {
  77. GObject obj = context.sender as GObject;
  78. int index = (int)obj.data;
  79. ShopCfg itemData = _shopCfgs[index];
  80. if (!AntiAddictionController.CheckAntiAddictionRecharge(itemData.price))
  81. {
  82. // RechargeSProxy.ReqRecharge(itemData.id).Coroutine();
  83. ShopSProxy.ReqShopBuy(itemData.id, 1).Coroutine();
  84. LogServerHelper.SendPlayParticipationLog((int)PlayParticipationEnum.SHANG_CHENG, 2);
  85. }
  86. }
  87. }
  88. }