209 lines
7.7 KiB
Lua
209 lines
7.7 KiB
Lua
|
|
local HHBJPage = {}
|
|
local cardData = {
|
|
[1] = { curState = 0 ,cardType = 2211},
|
|
[2] = { curState = 0 ,cardType = 2212},
|
|
[3] = { curState = 0 ,cardType = 2213}
|
|
}
|
|
local sortingOrder = 0
|
|
local addTimeNum = 30 * 24 * 60 * 60
|
|
local monthCardConFig = ConfigManager.GetConfig(ConfigName.MonthcardConfig)
|
|
|
|
function HHBJPage:New(gameObject)
|
|
local b = {}
|
|
b.gameObject = gameObject
|
|
b.transform = gameObject.transform
|
|
setmetatable(b, { __index = HHBJPage })
|
|
return b
|
|
end
|
|
local offSetX = {
|
|
[0] = Vector3.New(71.1,-7.34,0),
|
|
[1] = Vector3.New(188,-56,0),
|
|
[2] = Vector3.New(188,-56,0),
|
|
}
|
|
--初始化组件(用于子类重写)
|
|
function HHBJPage:InitComponent()
|
|
self.spLoader = SpriteLoader.New()
|
|
self.grid = Util.GetGameObject(self.gameObject, "grid")
|
|
self.cardPres = {}
|
|
self.timerList = {}
|
|
for i= 1 ,self.grid.transform.childCount do
|
|
self.cardPres[i] = {}
|
|
self.cardPres[i].go = self.grid.transform:GetChild(i - 1).gameObject
|
|
self.cardPres[i].month = Util.GetGameObject(self.cardPres[i].go, "small")
|
|
self.cardPres[i].btnText = Util.GetGameObject(self.cardPres[i].month, "Text"):GetComponent("Text")
|
|
self.cardPres[i].monthRedPot = Util.GetGameObject(self.cardPres[i].month, "redPoint")
|
|
self.cardPres[i].monthRedPot:SetActive(false)
|
|
self.cardPres[i].time = Util.GetGameObject(self.cardPres[i].go, "time")
|
|
self.cardPres[i].activRewardGrid=Util.GetGameObject(self.cardPres[i].go, "reward/activScroll/activRewardGrid")
|
|
self.cardPres[i].dayRewardGrid=Util.GetGameObject(self.cardPres[i].go, "reward/dayScroll/dayRewardGrid")
|
|
-- Util.GetGameObject(self.cardPres[i].go, "day/icon"):GetComponent("RectTransform").anchoredPosition = offSetX[GetCurLanguage()]
|
|
end
|
|
end
|
|
|
|
--绑定事件(用于子类重写)
|
|
function HHBJPage:BindEvent()
|
|
|
|
end
|
|
|
|
--添加事件监听(用于子类重写)
|
|
function HHBJPage:AddListener()
|
|
Game.GlobalEvent:AddEvent(GameEvent.MoneyPay.OnPayResultSuccess, self.BuySuccess)
|
|
Game.GlobalEvent:AddEvent(GameEvent.MonthCard.OnMonthCardUpdate, function()
|
|
MonthCardManager.RefreshMonthCardEnd()
|
|
PlayerPrefs.SetInt(PlayerManager.uid.."monthCard", 1)
|
|
self:RefreshStoneShow()
|
|
end)
|
|
end
|
|
|
|
--移除事件监听(用于子类重写)
|
|
function HHBJPage:RemoveListener()
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.MoneyPay.OnPayResultSuccess, self.BuySuccess)
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.MonthCard.OnMonthCardUpdate, function()
|
|
|
|
PlayerPrefs.SetInt(PlayerManager.uid.."monthCard", 1)
|
|
self:RefreshStoneShow()
|
|
end)
|
|
end
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
function HHBJPage:OnOpen(_activityConfig,_index,parent)
|
|
self.actConfig = _activityConfig
|
|
self.pageIndex = _index
|
|
self.parent = parent
|
|
end
|
|
|
|
function HHBJPage:OnSortingOrderChange()
|
|
end
|
|
|
|
-- 打开,重新打开时回调
|
|
function HHBJPage:OnShow(_sortingOrder)
|
|
self.gameObject:SetActive(true)
|
|
sortingOrder = _sortingOrder
|
|
self:RefreshStoneShow()
|
|
end
|
|
local gifts={}
|
|
local activityData={}
|
|
-- 妖晶数量显示
|
|
function HHBJPage:RefreshStoneShow(index)
|
|
gifts=ConfigManager.GetConfigData(ConfigName.GlobalActivity,10401).CanBuyRechargeId
|
|
activityData=ActivityGiftManager.GetActivityInfoByType(10401)
|
|
if activityData and activityData.mission then
|
|
for i = 1, #activityData.mission do
|
|
LogError("missions "..activityData.mission[i].state)
|
|
end
|
|
end
|
|
|
|
for i = 1, #gifts do
|
|
LogError("gifts======"..gifts[i])
|
|
end
|
|
--月卡
|
|
for i = 1, #self.cardPres do
|
|
self:SetCardShow(i)
|
|
end
|
|
end
|
|
local baseItems={}
|
|
local extraItems={}
|
|
function HHBJPage:SetCardShow(i)
|
|
local cardType=cardData[i].cardType
|
|
local rechargeConfig = ConfigManager.GetConfigData(ConfigName.RechargeCommodityConfig,gifts[i])
|
|
local state=0
|
|
for j = 1, #activityData.mission do
|
|
LogError("activityData.mission[i].activityId=="..activityData.mission[j].missionId)
|
|
if activityData.mission[j].missionId==gifts[i] then
|
|
state=activityData.mission[i].state
|
|
|
|
end
|
|
end
|
|
self.cardPres[i].month:SetActive(true)
|
|
--self.cardPres[i].monthRedPot:SetActive(MonthCardManager.RefreshMonthCardRedPoint(cardType))
|
|
---设置按钮显示
|
|
LogError("state=="..state)
|
|
self.cardPres[i].monthRedPot:SetActive(state==1)
|
|
if state == 0 then
|
|
Util.SetGray(self.cardPres[i].month,false)
|
|
self.cardPres[i].month:GetComponent("Button").enabled = true
|
|
self.cardPres[i].btnText.text = rechargeConfig.Price.."元"
|
|
elseif state == 1 then
|
|
Util.SetGray(self.cardPres[i].month,false)
|
|
self.cardPres[i].month:GetComponent("Button").enabled = true
|
|
self.cardPres[i].btnText.text = "领取"
|
|
elseif state == 2 then
|
|
Util.SetGray(self.cardPres[i].month,true)
|
|
self.cardPres[i].month:GetComponent("Button").enabled = false
|
|
self.cardPres[i].btnText.text = Language[10101]
|
|
end
|
|
Util.AddOnceClick(self.cardPres[i].month,function()
|
|
if state==0 then
|
|
PayManager.Pay(gifts[i], function()
|
|
-- self.curAllMonthCardData = MonthCardManager.GetMonthCardData()
|
|
Util.SetGray(self.cardPres[i].month,false)
|
|
self.cardPres[i].month:GetComponent("Button").enabled = true
|
|
self.cardPres[i].btnText.text = "领取"
|
|
--self.cardPres[i].monthRedPot:SetActive(true)
|
|
CheckRedPointStatus(RedPointType.haoHuaBuJi)
|
|
self.cardPres[i].monthRedPot:SetActive(true)
|
|
state=1
|
|
-- self:RefreshStoneShow()
|
|
end)
|
|
elseif state==1 then
|
|
NetManager.GetActivityRewardRequest(gifts[i],10401, function(_drop)
|
|
UIManager.OpenPanel(UIName.RewardItemPopup, _drop, 1)
|
|
Util.SetGray(self.cardPres[i].month,true)
|
|
self.cardPres[i].month:GetComponent("Button").enabled = false
|
|
self.cardPres[i].btnText.text = Language[10101]
|
|
CheckRedPointStatus(RedPointType.haoHuaBuJi)
|
|
self.cardPres[i].monthRedPot:SetActive(false)
|
|
state=2
|
|
end)
|
|
end
|
|
|
|
end)
|
|
if self.cardPres[i].activRewardGrid.transform.childCount<=0 then
|
|
---设置奖励物品显示
|
|
local curBaseItems={}
|
|
if rechargeConfig.BaseReward then
|
|
for j = 1, #rechargeConfig.BaseReward do
|
|
if baseItems[i] and baseItems[i][j] then
|
|
baseItems[i][j]:OnOpen(false, rechargeConfig.BaseReward[j], 0.6)
|
|
else
|
|
local itemInfo = SubUIManager.Open(SubUIConfig.ItemView, self.cardPres[i].activRewardGrid.transform)
|
|
itemInfo:OnOpen(false, rechargeConfig.BaseReward[j], 0.6)
|
|
table.insert(curBaseItems,itemInfo)
|
|
end
|
|
end
|
|
end
|
|
table.insert(baseItems,curBaseItems)
|
|
local curExItems={}
|
|
for j = 1, #rechargeConfig.ExtraReward do
|
|
if extraItems[i] and extraItems[i][j] then
|
|
extraItems[i][j]:OnOpen(false, rechargeConfig.ExtraReward[j], 0.6)
|
|
else
|
|
local itemInfo = SubUIManager.Open(SubUIConfig.ItemView, self.cardPres[i].dayRewardGrid.transform)
|
|
itemInfo:OnOpen(false, rechargeConfig.ExtraReward[j], 0.6)
|
|
table.insert(curExItems,itemInfo)
|
|
end
|
|
end
|
|
table.insert(extraItems,curExItems)
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
--界面关闭时调用(用于子类重写)
|
|
function HHBJPage:OnClose()
|
|
self.gameObject:SetActive(false)
|
|
end
|
|
--界面销毁时调用(用于子类重写)
|
|
function HHBJPage:OnDestroy()
|
|
self.spLoader:Destroy()
|
|
self.cardPres = {}
|
|
gifts={}
|
|
activityData={}
|
|
baseItems={}
|
|
extraItems={}
|
|
end
|
|
return HHBJPage
|
|
|