入门礼包

This commit is contained in:
CloudJ 2023-06-27 17:24:32 +08:00
parent 54242318ed
commit b59a8d20d6
14 changed files with 267 additions and 30 deletions

View File

@ -108,6 +108,7 @@ BIReport.ITEM_GET_TYPE = {
CHANGE_NAME = "ChangeName", -- 重命名
CHANGE_AVATAR = "ChangeAvatar", -- 修改头像
CHANGE_FRAME = "ChangeFrame", -- 修改头像框
INTRODUCTORY_GIFT = "IntroductoryGift", -- 入门礼包
}
BIReport.ADS_CLICK_TYPE = {
@ -160,6 +161,7 @@ BIReport.GIFT_TYPE = {
ACT_CHAPTER_STORE = "ActChapterStore",
GROWTH_FUND = "GrowthFund",
GROW_UP_GIFT = "GrowUpGift",
INTRODUCTORY_GIFT = "IntroductoryGift",
}
BIReport.COIN_TYPE = {

View File

@ -140,6 +140,7 @@ function DataManager:initWithServerData(data)
self.ShopData:initCommonDailyGoldGift(data.mall_idle and data.mall_idle.ad_count) -- 常驻金币礼包
self.ShopData:initGrowUpGift(data.act_grow_up_gift, data.now_ts) -- 成长礼包
self.ShopData:initLevelUpGift(data.act_level_up_gift) -- 助力/金币礼包
self.ShopData:initIntroductGift(data.act_introductory_gift) -- 入门礼包
-- 商店礼包都初始化完了后检查一下每日红点
self.ShopData:checkShopDiscountRedPoint()
self.SummonData:init(data.summon, true)

View File

@ -74,6 +74,7 @@ ModuleManager.MODULE_KEY = {
MAIL = "mail_open", -- 邮件
DUNGEON_SHARDS = "dungeon_shards_open", -- 碎片副本
DUNGEON_GOLD = "dungeon_gold_open", -- 金币副本
INTRODUCT_GIFT = "introduct_gift", -- 入门礼包
}
local _moduleMgrs = {}

View File

@ -11,6 +11,7 @@ PayManager.PURCHARSE_TYPE = {
PayManager.PURCHARSE_ACT_TYPE = {
FIRST_RECHARGE = 1,
COIN_GIFT = 2,
INTRODUCTORY_GIFT = 3,
BEGINNER_GIFT = 4,
LEVEL_UP_GIFT = 5,
GROWTH_FUND = 6,
@ -29,6 +30,7 @@ PayManager.BI_ITEM_GET_TYPE = {
[PayManager.PURCHARSE_TYPE.ACT_GIFT] = {
[PayManager.PURCHARSE_ACT_TYPE.FIRST_RECHARGE] = BIReport.ITEM_GET_TYPE.FIRST_RECHARGE,
[PayManager.PURCHARSE_ACT_TYPE.COIN_GIFT] = BIReport.ITEM_GET_TYPE.COIN_GIFT,
[PayManager.PURCHARSE_ACT_TYPE.INTRODUCTORY_GIFT] = BIReport.ITEM_GET_TYPE.INTRODUCTORY_GIFT,
[PayManager.PURCHARSE_ACT_TYPE.BEGINNER_GIFT] = BIReport.ITEM_GET_TYPE.BEGINNER_GIFT,
[PayManager.PURCHARSE_ACT_TYPE.LEVEL_UP_GIFT] = BIReport.ITEM_GET_TYPE.LEVEL_UP_GIFT,
[PayManager.PURCHARSE_ACT_TYPE.GROWTH_FUND] = BIReport.ITEM_GET_TYPE.GROWTH_FUND,
@ -44,6 +46,7 @@ PayManager.BI_GIFT_TYPE = {
[PayManager.PURCHARSE_TYPE.ACT_GIFT] = {
[PayManager.PURCHARSE_ACT_TYPE.FIRST_RECHARGE] = BIReport.GIFT_TYPE.FIRST_RECHARGE,
[PayManager.PURCHARSE_ACT_TYPE.COIN_GIFT] = BIReport.GIFT_TYPE.COIN_GIFT,
[PayManager.PURCHARSE_ACT_TYPE.INTRODUCTORY_GIFT] = BIReport.GIFT_TYPE.INTRODUCTORY_GIFT,
[PayManager.PURCHARSE_ACT_TYPE.BEGINNER_GIFT] = BIReport.GIFT_TYPE.BEGINNER_GIFT,
[PayManager.PURCHARSE_ACT_TYPE.LEVEL_UP_GIFT] = BIReport.GIFT_TYPE.LEVEL_UP_GIFT,
[PayManager.PURCHARSE_ACT_TYPE.GROWTH_FUND] = BIReport.GIFT_TYPE.GROWTH_FUND,

View File

@ -46,6 +46,11 @@ end
function ChapterManager:startFightFinish(result)
if result.err_code == GConst.ERROR_STR.SUCCESS then
ModuleManager.BattleManager:playBattle(GConst.BattleConst.BATTLE_TYPE.STAGE)
-- 开始第二章时,触发成长礼包
if result.reqData.chapter_id == GConst.ShopConst.INTRODUCTORY_GIFT_TRIGGER_CHAPTER_ID then
DataManager.ShopData:onTriggerIntroductGift()
end
end
end

View File

@ -31,7 +31,8 @@ MainCityConst.LEFT_SIDE_BARS = {
MainCityConst.RIGHT_SIDE_BARS = {
"app/ui/main_city/cell/side_bar_gold_pig_cell",
"app/ui/main_city/cell/side_bar_first_recharge_cell",
-- "app/ui/main_city/cell/side_bar_first_recharge_cell", 已作废
"app/ui/main_city/cell/side_bar_introduct_gift_cell",
"app/ui/main_city/cell/side_bar_beginner_gift_cell",
"app/ui/main_city/cell/side_bar_grow_up_gift_1_cell",
"app/ui/main_city/cell/side_bar_grow_up_gift_2_cell",

View File

@ -2,6 +2,8 @@ local ShopConst = {}
ShopConst.FIRST_RECHARGE_ID = 10102 -- 首充礼包ID
ShopConst.BEGINNER_GIFT_ID = 40102 -- 新手礼包ID
ShopConst.INTRODUCTORY_GIFT_ID = 30102 -- 入门礼包ID
ShopConst.INTRODUCTORY_GIFT_TRIGGER_CHAPTER_ID = 2 -- 入门礼包触发的章节ID
ShopConst.MAIN_UI_POP_TYPE = { -- 当触发弹窗时,相关联的类型礼包也要触发
[PayManager.PURCHARSE_TYPE.ACT_GIFT] = {
[PayManager.PURCHARSE_ACT_TYPE.BEGINNER_GIFT] = true,

View File

@ -36,6 +36,8 @@ function ShopManager:showGiftPopUI(actType, actId, onlySelf)
end
if actType == PayManager.PURCHARSE_TYPE.ACT_GIFT and actId == GConst.ShopConst.FIRST_RECHARGE_ID then
UIManager:showUI("app/ui/shop/first_recharge_pop_ui")
elseif actType == PayManager.PURCHARSE_TYPE.ACT_GIFT and actId == GConst.ShopConst.INTRODUCT_GIFT_ID then
UIManager:showUI("app/ui/shop/introduct_pop_ui")
else
UIManager:showUI("app/ui/shop/gift_pop_ui", {type = actType, id = actId, onlySelf = onlySelf})
end

View File

@ -0,0 +1,46 @@
local SideBarBaseCellComp = require "app/ui/main_city/cell/side_bar_base_cell"
local SideBarIntroductGiftCell = class("SideBarIntroductGiftCell", SideBarBaseCellComp)
function SideBarIntroductGiftCell:getModuleKey()
return ModuleManager.MODULE_KEY.INTRODUCT_GIFT
end
function SideBarIntroductGiftCell:getIsOpen()
return DataManager.ShopData:getIntroductGiftShowSideBar()
end
function SideBarIntroductGiftCell:getSpineName()
return "main_btn_gift_new"
end
function SideBarIntroductGiftCell:onClick()
ModuleManager.ShopManager:showGiftPopUI(PayManager.PURCHARSE_TYPE.ACT_GIFT, GConst.ShopConst.INTRODUCT_GIFT_ID, true)
end
function SideBarIntroductGiftCell:getIsShowRedPoint()
return false
end
function SideBarIntroductGiftCell:onRefresh()
self.timeBg:setVisible(true)
self:_refreshTime()
end
function SideBarIntroductGiftCell:updateTime()
if self:getIsOpen() then
self:_refreshTime()
else
self:closeBtn()
end
end
function SideBarIntroductGiftCell:_refreshTime()
local remainTime = DataManager.ShopData:getIntroductGiftRemainTime()
if remainTime >= 0 then
self.timeTx:setText(GFunc.getTimeStr(remainTime))
else
self.timeTx:setText("00:00:00")
end
end
return SideBarIntroductGiftCell

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: c8bc1461168b10444b874ff8cdd0c025
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -1003,7 +1003,7 @@ function MainCityUI:checkTutorial()
end
end
-- 检查礼包(首充/章节/新手/助力/成长/金币顺序)
-- 检查礼包(首充(作废)/入门/章节/新手/助力/成长/金币顺序)
function MainCityUI:checkGift()
-- 审核模式不弹礼包
if GFunc.isShenhe() then
@ -1023,6 +1023,7 @@ function MainCityUI:checkGift()
local beginnerGiftIds
local levelUpGiftIds
local firstRechargeIds
local introductGiftIds
local actPopUpGifts = DataManager.ShopData:getPopUpGiftByType(PayManager.PURCHARSE_TYPE.ACT_GIFT)
if actPopUpGifts and #actPopUpGifts > 0 then
-- 先遍历找出符合弹出的类型
@ -1050,6 +1051,13 @@ function MainCityUI:checkGift()
end
table.insert(firstRechargeIds, actId)
end
-- 入门礼包
if cfgInfo.type == PayManager.PURCHARSE_ACT_TYPE.INTRODUCTORY_GIFT then
if not introductGiftIds then
introductGiftIds = {}
end
table.insert(introductGiftIds, actId)
end
end
end
end
@ -1057,8 +1065,13 @@ function MainCityUI:checkGift()
local growUpPopUpGifts = DataManager.ShopData:getPopUpGiftByType(PayManager.PURCHARSE_TYPE.GROW_UP_GIFT)
-- 按顺序弹出(首充/章节/新手/助力/成长/金币顺序)
-- 首充礼包
if firstRechargeIds and #firstRechargeIds > 0 then
ModuleManager.ShopManager:triggerGiftPopUI(PayManager.PURCHARSE_TYPE.ACT_GIFT, firstRechargeIds[1])
-- if firstRechargeIds and #firstRechargeIds > 0 then
-- ModuleManager.ShopManager:triggerGiftPopUI(PayManager.PURCHARSE_TYPE.ACT_GIFT, firstRechargeIds[1])
-- return true
-- end
-- 入门礼包
if introductGiftIds and #introductGiftIds > 0 then
ModuleManager.ShopManager:triggerGiftPopUI(PayManager.PURCHARSE_TYPE.ACT_GIFT, introductGiftIds[1])
return true
end
-- 章节礼包

View File

@ -0,0 +1,92 @@
local IntroductPopUI = class("IntroductPopUI", BaseUI)
local MAX_ITEM_NUM = 3
function IntroductPopUI:ctor()
end
function IntroductPopUI:isFullScreen()
return false
end
function IntroductPopUI:getPrefabPath()
return "assets/prefabs/ui/shop/introduct_pop_ui.prefab"
end
function IntroductPopUI:onPressBackspace()
self:closeUI()
end
function IntroductPopUI:onLoadRootComplete()
self.uiMap = self.root:genAllChildren()
self.uiMap["introduct_pop_ui.close_btn"]:addClickListener(function()
self:closeUI()
end)
self.titleTx = self.uiMap["introduct_pop_ui.bg.title_bg.title"]
self.titleTx:setText(I18N:getGlobalText(I18N.GlobalConst.SHOP_DESC_37)) -- 入门礼包
self.rewardCellList = {}
for i = 1, MAX_ITEM_NUM do
table.insert(self.rewardCellList, CellManager:addCellComp(self.uiMap["introduct_pop_ui.bg.pop_reward_cell_" .. i], GConst.TYPEOF_LUA_CLASS.POP_REWARD_CELL))
end
self.descText = self.uiMap["introduct_pop_ui.bg.desc_text"]
self.descText:setText(I18N:getGlobalText(I18N.GlobalConst.SHOP_DESC_38)) -- 超值S级英雄,仅此一次!
self.buyBtn = self.uiMap["introduct_pop_ui.bg.buy_btn"]
self.buyText = self.uiMap["introduct_pop_ui.bg.buy_btn.text"]
self.buyBtn:addClickListener(function()
self:onClickFuncBtn()
end)
local cfgInfo = PayManager:getGiftConfigInfo(PayManager.PURCHARSE_TYPE.ACT_GIFT, GConst.ShopConst.INTRODUCTORY_GIFT_ID)
local rechargeId = cfgInfo.recharge_id
self.buyText:setText(GFunc.getFormatPrice(rechargeId))
self.timeText = self.uiMap["introduct_pop_ui.bg.time_node.text"]
self:_bind()
self:refresh()
-- 上报
BIReport:postPayUIShow(BIReport.GIFT_TYPE.INTRODUCTORY_GIFT, GConst.ShopConst.INTRODUCTORY_GIFT_ID)
end
function IntroductPopUI:_bind()
self:bind(DataManager.ShopData, "isDirty", function()
self:refresh()
end)
end
function IntroductPopUI:refresh()
if not (DataManager.ShopData:getIntroductGiftRemainBuyCount() > 0 and DataManager.ShopData:getIntroductGiftRemainTime() > 0) then
self:closeUI()
end
local cfgInfo = PayManager:getGiftConfigInfo(PayManager.PURCHARSE_TYPE.ACT_GIFT, GConst.ShopConst.INTRODUCTORY_GIFT_ID)
local rewards = cfgInfo.reward or {}
for i = 1, MAX_ITEM_NUM do
if i <= #rewards then
self.rewardCellList[i]:setVisible(true, 0.8)
self.rewardCellList[i]:refresh(rewards[i].id, rewards[i].num, false)
else
self.rewardCellList[i]:setVisible(false)
end
end
self:updateTime()
end
function IntroductPopUI:updateTime()
local remainTime = DataManager.ShopData:getIntroductGiftRemainTime()
if remainTime > 0 then
self.timeText:setText(Time:formatNumTime(remainTime))
else
self:closeUI()
end
end
function IntroductPopUI:onClickFuncBtn()
PayManager:purchasePackage(PayManager.PURCHARSE_TYPE.ACT_GIFT, GConst.ShopConst.INTRODUCTORY_GIFT_ID)
end
return IntroductPopUI

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 250463b2c13ef8146bff1f4439207b9a
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -765,60 +765,109 @@ end
-- 成长礼包结束 ----------------------------------------------------------------------------------------------
-- 首充 **********************************************************************************************
-- 首充(作废) **********************************************************************************************
function ShopData:getIsFirstRechargeOpen()
return ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.FIRST_RECHARGE, true)
return false -- ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.FIRST_RECHARGE, true)
end
-- 用于标记是否弹窗 要求等级不低于2 未领取该奖励
function ShopData:initFirstRecharge()
local lv = DataManager.PlayerData:getLv()
if lv > 1 and not self:getHasGotFirstRechargeReward() then
self:markPopUpGift(PayManager.PURCHARSE_TYPE.ACT_GIFT, GConst.ShopConst.FIRST_RECHARGE_ID)
end
-- local lv = DataManager.PlayerData:getLv()
-- if lv > 1 and not self:getHasGotFirstRechargeReward() then
-- self:markPopUpGift(PayManager.PURCHARSE_TYPE.ACT_GIFT, GConst.ShopConst.FIRST_RECHARGE_ID)
-- end
end
-- 是否有首充奖励 有支付且未领取
function ShopData:getHasFirstRechargeReward()
local pay = DataManager.PlayerData:getTotalPayAmount()
if pay > 0 and not self:getHasGotFirstRechargeReward() then
return true
else
-- local pay = DataManager.PlayerData:getTotalPayAmount()
-- if pay > 0 and not self:getHasGotFirstRechargeReward() then
-- return true
-- else
-- return false
-- end
return false
end
end
-- 是否已领取首充奖励
function ShopData:getHasGotFirstRechargeReward()
-- 通用act礼包中是否有已购
local boughtNum = self:getGiftBoughtNum(PayManager.PURCHARSE_TYPE.ACT_GIFT, GConst.ShopConst.FIRST_RECHARGE_ID)
return boughtNum > 0
-- local boughtNum = self:getGiftBoughtNum(PayManager.PURCHARSE_TYPE.ACT_GIFT, GConst.ShopConst.FIRST_RECHARGE_ID)
-- return boughtNum > 0
return true
end
-- 侧边栏是否展示 要求功能开启 未领取该奖励
function ShopData:getShowFirstRechargeSideBar()
if not self:getIsFirstRechargeOpen() then
-- if not self:getIsFirstRechargeOpen() then
-- return false
-- end
-- if not self:getHasGotFirstRechargeReward() then
-- return true
-- else
-- return false
-- end
return false
end
if not self:getHasGotFirstRechargeReward() then
return true
else
return false
end
end
-- 侧边栏红点
function ShopData:showFirstRechargeRp()
if not self:getIsFirstRechargeOpen() then
return false
end
-- if not self:getIsFirstRechargeOpen() then
-- return false
-- end
return self:getHasFirstRechargeReward()
-- return self:getHasFirstRechargeReward()
return false
end
-- 首充结束 ----------------------------------------------------------------------------------------------
-- 入门礼包 ----------------------------------------------------------------------------------------------
function ShopData:initIntroductGift(introductGift)
introductGift = introductGift or {}
self.introductGift = introductGift or {}
self.introductGiftTriggerTime = self.introductGift.trigger_at or 0
end
function ShopData:getIntroductGiftTriggerTime()
return self.introductGiftTriggerTime // 1000
end
function ShopData:setIntroductGiftTriggerTime(time)
self.introductGiftTriggerTime = time
end
-- 入门礼包剩余时间
function ShopData:getIntroductGiftRemainTime()
local cfgInfo = self:getActGiftConfig()[GConst.ShopConst.INTRODUCT_GIFT_ID]
local triggerTime = self:getIntroductGiftTriggerTime()
local remainTime = triggerTime + (cfgInfo.limit_time or 0) * 3600 - Time:getServerTime()
return remainTime
end
-- 入门礼包剩余可购次数
function ShopData:getIntroductGiftRemainBuyCount()
local cfgInfo = self:getActGiftConfig()[GConst.ShopConst.INTRODUCT_GIFT_ID]
local buyCount = self:getGiftBoughtNum(PayManager.PURCHARSE_TYPE.ACT_GIFT, GConst.ShopConst.INTRODUCT_GIFT_ID)
return cfgInfo.limit or 1 - buyCount
end
-- 触发入门礼包
function ShopData:onTriggerIntroductGift()
self:initIntroductGift({trigger_at = Time:getServerTime() * 1000})
-- 标记弹窗
self:markPopUpGift(PayManager.PURCHARSE_TYPE.ACT_GIFT, GConst.ShopConst.INTRODUCT_GIFT_ID)
end
-- 侧边栏是否展示(时间次数均满足)
function ShopData:getIntroductGiftShowSideBar()
return self:getIntroductGiftRemainBuyCount() > 0 and self:getIntroductGiftRemainTime() > 0
end
-- 入门礼包结束 --------------------------------------------------------------------------------------------
-- 底部栏是否有红点
function ShopData:getRp()
if not ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.MALL, true) then