GiftBagStoreView.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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 GiftBagStoreView : BaseWindow
  9. {
  10. private UI_GiftBagStoreUI _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_GiftBagStoreUI.PACKAGE_NAME;
  25. _ui = UI_GiftBagStoreUI.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. UI_ListShopItem item = UI_ListShopItem.Proxy(obj);
  52. ShopCfg shopCfg = _shopCfgs[index];
  53. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(shopCfg.itemId);
  54. item.m_txtName.text = shopCfg.itemName;
  55. item.m_icon.url = ResPathUtil.GetIconPath(itemCfg); // string.Format("ui://RechargeStore/{0}", cfg.res);
  56. item.m_grpDiscount.visible = shopCfg.price < shopCfg.originalPrice;
  57. item.m_txtDesc.text = ((double)(shopCfg.originalPrice / shopCfg.price) * 100).ToString();
  58. item.m_txtEndTime.SetVar("value", ShopDataManager.Instance.GetEndTime(shopCfg.id)).FlushVars();
  59. item.m_txtEndTime.visible = shopCfg.endTime != "";
  60. item.m_c2.selectedIndex = ShopDataManager.Instance.GetShopGoodsStateById(shopCfg.id) ? 0 : 1;
  61. if (shopCfg.lockType == LockType.STORY_LV)
  62. {
  63. StoryLevelCfg storyLevelCfg = StoryLevelCfgArray.Instance.GetCfg(shopCfg.storyLevelId);
  64. item.m_txtLock.text = string.Format("通关{0}-{1}解锁", StoryUtil.GetChapterOrder(storyLevelCfg.chapterId), storyLevelCfg.order);
  65. }
  66. else if (shopCfg.lockType == LockType.ROLE_LV)
  67. {
  68. item.m_txtLock.text = string.Format("角色达到{0}级解锁", shopCfg.lv);
  69. }
  70. else if (shopCfg.lockType == LockType.MONTH_CARD_TYPE)
  71. {
  72. item.m_txtLock.text = string.Format("开通{0}解锁", shopCfg.MonthlyCardType == MonthCardType.Gold ? "金卡" : "黑金卡");
  73. }
  74. int buyNum = ShopDataManager.Instance.GetGoodsBuyNumById(shopCfg.id);
  75. item.m_txtLimit.text = string.Format("{0}({1}/{2})", ShopDataManager.Instance.refreshType[shopCfg.refreshType], StringUtil.GetColorText(buyNum.ToString(), "#DA8870"), shopCfg.maxBuyNum);
  76. item.m_txtLimit.visible = shopCfg.maxBuyNum > 0;
  77. item.m_c1.selectedIndex = shopCfg.maxBuyNum == 0 || buyNum < shopCfg.maxBuyNum ? 0 : 1;
  78. // if (item.m_c1.selectedIndex == 0)
  79. // {
  80. // item.m_btnBuy.m_txtOriginalPrice.text = NumberUtil.ChangeNumberUnit(shopCfg.originalPrice);// cfg.originalPrice.ToString();
  81. // if (shopCfg.price > 0 && shopCfg.costType != CostType.FREE)
  82. // {
  83. // item.m_btnBuy.m_grpOriginalPrice.visible = shopCfg.originalPrice > 0;
  84. // item.m_btnBuy.m_grpIcon.visible = true;
  85. // item.m_btnBuy.m_txtPrice.text = NumberUtil.ChangeNumberUnit(shopCfg.price);// cfg.price.ToString();
  86. // if (shopCfg.costType == CostType.RMB)
  87. // {
  88. // item.m_btnBuy.m_loaIcon.visible = false;
  89. // item.m_btnBuy.m_txtIcon.visible = true;
  90. // item.m_btnBuy.m_txtIcon.text = "¥";
  91. // }
  92. // else
  93. // {
  94. // ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(shopCfg.costId);
  95. // item.m_btnBuy.m_loaIcon.url = ResPathUtil.GetCommonGameResPath(itemCfg.res);
  96. // item.m_btnBuy.m_loaIcon.visible = true;
  97. // item.m_btnBuy.m_txtIcon.visible = false;
  98. // }
  99. // }
  100. // else
  101. // {
  102. // item.m_btnBuy.m_grpIcon.visible = false;
  103. // item.m_btnBuy.m_grpOriginalPrice.visible = false;
  104. // item.m_btnBuy.m_txtPrice.text = "免费";
  105. // }
  106. // }
  107. // if (item.target.data == null)
  108. // {
  109. // item.target.onClick.Add(OnBtnBuyClick);
  110. // }
  111. // item.target.data = shopCfg.id;
  112. // bool isRed = item.m_c1.selectedIndex == 0 && item.m_c2.selectedIndex == 0 && shopCfg.price == 0;
  113. // RedDotController.Instance.SetComRedDot(item.target, isRed, "", -6, 100);
  114. UI_ListShopItem.ProxyEnd();
  115. }
  116. }
  117. }