|
@@ -0,0 +1,172 @@
|
|
|
+using UI.Store;
|
|
|
+using UI.CommonGame;
|
|
|
+using FairyGUI;
|
|
|
+using System.Collections.Generic;
|
|
|
+using ET;
|
|
|
+using System;
|
|
|
+
|
|
|
+namespace GFGGame
|
|
|
+{
|
|
|
+ public class StoreMonthView : BaseWindow
|
|
|
+ {
|
|
|
+ private UI_StoreMonthUI _ui;
|
|
|
+ private ValueBarController _valueBarController;
|
|
|
+ private List<ShopCfg> _shopCfgs;
|
|
|
+
|
|
|
+ public override void Dispose()
|
|
|
+ {
|
|
|
+ if (_valueBarController != null)
|
|
|
+ {
|
|
|
+ _valueBarController.Dispose();
|
|
|
+ _valueBarController = null;
|
|
|
+ }
|
|
|
+ if (_ui != null)
|
|
|
+ {
|
|
|
+ _ui.Dispose();
|
|
|
+ }
|
|
|
+ _ui = null;
|
|
|
+ base.Dispose();
|
|
|
+ }
|
|
|
+
|
|
|
+ protected override void OnInit()
|
|
|
+ {
|
|
|
+ base.OnInit();
|
|
|
+ packageName = UI_StoreMonthUI.PACKAGE_NAME;
|
|
|
+ _ui = UI_StoreMonthUI.Create();
|
|
|
+ this.viewCom = _ui.target;
|
|
|
+ isfullScreen = true;
|
|
|
+ this.clickBlankToClose = false;
|
|
|
+
|
|
|
+ _valueBarController = new ValueBarController(_ui.m_valueBar);
|
|
|
+ _ui.m_list.itemRenderer = ListItemRenderer;
|
|
|
+ _ui.m_btnBuy.target.onClick.Add(OnBtnBuyCardClick);
|
|
|
+ _ui.m_btnGet.onClick.Add(OnBtnGetClick);
|
|
|
+ }
|
|
|
+ protected override void AddEventListener()
|
|
|
+ {
|
|
|
+ base.AddEventListener();
|
|
|
+
|
|
|
+ }
|
|
|
+ protected override void OnShown()
|
|
|
+ {
|
|
|
+ base.OnShown();
|
|
|
+
|
|
|
+ _valueBarController.OnShown();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ protected override void OnHide()
|
|
|
+ {
|
|
|
+ base.OnHide();
|
|
|
+ _valueBarController.OnHide();
|
|
|
+ }
|
|
|
+ protected override void RemoveEventListener()
|
|
|
+ {
|
|
|
+ base.RemoveEventListener();
|
|
|
+ }
|
|
|
+ private void UpdateView()
|
|
|
+ {
|
|
|
+ int menu2 = (int)this.viewData;
|
|
|
+ _shopCfgs = ShopCfgArray.Instance.GetCfgsBymenu1Andmenu2(ConstStoreTabId.STORE_MONTH_CARD, menu2);
|
|
|
+ _ui.m_list.numItems = _shopCfgs.Count;
|
|
|
+
|
|
|
+ MonthlyCardPrivilegeCfg privilegeCfg = MonthlyCardPrivilegeCfgArray.Instance.GetCfg(MonthCardPrivilegeType.Privilege1);
|
|
|
+
|
|
|
+ string iconUrl = "";
|
|
|
+ bool isFirstBuy = false;
|
|
|
+ bool isGot = false;
|
|
|
+ long endTime = 0;
|
|
|
+ int privilegeCount = 0;
|
|
|
+ MonthlyCardCfg monthCfg = null;
|
|
|
+ switch (menu2)
|
|
|
+ {
|
|
|
+ case ConstStoreSubId.STORE_MONTH_GLOAD_CARD:
|
|
|
+ iconUrl = "ui://Store/MonthCard_Icon";
|
|
|
+ monthCfg = MonthlyCardCfgArray.Instance.GetCfg(MonthCardType.Gold);
|
|
|
+ isFirstBuy = GameGlobal.myNumericComponent.GetAsInt(NumericType.MonthCardGoldFirstBuy) <= 0;
|
|
|
+ endTime = GameGlobal.myNumericComponent.GetAsInt(NumericType.MonthCardGoldEndTime);
|
|
|
+ isGot = GameGlobal.myNumericComponent.GetAsInt(NumericType.MonthCardGoldReward) > 0;
|
|
|
+ for (int i = 0; i < MonthlyCardPrivilegeCfgArray.Instance.dataArray.Length; i++)
|
|
|
+ {
|
|
|
+ if (MonthlyCardPrivilegeCfgArray.Instance.dataArray[i].value1Arr[0] > 0)
|
|
|
+ {
|
|
|
+ privilegeCount++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ _ui.m_txtMoneyCount.text = privilegeCfg.value1Arr[0].ToString();
|
|
|
+ _ui.m_txtDailyMoneyCount.text = privilegeCfg.value1Arr[1].ToString();
|
|
|
+ break;
|
|
|
+ case ConstStoreSubId.STORE_MONTH_BLACK_CARD:
|
|
|
+ iconUrl = "ui://Store/MonthCard_Icon";
|
|
|
+ monthCfg = MonthlyCardCfgArray.Instance.GetCfg(MonthCardType.BlackGold);
|
|
|
+ isFirstBuy = GameGlobal.myNumericComponent.GetAsInt(NumericType.MonthCardBlackGoldFirstBuy) <= 0;
|
|
|
+ endTime = GameGlobal.myNumericComponent.GetAsInt(NumericType.MonthCardBlackGoldEndTime);
|
|
|
+ isGot = GameGlobal.myNumericComponent.GetAsInt(NumericType.MonthCardBlackGoldReward) > 0;
|
|
|
+ for (int i = 0; i < MonthlyCardPrivilegeCfgArray.Instance.dataArray.Length; i++)
|
|
|
+ {
|
|
|
+ if (MonthlyCardPrivilegeCfgArray.Instance.dataArray[i].value2Arr[0] > 0)
|
|
|
+ {
|
|
|
+ privilegeCount++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ _ui.m_txtMoneyCount.text = privilegeCfg.value2Arr[0].ToString();
|
|
|
+ _ui.m_txtDailyMoneyCount.text = privilegeCfg.value2Arr[1].ToString();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ long day = TimeUtil.FormattingTime11(TimeHelper.ServerNow(), endTime);
|
|
|
+ _ui.m_txtTime.SetVar("value", day.ToString()).FlushVars();
|
|
|
+ _ui.m_txtTime.visible = endTime > TimeHelper.ServerNow();
|
|
|
+ _ui.m_loaCard.url = iconUrl;
|
|
|
+ ShopCfg shopCfg = ShopCfgArray.Instance.GetCfg(monthCfg.shopId);
|
|
|
+ _ui.m_btnBuy.m_txtOriginalPrice.text = shopCfg.price.ToString();
|
|
|
+ _ui.m_btnBuy.m_grpOriginalPrice.visible = isFirstBuy && shopCfg.oncePrice < shopCfg.price;
|
|
|
+ int price = isFirstBuy ? shopCfg.oncePrice : shopCfg.price;
|
|
|
+ _ui.m_btnBuy.m_txtPrice.text = price.ToString();
|
|
|
+ _ui.m_btnBuy.target.data = "";
|
|
|
+ _ui.m_txtTips.SetVar("value", (price * 10).ToString()).FlushVars();
|
|
|
+ _ui.m_txtTips.SetVar("day", monthCfg.limitDays.ToString()).FlushVars();
|
|
|
+
|
|
|
+ _ui.m_loaMoney.url = ResPathUtil.GetCommonGameResPath(ItemCfgArray.Instance.GetCfg(privilegeCfg.paramsArr[0]).res);
|
|
|
+ _ui.m_loaDailyMoney.url = ResPathUtil.GetCommonGameResPath(ItemCfgArray.Instance.GetCfg(privilegeCfg.paramsArr[0]).res);
|
|
|
+ _ui.m_txtPrivilegeCount.text = privilegeCount.ToString();
|
|
|
+ _ui.m_btnGet.enabled = endTime > TimeHelper.ServerNow() && !isGot;
|
|
|
+ _ui.m_btnGet.text = isGot ? "已领取" : "领取";
|
|
|
+ _ui.m_btnGet.data = monthCfg.type; ;
|
|
|
+ }
|
|
|
+ private void OnBtnBuyCardClick(EventContext context)
|
|
|
+ {
|
|
|
+ GObject obj = context.sender as GObject;
|
|
|
+ int goodsId = (int)obj.data;
|
|
|
+ ShopSProxy.ReqShopBuy(goodsId).Coroutine();
|
|
|
+ }
|
|
|
+ private async void OnBtnGetClick(EventContext context)
|
|
|
+ {
|
|
|
+ GObject obj = context.sender as GObject;
|
|
|
+ int goodsId = (int)obj.data;
|
|
|
+ bool result = await ShopSProxy.ReqGetMonthCardReward(goodsId);
|
|
|
+ if (result)
|
|
|
+ {
|
|
|
+ UpdateView();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private void ListItemRenderer(int index, GObject obj)
|
|
|
+ {
|
|
|
+ ShopCfg shopCfg = _shopCfgs[index];
|
|
|
+ ShopViewManager.Instance.UptadeItem(obj, shopCfg);
|
|
|
+ }
|
|
|
+
|
|
|
+ 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))
|
|
|
+ {
|
|
|
+ ShopSProxy.ReqShopBuy(itemData.id, 1).Coroutine();
|
|
|
+ LogServerHelper.SendPlayParticipationLog((int)PlayParticipationEnum.SHANG_CHENG, 2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|