2020-08-25 15:46:38 +08:00
|
|
|
|
--- 不知道多少星级的听说是可以让英雄成长的感觉应该不怎么好玩的礼包购买页面
|
2020-05-09 13:31:21 +08:00
|
|
|
|
HeroStarFeedPage = {}
|
|
|
|
|
|
|
|
|
|
local this = HeroStarFeedPage
|
|
|
|
|
|
2020-08-14 13:32:55 +08:00
|
|
|
|
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 = {}
|
|
|
|
|
|
2020-05-09 13:31:21 +08:00
|
|
|
|
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)
|
2020-08-14 13:32:55 +08:00
|
|
|
|
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")
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function HeroStarFeedPage:OnSortingOrderChange(parentSorting)
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function HeroStarFeedPage:BindEvent()
|
2020-08-14 13:32:55 +08:00
|
|
|
|
Util.AddClick(self.btnClose,function()
|
|
|
|
|
self:OnClose()
|
|
|
|
|
end)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
2020-08-14 13:32:55 +08:00
|
|
|
|
Util.AddClick(self.btnBuy,function()
|
2020-09-09 18:47:17 +08:00
|
|
|
|
--直购商品
|
|
|
|
|
PayManager.Pay(curGiftId, function(id)
|
|
|
|
|
this:RechargeSuccessFunc(id)
|
|
|
|
|
end)
|
2020-08-14 13:32:55 +08:00
|
|
|
|
end)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
2020-08-14 13:32:55 +08:00
|
|
|
|
Util.AddClick(self.arrowsLeft,function()
|
|
|
|
|
self:FreshRewardShow(curIndex-1)
|
|
|
|
|
end)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
2020-08-14 13:32:55 +08:00
|
|
|
|
Util.AddClick(self.arrowsRight,function()
|
|
|
|
|
self:FreshRewardShow(curIndex+1)
|
|
|
|
|
end)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- 充值成功回调
|
|
|
|
|
function HeroStarFeedPage:RechargeSuccessFunc(id)
|
2020-09-09 18:47:17 +08:00
|
|
|
|
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
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
2020-08-14 13:32:55 +08:00
|
|
|
|
function HeroStarFeedPage:AddListener()
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--移除事件监听(用于子类重写)
|
|
|
|
|
function HeroStarFeedPage:RemoveListener()
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
2020-05-09 13:31:21 +08:00
|
|
|
|
--- 这玩意点击购买之后外面会刷4遍,……,自己不主动退出。就不让他刷新
|
|
|
|
|
function HeroStarFeedPage:OnShow()
|
|
|
|
|
if not self.isClose then return end
|
2020-08-14 13:32:55 +08:00
|
|
|
|
local index = 1
|
|
|
|
|
self:FreshRewardShow(index)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
self.isClose = false
|
|
|
|
|
end
|
|
|
|
|
|
2020-08-14 13:32:55 +08:00
|
|
|
|
--获取(自己拼凑)礼包数据
|
|
|
|
|
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)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
2020-08-14 13:32:55 +08:00
|
|
|
|
curGiftList = list
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
2020-08-14 13:32:55 +08:00
|
|
|
|
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
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
2020-08-14 13:32:55 +08:00
|
|
|
|
--设置剩余时间,取剩余时间最短的礼包(第一个礼包的剩余时间)
|
|
|
|
|
function this:SetTime()
|
|
|
|
|
if self.localTimer then
|
|
|
|
|
self.localTimer:Stop()
|
|
|
|
|
self.localTimer = nil
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
2020-08-14 13:32:55 +08:00
|
|
|
|
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
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
2020-08-14 13:32:55 +08:00
|
|
|
|
self:GetInfoList()
|
|
|
|
|
if #curGiftList == 0 then
|
|
|
|
|
self:OnClose()
|
2020-05-09 13:31:21 +08:00
|
|
|
|
else
|
2020-08-14 13:32:55 +08:00
|
|
|
|
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
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
2020-08-14 13:32:55 +08:00
|
|
|
|
end
|
2020-08-25 21:55:13 +08:00
|
|
|
|
self.endTime.text = Language[11496]..TimeToHMS(curEndTime-GetTimeStamp())
|
2020-08-14 13:32:55 +08:00
|
|
|
|
end,1,-1,true)
|
|
|
|
|
self.localTimer:Start()
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
2020-08-14 13:32:55 +08:00
|
|
|
|
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[10535]..curGiftList[curIndex].dynamicBuyTimes..Language[10054]
|
2020-08-25 17:59:34 +08:00
|
|
|
|
self.price.text = string.format(MoneyUtil.GetMoneyUnitName(), MoneyUtil.GetMoney(RechargeConfig[curGiftId].Price))--..MoneyUtil.GetMoneyUnitName()
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function HeroStarFeedPage:OnClose()
|
2020-08-14 13:32:55 +08:00
|
|
|
|
Log("HeroStarFeedPage:OnClose()")
|
|
|
|
|
if self.localTimer then
|
|
|
|
|
self.localTimer:Stop()
|
|
|
|
|
self.localTimer = nil
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
self.isClose = true
|
2020-08-14 13:32:55 +08:00
|
|
|
|
self.gameObject:SetActive(false)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function HeroStarFeedPage:OnDestroy()
|
2020-08-14 13:32:55 +08:00
|
|
|
|
cursortingOrder = 0
|
|
|
|
|
_ItemViewList = {}
|
|
|
|
|
if self.localTimer then
|
|
|
|
|
self.localTimer:Stop()
|
|
|
|
|
self.localTimer = nil
|
|
|
|
|
end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return HeroStarFeedPage
|