五星成长礼修改提交
parent
905d77b0c6
commit
1f7b161087
File diff suppressed because it is too large
Load Diff
|
@ -87,8 +87,8 @@ local type = {
|
|||
livePos = Vector2(274.5, -408.1),
|
||||
liveSize = Vector2(1612, 1802),
|
||||
tipBg = "r_Dungeon_juqingdian",
|
||||
resetTime = string.format("<color=#BA9AC2>%s</color>",specialConfig[66].Value),
|
||||
tip = string.format("<color=#BA9AC2>%s</color>",specialConfig[67].Value),
|
||||
resetTime = string.format("<color=#DB9A9A>%s</color>",specialConfig[75].Value),
|
||||
tip = string.format("<color=#DB9A9A>%s</color>",specialConfig[76].Value),
|
||||
redPointType = RedPointType.People_Mirror
|
||||
},
|
||||
default = {id = -1,bg = "r_Dungeon_rendi_01"}
|
||||
|
|
|
@ -3,6 +3,19 @@ HeroStarFeedPage = {}
|
|||
|
||||
local this = HeroStarFeedPage
|
||||
|
||||
local RechargeConfig = ConfigManager.GetConfig(ConfigName.RechargeCommodityConfig)--整表数据
|
||||
local upgradeConfig = ConfigManager.GetAllConfigsDataByKey(ConfigName.RechargeCommodityConfig,"ShowType",8)--五档奖励数据
|
||||
|
||||
local rechargeNum = 0
|
||||
local cursortingOrder = 0
|
||||
local curGiftList = {}
|
||||
local curGiftId = 0
|
||||
local curEndTime = 0
|
||||
local curIndex
|
||||
local fun--回调
|
||||
--设置奖励
|
||||
local _ItemViewList = {}
|
||||
|
||||
function HeroStarFeedPage:New(super, gameObject)
|
||||
local _o
|
||||
_o = _o or {}
|
||||
|
@ -11,19 +24,19 @@ function HeroStarFeedPage:New(super, gameObject)
|
|||
_o.fatherClass = super
|
||||
_o.gameObject = gameObject
|
||||
_o:InitComponent(gameObject)
|
||||
|
||||
return _o
|
||||
end
|
||||
|
||||
--- 组件初始化, 跟主面板一起生成
|
||||
function HeroStarFeedPage:InitComponent(gameObject)
|
||||
self.rewardGrid = Util.GetGameObject(gameObject, "downLayout/rect/grid")
|
||||
self.itemPre = Util.GetGameObject(gameObject, "downLayout/item")
|
||||
|
||||
self.rewardItemList = {}
|
||||
self.timeList = {}
|
||||
self.isClose = true
|
||||
|
||||
self.btnClose = Util.GetGameObject(self.gameObject,"show/btnBack")
|
||||
self.btnBuy = Util.GetGameObject(self.gameObject,"show/buy")
|
||||
self.grid = Util.GetGameObject(self.gameObject,"show/rewards/Grid")
|
||||
self.endTime = Util.GetGameObject(self.gameObject,"show/endTime/text"):GetComponent("Text")
|
||||
self.price = Util.GetGameObject(self.btnBuy,"Text"):GetComponent("Text")
|
||||
self.arrowsLeft = Util.GetGameObject(self.gameObject,"show/arrows/left")
|
||||
self.arrowsRight = Util.GetGameObject(self.gameObject,"show/arrows/right")
|
||||
self.times = Util.GetGameObject(self.gameObject,"show/timesLeft"):GetComponent("Text")
|
||||
end
|
||||
|
||||
function HeroStarFeedPage:OnSortingOrderChange(parentSorting)
|
||||
|
@ -31,19 +44,63 @@ function HeroStarFeedPage:OnSortingOrderChange(parentSorting)
|
|||
end
|
||||
|
||||
function HeroStarFeedPage:BindEvent()
|
||||
Util.AddClick(self.btnClose,function()
|
||||
self:OnClose()
|
||||
end)
|
||||
|
||||
Util.AddClick(self.btnBuy,function()
|
||||
if AppConst.isSDKLogin then
|
||||
PayManager.Pay({ Id = curGiftId })
|
||||
else
|
||||
NetManager.RequestBuyGiftGoods(curGiftId, function()
|
||||
FirstRechargeManager.RefreshAccumRechargeValue(curGiftId)
|
||||
CheckRedPointStatus(RedPointType.GrowthPackage)--成长礼包的红点检测
|
||||
curGiftList[curIndex].dynamicBuyTimes = curGiftList[curIndex].dynamicBuyTimes - 1
|
||||
--判断可购买次数是否为零,是剔除礼包信息
|
||||
-- for i = 1, #curGiftList do
|
||||
if curGiftList[curIndex].dynamicBuyTimes == 0 then
|
||||
OperatingManager.SetHadBuyGoodsId({curGiftId})
|
||||
OperatingManager.RemoveItemInfoByType(GoodsTypeDef.DirectPurchaseGift, curGiftId)
|
||||
if curGiftList[curIndex-1] then
|
||||
curIndex = curIndex -1
|
||||
-- LogBlue("QWEQWEQWEWQ")
|
||||
-- elseif curGiftList[curIndex+1] then
|
||||
-- curIndex = curIndex +1
|
||||
-- LogRed("ZXCZXCZX")
|
||||
end
|
||||
end
|
||||
-- end
|
||||
--判断是否有礼包
|
||||
self:GetInfoList()
|
||||
if #curGiftList == 0 then
|
||||
self:OnClose()
|
||||
else
|
||||
if curIndex then
|
||||
self:FreshRewardShow(curIndex)
|
||||
-- LogGreen("没换界面")
|
||||
else
|
||||
if curGiftList[curIndex-1] then
|
||||
self:FreshRewardShow(curIndex - 1)
|
||||
elseif curGiftList[curIndex+1] then
|
||||
self:FreshRewardShow(curIndex + 1)
|
||||
-- LogRed("界面-1")
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
end)
|
||||
|
||||
Util.AddClick(self.arrowsLeft,function()
|
||||
self:FreshRewardShow(curIndex-1)
|
||||
end)
|
||||
|
||||
Util.AddClick(self.arrowsRight,function()
|
||||
self:FreshRewardShow(curIndex+1)
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
|
||||
function HeroStarFeedPage:AddListener()
|
||||
Game.GlobalEvent:AddEvent(GameEvent.MoneyPay.OnPayResultSuccess, self.RechargeSuccessFunc, self)
|
||||
end
|
||||
|
||||
function HeroStarFeedPage:RemoveListener()
|
||||
Game.GlobalEvent:RemoveEvent(GameEvent.MoneyPay.OnPayResultSuccess, self.RechargeSuccessFunc, self)
|
||||
end
|
||||
|
||||
-- 充值成功回调
|
||||
function HeroStarFeedPage:RechargeSuccessFunc(id)
|
||||
FirstRechargeManager.RefreshAccumRechargeValue(id)
|
||||
|
@ -52,185 +109,116 @@ function HeroStarFeedPage:RechargeSuccessFunc(id)
|
|||
|
||||
end
|
||||
|
||||
function HeroStarFeedPage:AddListener()
|
||||
|
||||
end
|
||||
|
||||
--移除事件监听(用于子类重写)
|
||||
function HeroStarFeedPage:RemoveListener()
|
||||
|
||||
end
|
||||
|
||||
--- 这玩意点击购买之后外面会刷4遍,……,自己不主动退出。就不让他刷新
|
||||
function HeroStarFeedPage:OnShow()
|
||||
if not self.isClose then return end
|
||||
--Log("self.isClose "..tostring(self.isClose))
|
||||
self:FreshRewardShow()
|
||||
self:SetTimeStart()
|
||||
local index = 1
|
||||
self:FreshRewardShow(index)
|
||||
self.isClose = false
|
||||
end
|
||||
|
||||
function HeroStarFeedPage:SetTimeStart()
|
||||
--- 启动一个通用定时器
|
||||
self.timer = nil
|
||||
self.timer = Timer.New(function ()
|
||||
for i = 1 , #self.timeList do
|
||||
local value = self.timeList[i]
|
||||
if value then
|
||||
local duration = value.endTime - PlayerManager.serverTime
|
||||
if value.isActive then
|
||||
if duration >= 0 then
|
||||
value.timeComp.text = Language[10541] .. TimeToDHMS(duration) .. ")"
|
||||
--获取(自己拼凑)礼包数据
|
||||
function HeroStarFeedPage:GetInfoList()
|
||||
-- body
|
||||
local list={}
|
||||
local infoList = OperatingManager.GetGiftGoodsInfoList(GoodsTypeDef.DirectPurchaseGift)--拿取所有类型5礼包信息(包含需要的礼包)
|
||||
for index, value in pairs(infoList) do
|
||||
for i = 1, #upgradeConfig do
|
||||
if upgradeConfig[i].Id == value.goodsId then
|
||||
table.insert(list,value)
|
||||
end
|
||||
end
|
||||
end
|
||||
curGiftList = list
|
||||
end
|
||||
|
||||
function HeroStarFeedPage:FreshRewardShow(index)
|
||||
curIndex = index
|
||||
rechargeNum= VipManager.GetChargedNum()
|
||||
self:GetInfoList()
|
||||
self.arrowsLeft:SetActive(not (not curGiftList[curIndex-1]))
|
||||
self.arrowsRight:SetActive(not (not curGiftList[curIndex+1]))
|
||||
curGiftId = curGiftList[curIndex].goodsId
|
||||
curEndTime = curGiftList[curIndex].endTime
|
||||
self.endTime.text = Language[11496]..TimeToHMS(curEndTime-GetTimeStamp())
|
||||
self:SetGfitShow()
|
||||
self:SetTime()
|
||||
end
|
||||
|
||||
--设置剩余时间,取剩余时间最短的礼包(第一个礼包的剩余时间)
|
||||
function this:SetTime()
|
||||
if self.localTimer then
|
||||
self.localTimer:Stop()
|
||||
self.localTimer = nil
|
||||
end
|
||||
self.localTimer = Timer.New(function()
|
||||
-- curEndTime= curEndTime-1
|
||||
--时间到了之后
|
||||
if curEndTime-GetTimeStamp() < 0 then
|
||||
OperatingManager.RemoveItemInfoByType(GoodsTypeDef.DirectPurchaseGift, curGiftId)
|
||||
if curGiftList[curIndex-1] then
|
||||
curIndex = curIndex -1
|
||||
end
|
||||
self:GetInfoList()
|
||||
if #curGiftList == 0 then
|
||||
self:OnClose()
|
||||
else
|
||||
if curIndex then
|
||||
self:FreshRewardShow(curIndex)
|
||||
else
|
||||
-- 从激活状态到结束状态
|
||||
Log(Language[10542])
|
||||
value.timeComp.text = ""
|
||||
table.remove(self.timeList, i)
|
||||
OperatingManager.RemoveItemInfoByType(GoodsTypeDef.DirectPurchaseGift, value.id)
|
||||
self:FreshRewardShow()
|
||||
|
||||
if not not curGiftList[curIndex-1] then
|
||||
self:FreshRewardShow(curIndex-1)
|
||||
elseif not not curGiftList[curIndex+1] then
|
||||
self:FreshRewardShow(curIndex+1)
|
||||
end
|
||||
end
|
||||
else
|
||||
value.timeComp.text = ""
|
||||
end
|
||||
end
|
||||
end
|
||||
end, 1, -1, true)
|
||||
self.timer:Start()
|
||||
|
||||
this.endTime.text = Language[11496]..TimeToHMS(curEndTime-GetTimeStamp())
|
||||
end,1,-1,true)
|
||||
self.localTimer:Start()
|
||||
end
|
||||
|
||||
|
||||
function HeroStarFeedPage:FreshRewardShow()
|
||||
---没有激活的礼包直接回到主界面
|
||||
local hasActiveGift = OperatingManager.IsHeroGiftActive()
|
||||
|
||||
if not hasActiveGift then
|
||||
if AppConst.isSDKLogin then
|
||||
UIManager.OpenPanel(UIName.ExpertPanel)
|
||||
else
|
||||
CallBackOnPanelClose(UIName.RewardItemPopup, function()
|
||||
UIManager.OpenPanel(UIName.ExpertPanel)
|
||||
end)
|
||||
function HeroStarFeedPage:SetGfitShow()
|
||||
for i=1, #RechargeConfig[curGiftId].RewardShow do
|
||||
if not _ItemViewList[i] then
|
||||
local view = SubUIManager.Open(SubUIConfig.ItemView,self.grid.transform)
|
||||
_ItemViewList[i] = view
|
||||
end
|
||||
|
||||
return
|
||||
_ItemViewList[i]:OnOpen(false,RechargeConfig[curGiftId].RewardShow[i],1,false)
|
||||
_ItemViewList[i].gameObject:SetActive(true)
|
||||
end
|
||||
|
||||
|
||||
local shopData = OperatingManager.GetGiftShowData()
|
||||
|
||||
for i = 1, #shopData do
|
||||
|
||||
-- 重新组的数据,检查到上一个是有数据的条目时,隐藏, 然后需要清除缓存,
|
||||
if shopData[i].leftBuyTime <= 0 then
|
||||
if self.rewardItemList[i] then
|
||||
self.rewardItemList[i]:SetActive(false)
|
||||
table.remove( self.rewardItemList, i)
|
||||
end
|
||||
break
|
||||
end
|
||||
|
||||
|
||||
local info = shopData[i]
|
||||
if not self.rewardItemList[i] then
|
||||
self.rewardItemList[i] = newObjToParent(self.itemPre, self.rewardGrid)
|
||||
self.rewardItemList[i]:SetActive(true)
|
||||
end
|
||||
|
||||
local item = self.rewardItemList[i]
|
||||
|
||||
local giftName = Util.GetGameObject(item, "titleImage/root/desc"):GetComponent("Text")
|
||||
local leftTime = Util.GetGameObject(item, "titleImage/root/leftTime"):GetComponent("Text")
|
||||
local btnBuy = Util.GetGameObject(item, "getRewardBtn")
|
||||
local buyRed = Util.GetGameObject(btnBuy, "redPoint")
|
||||
local buyText = Util.GetGameObject(btnBuy, "Text"):GetComponent("Text")
|
||||
local leftNum = Util.GetGameObject(item, "left"):GetComponent("Text")
|
||||
local grid = Util.GetGameObject(item, "scroll/content")
|
||||
|
||||
leftTime.text = ""
|
||||
-- if not self.timeList[info.id] then
|
||||
self.timeList[i] = {}
|
||||
self.timeList[i].id = info.id
|
||||
self.timeList[i].timeComp = leftTime
|
||||
self.timeList[i].isActive = false
|
||||
self.timeList[i].endTime = 0
|
||||
-- end
|
||||
|
||||
|
||||
|
||||
--- 设置购买按钮信息
|
||||
giftName.text = info.name
|
||||
|
||||
local leftTime = info.leftBuyTime
|
||||
leftNum.gameObject:SetActive(leftTime > 0)
|
||||
leftNum.text = Language[10535] .. leftTime
|
||||
Util.SetGray(btnBuy, leftTime == 0)
|
||||
local str = leftTime > 0 and info.price .. Language[10538] or Language[10543]
|
||||
buyText.text = str
|
||||
self.timeList[i].isActive = leftTime > 0
|
||||
self.timeList[i].endTime = leftTime > 0 and info.endTime or 0
|
||||
|
||||
|
||||
self:SetRewardData(item, info, grid)
|
||||
|
||||
--- 注册购买函数
|
||||
Util.AddOnceClick(btnBuy, function ()
|
||||
if leftTime < 1 then
|
||||
PopupTipPanel.ShowTip(Language[10544])
|
||||
return
|
||||
end
|
||||
|
||||
if AppConst.isSDKLogin then
|
||||
PayManager.Pay({ Id = info.id })
|
||||
else
|
||||
NetManager.RequestBuyGiftGoods(info.id, function(msg)
|
||||
self:RechargeSuccessFunc(info.id)
|
||||
Log(Language[10545])
|
||||
|
||||
end)
|
||||
end
|
||||
end)
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
function this:SetRewardData(item, info, grid)
|
||||
--- 设置奖励内容
|
||||
--- 当前的礼包内容
|
||||
local curGiftData = info.rewardData
|
||||
|
||||
if self.rewardItemList[item] then
|
||||
for i = 1, 4 do
|
||||
self.rewardItemList[item][i].gameObject:SetActive(false)
|
||||
end
|
||||
for i = 1, #curGiftData do
|
||||
if self.rewardItemList[item][i] then
|
||||
self.rewardItemList[item][i]:OnOpen(false, {curGiftData[i][1],curGiftData[i][2]}, 0.75)
|
||||
self.rewardItemList[item][i].gameObject:SetActive(true)
|
||||
end
|
||||
end
|
||||
else
|
||||
self.rewardItemList[item]={}
|
||||
for i = 1, 4 do
|
||||
self.rewardItemList[item][i] = SubUIManager.Open(SubUIConfig.ItemView, grid.transform)
|
||||
self.rewardItemList[item][i].gameObject:SetActive(false)
|
||||
|
||||
end
|
||||
for i = 1, #curGiftData do
|
||||
self.rewardItemList[item][i]:OnOpen(false, {curGiftData[i][1],curGiftData[i][2]}, 0.75)
|
||||
self.rewardItemList[item][i].gameObject:SetActive(true)
|
||||
end
|
||||
end
|
||||
|
||||
self.times.text = Language[10535]..curGiftList[curIndex].dynamicBuyTimes..Language[10054]
|
||||
self.price.text = RechargeConfig[curGiftId].Price..Language[10538]
|
||||
end
|
||||
|
||||
|
||||
function HeroStarFeedPage:OnClose()
|
||||
Log("HeroStarFeedPage:OnClose()")
|
||||
if self.timer then
|
||||
self.timer:Stop()
|
||||
self.timer = nil
|
||||
Log("HeroStarFeedPage:OnClose()")
|
||||
if self.localTimer then
|
||||
self.localTimer:Stop()
|
||||
self.localTimer = nil
|
||||
end
|
||||
self.isClose = true
|
||||
self.timeList = {}
|
||||
self.gameObject:SetActive(false)
|
||||
end
|
||||
|
||||
function HeroStarFeedPage:OnDestroy()
|
||||
self.rewardItemList = {}
|
||||
|
||||
|
||||
cursortingOrder = 0
|
||||
_ItemViewList = {}
|
||||
if self.localTimer then
|
||||
self.localTimer:Stop()
|
||||
self.localTimer = nil
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue