ChargeStoreView.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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_ChargeUI _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_ChargeUI.PACKAGE_NAME;
  25. _ui = UI_ChargeUI.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. }
  35. protected override void OnShown()
  36. {
  37. base.OnShown();
  38. _shopCfgs = ShopCfgArray.Instance.GetCfgsBymenu1Andmenu2(ConstStoreTabId.STORE_CHARGE, ConstStoreSubId.STORE_CHARGE);
  39. _ui.m_list.numItems = _shopCfgs.Count;
  40. }
  41. protected override void OnHide()
  42. {
  43. base.OnHide();
  44. }
  45. protected override void RemoveEventListener()
  46. {
  47. base.RemoveEventListener();
  48. }
  49. private void ListItemRenderer(int index, GObject obj)
  50. {
  51. ShopCfg itemData = _shopCfgs[index];
  52. UI_ListChargeItem item = UI_ListChargeItem.Proxy(obj);
  53. item.m_btnBuy.m_c1.selectedIndex = 1;
  54. item.m_btnBuy.m_txtTitle.text = itemData.price.ToString();
  55. if (item.target.data == null)
  56. {
  57. item.target.onClick.Add(OnClickBtnBuy);
  58. // item.target.onClick.Add(() =>
  59. // {
  60. // if (!AntiAddictionController.CheckAntiAddictionRecharge(itemData.price))
  61. // {
  62. // RechargeSProxy.ReqRecharge(itemData.id).Coroutine();
  63. // LogServerHelper.SendPlayParticipationLog((int)PlayParticipationEnum.SHANG_CHENG, 2);
  64. // }
  65. // });
  66. }
  67. item.target.data = index;
  68. item.m_txtName.text = string.Format("{0}{1}", itemData.itemNum, itemData.itemName);
  69. item.m_txtDesc.text = string.Format("首充赠送+{0}{1}", itemData.itemNum, itemData.itemName);
  70. bool isDouble = ShopDataManager.Instance.GetRechargeBuyNumById(itemData.id) < itemData.doubleTimes;
  71. item.m_imgDouble.visible = isDouble;
  72. item.m_txtDesc.visible = isDouble;
  73. item.m_icon.url = "ui://Store/sc_zizhuan_" + (index + 1);
  74. UI_ListChargeItem.ProxyEnd();
  75. }
  76. private void OnClickBtnBuy(EventContext context)
  77. {
  78. GObject obj = context.sender as GObject;
  79. int index = (int)obj.data;
  80. ShopCfg itemData = _shopCfgs[index];
  81. if (!AntiAddictionController.CheckAntiAddictionRecharge(itemData.price))
  82. {
  83. RechargeSProxy.ReqRecharge(itemData.id).Coroutine();
  84. LogServerHelper.SendPlayParticipationLog((int)PlayParticipationEnum.SHANG_CHENG, 2);
  85. }
  86. }
  87. }
  88. }