ChargeStoreView.cs 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. 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 OnInit()
  21. {
  22. base.OnInit();
  23. packageName = UI_ChargeUI.PACKAGE_NAME;
  24. _ui = UI_ChargeUI.Create();
  25. this.viewCom = _ui.target;
  26. isfullScreen = true;
  27. this.clickBlankToClose = false;
  28. _ui.m_list.itemRenderer = ListItemRenderer;
  29. }
  30. protected override void AddEventListener()
  31. {
  32. base.AddEventListener();
  33. }
  34. protected override void OnShown()
  35. {
  36. base.OnShown();
  37. _ui.m_list.numItems = RechargeCfgArray.Instance.dataArray.Length;
  38. }
  39. protected override void OnHide()
  40. {
  41. base.OnHide();
  42. }
  43. protected override void RemoveEventListener()
  44. {
  45. base.RemoveEventListener();
  46. }
  47. private void ListItemRenderer(int index, GObject obj)
  48. {
  49. RechargeCfg itemData = RechargeCfgArray.Instance.dataArray[index];
  50. UI_StoreListItem item = UI_StoreListItem.Proxy(obj);
  51. item.m_txtExchangeCount.visible = false;
  52. item.m_btnBuy.m_c1.selectedIndex = 1;
  53. item.m_btnBuy.m_txtTitle.text = itemData.price.ToString();
  54. if (item.target.data == null)
  55. {
  56. item.target.onClick.Add(() =>
  57. {
  58. if (!AntiAddictionController.CheckAntiAddictionRecharge(itemData.price))
  59. {
  60. RechargeSProxy.ReqRecharge(itemData.id).Coroutine();
  61. LogServerHelper.SendPlayParticipationLog((int)PlayParticipationEnum.SHANG_CHENG, 2);
  62. }
  63. });
  64. }
  65. item.target.data = index;
  66. item.m_txtName.text = string.Format("{0}{1}", itemData.itemNum, itemData.name);
  67. item.m_txtDesc.text = string.Format("首充赠送+{0}{1}", itemData.itemNum, itemData.name);
  68. bool isDouble = StoreDataManager.Instance.GetRechargeBuyNumById(itemData.id) < itemData.doubleTimes;
  69. item.m_imgDouble.visible = isDouble;
  70. item.m_txtDesc.visible = isDouble;
  71. item.m_icon.url = "ui://Store/sc_zizhuan_" + itemData.id;
  72. UI_StoreListItem.ProxyEnd();
  73. }
  74. }
  75. }