1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- using UI.Store;
- using UI.CommonGame;
- using FairyGUI;
- using System.Collections.Generic;
- using ET;
- namespace GFGGame
- {
- public class StoreChargeView : BaseWindow
- {
- private UI_StoreChargeUI _ui;
- private List<ShopCfg> _shopCfgs;
- public override void Dispose()
- {
- if (_ui != null)
- {
- _ui.Dispose();
- }
- _ui = null;
- base.Dispose();
- }
- protected override void OnInit()
- {
- base.OnInit();
- packageName = UI_StoreChargeUI.PACKAGE_NAME;
- _ui = UI_StoreChargeUI.Create();
- this.viewCom = _ui.target;
- isfullScreen = true;
- this.clickBlankToClose = false;
- _ui.m_list.itemRenderer = ListItemRenderer;
- }
- protected override void AddEventListener()
- {
- base.AddEventListener();
- EventAgent.AddEventListener(ConstMessage.NUMERIC_CHANGE, UpdateVipProgressCom);
- }
- protected override void OnShown()
- {
- base.OnShown();
- _shopCfgs = ShopCfgArray.Instance.GetCfgsBymenu1Andmenu2(ConstStoreTabId.STORE_CHARGE, ConstStoreSubId.STORE_CHARGE);
- _ui.m_list.numItems = _shopCfgs.Count;
- UpdateVipProgressCom();
- }
- private void UpdateVipProgressCom()
- {
- ShopViewManager.Instance.UpdateVipProgressCom(_ui.m_comVipLv.target);
- }
- protected override void OnHide()
- {
- base.OnHide();
- }
- protected override void RemoveEventListener()
- {
- base.RemoveEventListener();
- EventAgent.RemoveEventListener(ConstMessage.NUMERIC_CHANGE, UpdateVipProgressCom);
- }
- private void ListItemRenderer(int index, GObject obj)
- {
- ShopCfg shopCfg = _shopCfgs[index];
- UI_ListChargeItem item = UI_ListChargeItem.Proxy(obj);
- item.m_btnBuy.m_c1.selectedIndex = 1;
- item.m_btnBuy.m_txtTitle.text = shopCfg.price.ToString();
- if (item.target.data == null)
- {
- item.target.onClick.Add(OnClickBtnBuy);
- }
- item.target.data = index;
- item.m_txtName.text = string.Format("{0}{1}", shopCfg.itemNum, shopCfg.itemName);
- item.m_txtDesc.text = string.Format("首充赠送+{0}{1}", shopCfg.itemNum, shopCfg.itemName);
- bool isDouble = ShopDataManager.Instance.GetGoodsBuyNumById(shopCfg.id) < shopCfg.doubleTimes;
- item.m_imgDouble.visible = isDouble;
- item.m_txtDesc.visible = isDouble;
- item.m_icon.url = "ui://Store/sc_zizhuan_" + (index + 1);
- UI_ListChargeItem.ProxyEnd();
- }
- private void OnClickBtnBuy(EventContext context)
- {
- GObject obj = context.sender as GObject;
- int index = (int)obj.data;
- ShopCfg itemData = _shopCfgs[index];
- if (!AntiAddictionController.CheckAntiAddictionRecharge(itemData.price))
- {
- // RechargeSProxy.ReqRecharge(itemData.id).Coroutine();
- ShopSProxy.ReqShopBuy(itemData.id, 1).Coroutine();
- LogServerHelper.SendPlayParticipationLog((int)PlayParticipationEnum.SHANG_CHENG, 2);
- }
- }
- }
- }
|