miduo_client/Assets/ManagedResources/~Lua/Modules/Expert/HeroStarFeedPage.lua

225 lines
7.1 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

--- 不知道多少星级的听说是可以让英雄成长的感觉应该不怎么好玩的礼包购买页面
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 {}
setmetatable(_o, self)
self.__index = self
_o.fatherClass = super
_o.gameObject = gameObject
_o:InitComponent(gameObject)
return _o
end
--- 组件初始化, 跟主面板一起生成
function HeroStarFeedPage:InitComponent(gameObject)
this.spLoader = SpriteLoader.New()
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)
end
function HeroStarFeedPage:BindEvent()
Util.AddClick(self.btnClose,function()
self:OnClose()
end)
Util.AddClick(self.btnBuy,function()
--直购商品
PayManager.Pay(curGiftId, function(id)
this:RechargeSuccessFunc(id)
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:RechargeSuccessFunc(id)
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
function HeroStarFeedPage:AddListener()
end
--移除事件监听(用于子类重写)
function HeroStarFeedPage:RemoveListener()
end
--- 这玩意点击购买之后外面会刷4遍……自己不主动退出。就不让他刷新
function HeroStarFeedPage:OnShow()
if not self.isClose then return end
local index = 1
self:FreshRewardShow(index)
self.isClose = false
end
--获取(自己拼凑)礼包数据
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[10573]..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
if not not curGiftList[curIndex-1] then
self:FreshRewardShow(curIndex-1)
elseif not not curGiftList[curIndex+1] then
self:FreshRewardShow(curIndex+1)
end
end
end
end
self.endTime.text = Language[10573]..TimeToHMS(curEndTime-GetTimeStamp())
end,1,-1,true)
self.localTimer:Start()
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
_ItemViewList[i]:OnOpen(false,RechargeConfig[curGiftId].RewardShow[i],1,false)
_ItemViewList[i].gameObject:SetActive(true)
end
self.times.text = Language[10580]..curGiftList[curIndex].dynamicBuyTimes..Language[10048]
self.price.text = string.format(MoneyUtil.GetMoneyUnitName(), MoneyUtil.GetMoney(RechargeConfig[curGiftId].Price))--..MoneyUtil.GetMoneyUnitName()
end
function HeroStarFeedPage:OnClose()
Log("HeroStarFeedPage:OnClose()")
if self.localTimer then
self.localTimer:Stop()
self.localTimer = nil
end
self.isClose = true
self.gameObject:SetActive(false)
end
function HeroStarFeedPage:OnDestroy()
this.spLoader:Destroy()
cursortingOrder = 0
_ItemViewList = {}
if self.localTimer then
self.localTimer:Stop()
self.localTimer = nil
end
end
return HeroStarFeedPage