using System.Threading.Tasks; using ET; using FairyGUI; using UI.Store; namespace GFGGame { public class WeekGiftView : BaseWindow { private UI_WeekGiftUI _ui; private int _vipLv; public override void Dispose() { if (_ui != null) { _ui.Dispose(); } _ui = null; base.Dispose(); } protected override void OnHide() { base.OnHide(); } protected override void OnInit() { base.OnInit(); packageName = UI_WeekGiftUI.PACKAGE_NAME; _ui = UI_WeekGiftUI.Create(); this.viewCom = _ui.target; this.viewCom.Center(); this.modal = true; _ui.m_listWeekGiftBag.itemRenderer = ListRewardItemRender; _ui.m_btnGetWeekGiftBag.onClick.Add(OnBtnGetWeekGiftBagClick); } protected override void OnShown() { base.OnShown(); _vipLv = (int)this.viewData; VipCfg vipCfg = VipCfgArray.Instance.dataArray[_vipLv]; _ui.m_txtWeekGiftBag.SetVar("value", vipCfg.id.ToString()).FlushVars(); _ui.m_listWeekGiftBag.data = vipCfg.bonusWeekArr; _ui.m_listWeekGiftBag.numItems = vipCfg.bonusWeekArr.Length; } private void ListRewardItemRender(int index, GObject obj) { int[][] rewards = (int[][])obj.parent.data; if (obj.data == null) { obj.data = new ItemView(obj as GComponent); } ItemData itemData = ItemUtil.createItemData(rewards[index]); (obj.data as ItemView).SetData(itemData); (obj.data as ItemView).ChangeTxtCountStyle(); } private void OnBtnGetWeekGiftBagClick(EventContext context) { if (GameGlobal.myNumericComponent.GetAsInt(NumericType.VipWeekGetStatus) == 1) { PromptController.Instance.ShowFloatTextPrompt("会员每周礼包已领取"); return; } if (RoleDataManager.vipLv < _vipLv) { PromptController.Instance.ShowFloatTextPrompt("会员等级不足"); return; } AlertUI.Show("提升VIP等级能领取更高级的礼包,是否继续领取当前等级的VIP礼包?", "(该礼包每周只能领取1次)") .SetLeftButton(true, "否").SetRightButton(true, "是", async (object data) => { ViewManager.Hide(); bool result = await ShopSProxy.ReqGetVipWeekGiftBag(_vipLv); if (result){ } }); } } }