From 23fca8d7bf14ed095d17486d7a16809d2364c4fe Mon Sep 17 00:00:00 2001 From: CloudJ Date: Mon, 29 May 2023 17:15:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=A6=96=E5=85=85=E7=95=8C?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/common/pay_manager.lua | 1 - lua/app/module/shop/shop_manager.lua | 52 +++++---- .../cell/side_bar_beginner_gift_cell.lua | 2 +- .../cell/side_bar_first_recharge_cell.lua | 2 +- .../cell/side_bar_grow_up_gift_1_cell.lua | 2 +- .../cell/side_bar_grow_up_gift_2_cell.lua | 2 +- lua/app/ui/shop/first_recharge_pop_ui.lua | 107 ++++++++++++++++++ .../ui/shop/first_recharge_pop_ui.lua.meta | 10 ++ 8 files changed, 153 insertions(+), 25 deletions(-) create mode 100644 lua/app/ui/shop/first_recharge_pop_ui.lua create mode 100644 lua/app/ui/shop/first_recharge_pop_ui.lua.meta diff --git a/lua/app/common/pay_manager.lua b/lua/app/common/pay_manager.lua index ff78d38d..436f9b98 100644 --- a/lua/app/common/pay_manager.lua +++ b/lua/app/common/pay_manager.lua @@ -103,7 +103,6 @@ function PayManager:getGiftConfigInfo(purchaseType, id) return end local cfg = ConfigManager:getConfig(cfgName) - local cfg = ConfigManager:getConfig(cfgName) if not cfg or not cfg[id] then return end diff --git a/lua/app/module/shop/shop_manager.lua b/lua/app/module/shop/shop_manager.lua index 23bdd846..1ceb87d4 100644 --- a/lua/app/module/shop/shop_manager.lua +++ b/lua/app/module/shop/shop_manager.lua @@ -24,13 +24,17 @@ end -- 触发弹窗礼包 function ShopManager:triggerGiftPopUI(actType, actId) if ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.ACT_GIFT_SHOW_OPEN, true) then - UIManager:showUI("app/ui/shop/gift_pop_ui", {type = actType, id = actId}) + self:showGiftPopUI(actType, actId, false) DataManager.ShopData:removePopUpGift(actType, actId) end end -function ShopManager:showGiftPopUI(actType, actId) - UIManager:showUI("app/ui/shop/gift_pop_ui", {type = actType, id = actId, onlySelf = true}) +function ShopManager:showGiftPopUI(actType, actId, onlySelf) + if actType == PayManager.PURCHARSE_TYPE.ACT_GIFT and actId == GConst.ShopConst.FIRST_RECHARGE_ID then + UIManager:showUI("app/ui/shop/first_recharge_pop_ui") + else + UIManager:showUI("app/ui/shop/gift_pop_ui", {type = actType, id = actId, onlySelf = onlySelf}) + end end -- 触发金币弹窗礼包 @@ -64,23 +68,31 @@ function ShopManager:buyMallDailyGift(id, isAd) end -- 二次弹窗确认 - local isCoin = costs.id == GConst.ItemConst.ITEM_ID_GOLD - local params ={ - titleTx = I18N:getGlobalText(I18N.GlobalConst.SHOP_DESC_31), - content = isCoin and I18N:getGlobalText(I18N.GlobalConst.SHOP_DESC_32) or I18N:getGlobalText(I18N.GlobalConst.SHOP_DESC_33), - boxType = GConst.MESSAGE_BOX_TYPE.MB_OK_CANCEL, - showToday = GConst.MESSAGE_BOX_SHOW_TODAY.HOT_SELL_BUY, - costId = costs.id, - costNum = costs.num, - okFunc = function() - local responseData = { - rewards = rewards, - costs = costs - } - self:sendMessage(ProtoMsgType.FromMsgEnum.BuyMallDailyReq, params, responseData, self.buyMallDailyGiftFinish, BIReport.ITEM_GET_TYPE.MALL_DAILY) - end, - } - GFunc.showMessageBox(params) + if costs then + local isCoin = costs.id == GConst.ItemConst.ITEM_ID_GOLD + local params ={ + titleTx = I18N:getGlobalText(I18N.GlobalConst.SHOP_DESC_31), + content = isCoin and I18N:getGlobalText(I18N.GlobalConst.SHOP_DESC_32) or I18N:getGlobalText(I18N.GlobalConst.SHOP_DESC_33), + boxType = GConst.MESSAGE_BOX_TYPE.MB_OK_CANCEL, + showToday = GConst.MESSAGE_BOX_SHOW_TODAY.HOT_SELL_BUY, + costId = costs.id, + costNum = costs.num, + okFunc = function() + local responseData = { + rewards = rewards, + costs = costs + } + self:sendMessage(ProtoMsgType.FromMsgEnum.BuyMallDailyReq, params, responseData, self.buyMallDailyGiftFinish, BIReport.ITEM_GET_TYPE.MALL_DAILY) + end, + } + GFunc.showMessageBox(params) + else + local responseData = { + rewards = rewards, + costs = costs + } + self:sendMessage(ProtoMsgType.FromMsgEnum.BuyMallDailyReq, params, responseData, self.buyMallDailyGiftFinish, BIReport.ITEM_GET_TYPE.MALL_DAILY) + end end function ShopManager:buyMallDailyGiftFinish(result) diff --git a/lua/app/ui/main_city/cell/side_bar_beginner_gift_cell.lua b/lua/app/ui/main_city/cell/side_bar_beginner_gift_cell.lua index 26ab3ff1..5fcfbc4f 100644 --- a/lua/app/ui/main_city/cell/side_bar_beginner_gift_cell.lua +++ b/lua/app/ui/main_city/cell/side_bar_beginner_gift_cell.lua @@ -10,7 +10,7 @@ function SideBarBeginnerGiftCell:getIconRes() end function SideBarBeginnerGiftCell:onClick() - ModuleManager.ShopManager:showGiftPopUI(PayManager.PURCHARSE_TYPE.ACT_GIFT, GConst.ShopConst.BEGINNER_GIFT_ID) + ModuleManager.ShopManager:showGiftPopUI(PayManager.PURCHARSE_TYPE.ACT_GIFT, GConst.ShopConst.BEGINNER_GIFT_ID, true) end function SideBarBeginnerGiftCell:getIsShowRedPoint() diff --git a/lua/app/ui/main_city/cell/side_bar_first_recharge_cell.lua b/lua/app/ui/main_city/cell/side_bar_first_recharge_cell.lua index 30233d01..c5cf24c9 100644 --- a/lua/app/ui/main_city/cell/side_bar_first_recharge_cell.lua +++ b/lua/app/ui/main_city/cell/side_bar_first_recharge_cell.lua @@ -10,7 +10,7 @@ function SideBarFirstRechargeCell:getIconRes() end function SideBarFirstRechargeCell:onClick() - ModuleManager.ShopManager:showGiftPopUI(PayManager.PURCHARSE_TYPE.ACT_GIFT, GConst.ShopConst.FIRST_RECHARGE_ID) + ModuleManager.ShopManager:showGiftPopUI(PayManager.PURCHARSE_TYPE.ACT_GIFT, GConst.ShopConst.FIRST_RECHARGE_ID, true) end function SideBarFirstRechargeCell:getIsShowRedPoint() diff --git a/lua/app/ui/main_city/cell/side_bar_grow_up_gift_1_cell.lua b/lua/app/ui/main_city/cell/side_bar_grow_up_gift_1_cell.lua index f0e1a329..c8888638 100644 --- a/lua/app/ui/main_city/cell/side_bar_grow_up_gift_1_cell.lua +++ b/lua/app/ui/main_city/cell/side_bar_grow_up_gift_1_cell.lua @@ -12,7 +12,7 @@ end function SideBarGrowUpGift1Cell:onClick() local gift = DataManager.ShopData:getValidGrowUpGifts()[1] if gift then - ModuleManager.ShopManager:showGiftPopUI(PayManager.PURCHARSE_TYPE.GROW_UP_GIFT, gift.current_grow_up_id) + ModuleManager.ShopManager:showGiftPopUI(PayManager.PURCHARSE_TYPE.GROW_UP_GIFT, gift.current_grow_up_id, true) end end diff --git a/lua/app/ui/main_city/cell/side_bar_grow_up_gift_2_cell.lua b/lua/app/ui/main_city/cell/side_bar_grow_up_gift_2_cell.lua index e0edbbcb..2d8fe520 100644 --- a/lua/app/ui/main_city/cell/side_bar_grow_up_gift_2_cell.lua +++ b/lua/app/ui/main_city/cell/side_bar_grow_up_gift_2_cell.lua @@ -12,7 +12,7 @@ end function SideBarGrowUpGift2Cell:onClick() local gift = DataManager.ShopData:getValidGrowUpGifts()[2] if gift then - ModuleManager.ShopManager:showGiftPopUI(PayManager.PURCHARSE_TYPE.GROW_UP_GIFT, gift.current_grow_up_id) + ModuleManager.ShopManager:showGiftPopUI(PayManager.PURCHARSE_TYPE.GROW_UP_GIFT, gift.current_grow_up_id, true) end end diff --git a/lua/app/ui/shop/first_recharge_pop_ui.lua b/lua/app/ui/shop/first_recharge_pop_ui.lua new file mode 100644 index 00000000..ce07fd8b --- /dev/null +++ b/lua/app/ui/shop/first_recharge_pop_ui.lua @@ -0,0 +1,107 @@ +local FirstRechargePopUI = class("FirstRechargePopUI", BaseUI) +local MAX_ITEM_NUM = 3 + +function FirstRechargePopUI:ctor() +end + +function FirstRechargePopUI:isFullScreen() + return false +end + +function FirstRechargePopUI:getPrefabPath() + return "assets/prefabs/ui/shop/first_recharge_pop_ui.prefab" +end + +function FirstRechargePopUI:onLoadRootComplete() + self.uiMap = self.root:genAllChildren() + self.uiMap["first_recharge_pop_ui.close_btn"]:addClickListener(function() + self:closeUI() + end) + + self.titleTx = self.uiMap["first_recharge_pop_ui.bg.title_bg.title"] + self.titleTx:setText(I18N:getGlobalText(I18N.GlobalConst.SHOP_DESC_34)) -- 首充豪礼 + + self.itemNodeList = {} + self.itemCellList = {} + self.itemTextList = {} + self.itemHelpList = {} + for i = 1, MAX_ITEM_NUM do + table.insert(self.itemNodeList, self.uiMap["first_recharge_pop_ui.bg.item_" .. i]) + table.insert(self.itemCellList, CellManager:addCellComp(self.uiMap["first_recharge_pop_ui.bg.item_".. i .. ".item_cell"], GConst.TYPEOF_LUA_CLASS.ITEM_CELL)) + table.insert(self.itemTextList, self.uiMap["first_recharge_pop_ui.bg.item_".. i .. ".num"]) + table.insert(self.itemHelpList, self.uiMap["first_recharge_pop_ui.bg.item_" .. i .. ".help"]) + end + + self.descText = self.uiMap["first_recharge_pop_ui.bg.desc_text"] + self.titleTx:setText(I18N:getGlobalText(I18N.GlobalConst.SHOP_DESC_35)) -- 充值购买任意商品,即可获得如下奖励,仅此一次! + + self.funcBtn = self.uiMap["first_recharge_pop_ui.bg.func_btn"] + self.btnJumpText = self.uiMap["first_recharge_pop_ui.bg.func_btn.jump_text"] + self.btnGetText = self.uiMap["first_recharge_pop_ui.bg.func_btn.get_text"] + self.btnIcon = self.uiMap["first_recharge_pop_ui.bg.func_btn.icon"] + + self.btnJumpText:setText(I18N:getGlobalText(I18N.GlobalConst.SHOP_DESC_36)) -- 商店 + self.btnGetText:setText(I18N:getGlobalText(I18N.GlobalConst.BTN_CLAIM)) -- 领取 + + self.funcBtn:addClickListener(function() + self:onClickFuncBtn() + end) + + self:_bind() + self:refresh() +end + +function FirstRechargePopUI:_bind() + self:bind(DataManager.ShopData, "isDirty", function() + self:refresh() + end) +end + +function FirstRechargePopUI:refresh() + local cfgInfo = PayManager:getGiftConfigInfo(PayManager.PURCHARSE_TYPE.ACT_GIFT, GConst.ShopConst.FIRST_RECHARGE_ID) + local rewards = cfgInfo.reward or {} + for i = 1, MAX_ITEM_NUM do + if i <= #rewards then + self.itemNodeList[i]:setVisible(true) + self.itemCellList[i]:refreshByCfg(rewards[i].id, 0) + self.itemCellList[i]:setNum("") + self.itemTextList[i]:setText(rewards[i].num) + self.itemCellList[i]:addClickListener(function() + ModuleManager.TipsManager:showItemTips(rewards[i].id, self.itemCellList[i]:getBaseObject()) + end) + self.itemHelpList[i]:setVisible(false) + else + self.itemNodeList[i]:setVisible(false) + end + end + + -- 对于首充礼包,有跳转商店和领取2个分支 + local canGet = DataManager.ShopData:getHasFirstRechargeReward() + if canGet then + self.btnIcon:setVisible(false) + self.btnJumpText:setVisible(false) + self.btnGetText:setVisible(true) + else + local hasGet = DataManager.ShopData:getHasGotFirstRechargeReward() + if hasGet then + self:closeUI() + else + self.btnIcon:setVisible(true) + self.btnJumpText:setVisible(true) + self.btnGetText:setVisible(false) + end + end +end + +function FirstRechargePopUI:onClickFuncBtn() + -- 对于首充礼包,有跳转商店和领取2个分支 + local canGet = DataManager.ShopData:getHasFirstRechargeReward() + if canGet then + PayManager:purchasePackage(PayManager.PURCHARSE_TYPE.ACT_GIFT, GConst.ShopConst.FIRST_RECHARGE_ID) + else + EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.GO_SHOP) + self:closeUI() + end +end + +return FirstRechargePopUI \ No newline at end of file diff --git a/lua/app/ui/shop/first_recharge_pop_ui.lua.meta b/lua/app/ui/shop/first_recharge_pop_ui.lua.meta new file mode 100644 index 00000000..a062972f --- /dev/null +++ b/lua/app/ui/shop/first_recharge_pop_ui.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d1ea4328dc9ac714d8d6e25ef668467e +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}