Browse Source

直购弹窗修改

zhangyuqian 1 year ago
parent
commit
4d0c7d29f6

+ 18 - 3
GameClient/Assets/Game/HotUpdate/Views/ActivityMainTips/ZGTHgiftDCTipsView.cs

@@ -51,13 +51,13 @@ namespace GFGGame
         protected override void AddEventListener()
         {
             base.AddEventListener();
-            EventAgent.AddEventListener(ConstMessage.NUMERIC_CHANGE, OnNumericChange);
+            EventAgent.AddEventListener(ConstMessage.SHOP_BUY, UpdateBtn);
         }
 
         protected override void RemoveEventListener()
         {
             base.RemoveEventListener();
-            EventAgent.RemoveEventListener(ConstMessage.NUMERIC_CHANGE, OnNumericChange);
+            EventAgent.RemoveEventListener(ConstMessage.SHOP_BUY, UpdateBtn);
         }
 
         protected override void OnShown()
@@ -92,7 +92,22 @@ namespace GFGGame
         {
             //修改直购逻辑,根据时间判断传入不用的直购id,是折扣还是现价
             await ReqShopBuy(giftShopId);
-            _ui.m_btnCharge.visible = false;
+        }
+        private void UpdateBtn()
+        {
+            ShopCfg shopCfg = ShopCfgArray.Instance.GetCfg(giftShopId); 
+            var remainBuyNum = shopCfg.maxBuyNum - ShopDataManager.Instance.GetGoodsBuyNumById(shopCfg.id);
+            if (remainBuyNum == 0)
+            {
+                //已售完
+                _ui.m_btnCharge.visible = false;
+            }
+            else
+            {
+                //未售完
+                _ui.m_btnCharge.visible = true;
+            }
+
         }
         private void OnClickTips()
         {

+ 16 - 3
GameClient/Assets/Game/HotUpdate/Views/ActivityMainTips/ZGTHgiftTipsView.cs

@@ -13,6 +13,7 @@ namespace GFGGame
         private int giftItemId = 0;
         private ItemCfg itemcfg;
         private int shopId = 0;
+        private ShopCfg shopCfg;
         public override void Dispose()
         {
 
@@ -45,19 +46,20 @@ namespace GFGGame
         protected override void AddEventListener()
         {
             base.AddEventListener();
-
+            EventAgent.AddEventListener(ConstMessage.SHOP_BUY, UpdateBtn);
         }
 
         protected override void RemoveEventListener()
         {
             base.RemoveEventListener();
+            EventAgent.RemoveEventListener(ConstMessage.SHOP_BUY, UpdateBtn);
         }
 
         protected override void OnShown()
         {
             base.OnShown();
             
-            ShopCfg shopCfg = ShopCfgArray.Instance.GetCfg(ActivityOpenCfgArray.Instance.GetCfg(6002).paramsArr[0]);
+            shopCfg = ShopCfgArray.Instance.GetCfg(ActivityOpenCfgArray.Instance.GetCfg(6002).paramsArr[0]);
             giftItemId = shopCfg.itemId;
             shopId = shopCfg.id;
             itemcfg = ItemCfgArray.Instance.GetCfg(giftItemId);
@@ -111,7 +113,18 @@ namespace GFGGame
         }
         private void UpdateBtn()
         {
-            _ui.m_btnBuy.visible = false;
+            var remainBuyNum = shopCfg.maxBuyNum - ShopDataManager.Instance.GetGoodsBuyNumById(shopCfg.id);
+            if (remainBuyNum == 0)
+            {
+                //已售完
+                _ui.m_btnBuy.visible = false;
+            }
+            else
+            {
+                //未售完
+                _ui.m_btnBuy.visible = true;
+            }
+            
         }
         private void OnClickTips()
         {