using UI.Store; using UI.CommonGame; using FairyGUI; using System.Collections.Generic; using ET; namespace GFGGame { public class GiftBagStoreView : BaseWindow { private UI_GiftBagStoreUI _ui; private List _shopCfgs; public override void Dispose() { if (_ui != null) { _ui.Dispose(); } _ui = null; base.Dispose(); } protected override void OnInit() { base.OnInit(); packageName = UI_GiftBagStoreUI.PACKAGE_NAME; _ui = UI_GiftBagStoreUI.Create(); this.viewCom = _ui.target; isfullScreen = true; this.clickBlankToClose = false; _ui.m_list.itemRenderer = ListItemRenderer; } protected override void AddEventListener() { base.AddEventListener(); } protected override void OnShown() { base.OnShown(); _shopCfgs = ShopCfgArray.Instance.GetCfgsBymenu1Andmenu2(ConstStoreTabId.STORE_CHARGE, ConstStoreSubId.STORE_CHARGE); _ui.m_list.numItems = _shopCfgs.Count; } protected override void OnHide() { base.OnHide(); } protected override void RemoveEventListener() { base.RemoveEventListener(); } private void ListItemRenderer(int index, GObject obj) { UI_ListShopItem item = UI_ListShopItem.Proxy(obj); ShopCfg shopCfg = _shopCfgs[index]; ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(shopCfg.itemId); item.m_txtName.text = shopCfg.itemName; item.m_icon.url = ResPathUtil.GetIconPath(itemCfg); // string.Format("ui://RechargeStore/{0}", cfg.res); item.m_grpDiscount.visible = shopCfg.price < shopCfg.originalPrice; item.m_txtDesc.text = ((double)(shopCfg.originalPrice / shopCfg.price) * 100).ToString(); item.m_txtEndTime.SetVar("value", ShopDataManager.Instance.GetEndTime(shopCfg.id)).FlushVars(); item.m_txtEndTime.visible = shopCfg.endTime != ""; item.m_c2.selectedIndex = ShopDataManager.Instance.GetShopGoodsStateById(shopCfg.id) ? 0 : 1; if (shopCfg.lockType == LockType.STORY_LV) { StoryLevelCfg storyLevelCfg = StoryLevelCfgArray.Instance.GetCfg(shopCfg.storyLevelId); item.m_txtLock.text = string.Format("通关{0}-{1}解锁", StoryUtil.GetChapterOrder(storyLevelCfg.chapterId), storyLevelCfg.order); } else if (shopCfg.lockType == LockType.ROLE_LV) { item.m_txtLock.text = string.Format("角色达到{0}级解锁", shopCfg.lv); } else if (shopCfg.lockType == LockType.MONTH_CARD_TYPE) { item.m_txtLock.text = string.Format("开通{0}解锁", shopCfg.MonthlyCardType == MonthCardType.Gold ? "金卡" : "黑金卡"); } int buyNum = ShopDataManager.Instance.GetGoodsBuyNumById(shopCfg.id); item.m_txtLimit.text = string.Format("{0}({1}/{2})", ShopDataManager.Instance.refreshType[shopCfg.refreshType], StringUtil.GetColorText(buyNum.ToString(), "#DA8870"), shopCfg.maxBuyNum); item.m_txtLimit.visible = shopCfg.maxBuyNum > 0; item.m_c1.selectedIndex = shopCfg.maxBuyNum == 0 || buyNum < shopCfg.maxBuyNum ? 0 : 1; // if (item.m_c1.selectedIndex == 0) // { // item.m_btnBuy.m_txtOriginalPrice.text = NumberUtil.ChangeNumberUnit(shopCfg.originalPrice);// cfg.originalPrice.ToString(); // if (shopCfg.price > 0 && shopCfg.costType != CostType.FREE) // { // item.m_btnBuy.m_grpOriginalPrice.visible = shopCfg.originalPrice > 0; // item.m_btnBuy.m_grpIcon.visible = true; // item.m_btnBuy.m_txtPrice.text = NumberUtil.ChangeNumberUnit(shopCfg.price);// cfg.price.ToString(); // if (shopCfg.costType == CostType.RMB) // { // item.m_btnBuy.m_loaIcon.visible = false; // item.m_btnBuy.m_txtIcon.visible = true; // item.m_btnBuy.m_txtIcon.text = "¥"; // } // else // { // ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(shopCfg.costId); // item.m_btnBuy.m_loaIcon.url = ResPathUtil.GetCommonGameResPath(itemCfg.res); // item.m_btnBuy.m_loaIcon.visible = true; // item.m_btnBuy.m_txtIcon.visible = false; // } // } // else // { // item.m_btnBuy.m_grpIcon.visible = false; // item.m_btnBuy.m_grpOriginalPrice.visible = false; // item.m_btnBuy.m_txtPrice.text = "免费"; // } // } // if (item.target.data == null) // { // item.target.onClick.Add(OnBtnBuyClick); // } // item.target.data = shopCfg.id; // bool isRed = item.m_c1.selectedIndex == 0 && item.m_c2.selectedIndex == 0 && shopCfg.price == 0; // RedDotController.Instance.SetComRedDot(item.target, isRed, "", -6, 100); UI_ListShopItem.ProxyEnd(); } } }