RechargeStoreView.cs 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. using UI.RechargeStore;
  2. using UI.CommonGame;
  3. using FairyGUI;
  4. namespace GFGGame
  5. {
  6. public class RechargeStoreView : BaseWindow
  7. {
  8. private UI_RechargeStoreUI _ui;
  9. private ValueBarController _valueBarController;
  10. public override void Dispose()
  11. {
  12. _valueBarController.Dispose();
  13. _valueBarController = null;
  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_RechargeStoreUI.PACKAGE_NAME;
  25. _ui = UI_RechargeStoreUI.Create();
  26. this.viewCom = _ui.target;
  27. isfullScreen = true;
  28. _valueBarController = new ValueBarController(_ui.m_valueBar);
  29. _ui.m_btnBack.onClick.Add(OnClickBtnBack);
  30. _ui.m_list.itemRenderer = ListItemRenderer;
  31. _ui.m_comTab.m_c1.onChanged.Add(OnComTabChange);
  32. _ui.m_c1.onChanged.Add(OnTabChange);
  33. }
  34. protected override void OnShown()
  35. {
  36. base.OnShown();
  37. _valueBarController.OnShown();
  38. _ui.m_list.numItems = RechargeCfgArray.Instance.dataArray.Length;
  39. }
  40. protected override void OnHide()
  41. {
  42. base.OnHide();
  43. _valueBarController.OnHide();
  44. }
  45. private void OnClickBtnBack()
  46. {
  47. this.Hide();
  48. }
  49. private void OnComTabChange()
  50. {
  51. _ui.m_c1.selectedIndex = _ui.m_comTab.m_c1.selectedIndex;
  52. }
  53. private void OnTabChange()
  54. {
  55. }
  56. private void ListItemRenderer(int index, GObject obj)
  57. {
  58. RechargeCfg itemData = RechargeCfgArray.Instance.dataArray[index];
  59. UI_StoreListItem item = UI_StoreListItem.Proxy(obj);
  60. item.m_btnBuy.text = itemData.price.ToString();
  61. if (item.m_btnBuy.data == null)
  62. {
  63. item.m_btnBuy.onClick.Add(() =>
  64. {
  65. RechargeSProxy.ReqRecharge(itemData.id).Coroutine();
  66. });
  67. }
  68. item.m_btnBuy.data = index;
  69. item.m_txtName.text = string.Format("{0}{1}", itemData.itemNum, itemData.name);
  70. item.m_txtDesc.text = string.Format("首冲赠送+{0}{1}", itemData.itemNum, itemData.name);
  71. item.m_imgDouble.visible = false;
  72. item.m_txtDesc.visible = false;
  73. item.m_icon.url = "ui://RechargeStore/sc_zizhuan_" + itemData.id;
  74. UI_StoreListItem.ProxyEnd();
  75. }
  76. }
  77. }