2020-08-25 15:46:38 +08:00
|
|
|
|
-- local HeavenUnlockExtraRewardPanel = quick_class("HeavenUnlockExtraRewardPanel", BasePanel)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
require("Base/BasePanel")
|
|
|
|
|
local HeavenUnlockExtraRewardPanel = Inherit(BasePanel)
|
|
|
|
|
local this = HeavenUnlockExtraRewardPanel
|
|
|
|
|
|
|
|
|
|
local rewardStateData = {}
|
|
|
|
|
local treasureState--礼包状态
|
|
|
|
|
local rewardData--表内活动数据
|
2020-08-19 10:05:01 +08:00
|
|
|
|
local curType = 0
|
|
|
|
|
local type = {
|
2020-08-25 15:46:38 +08:00
|
|
|
|
[1]={name=Language[12365],id = 106,goodsType = GoodsTypeDef.TreasureOfHeaven},
|
|
|
|
|
[2] = {name=Language[12348],id = 5001,goodsType = GoodsTypeDef.FindBaby},
|
2020-08-19 10:05:01 +08:00
|
|
|
|
}
|
2020-06-03 19:09:01 +08:00
|
|
|
|
|
|
|
|
|
--初始化组件(用于子类重写)
|
|
|
|
|
function HeavenUnlockExtraRewardPanel:InitComponent()
|
|
|
|
|
this.btnBack = Util.GetGameObject(this.transform, "frame/bg/closeBtn")
|
|
|
|
|
this.btnBack2 = Util.GetGameObject(this.transform, "frame")
|
|
|
|
|
this.dealBtn = Util.GetGameObject(this.transform, "frame/bg/dealBtn")
|
|
|
|
|
this.Content = Util.GetGameObject(this.transform, "rewardPart/Viewport/Content")
|
|
|
|
|
this.box1 = Util.GetGameObject(this.Content, "box1")
|
|
|
|
|
this.box2 = Util.GetGameObject(this.Content, "box2")
|
|
|
|
|
this.taskList = {}
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--绑定事件(用于子类重写)
|
|
|
|
|
function HeavenUnlockExtraRewardPanel:BindEvent()
|
|
|
|
|
Util.AddClick(this.btnBack, function()
|
|
|
|
|
this:ClosePanel()
|
|
|
|
|
end)
|
|
|
|
|
Util.AddClick(this.btnBack2, function()
|
|
|
|
|
this:ClosePanel()
|
|
|
|
|
end)
|
|
|
|
|
Util.AddOnceClick(this.dealBtn,function()
|
2020-07-13 16:48:50 +08:00
|
|
|
|
if AppConst.isSDKLogin then
|
2020-08-19 10:05:01 +08:00
|
|
|
|
PayManager.Pay({Id = type[curType].id})
|
2020-06-03 19:09:01 +08:00
|
|
|
|
else
|
2020-08-19 10:05:01 +08:00
|
|
|
|
NetManager.RequestBuyGiftGoods(type[curType].id,function()
|
2020-06-03 19:09:01 +08:00
|
|
|
|
this.RechargeSuccessFunc()
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function HeavenUnlockExtraRewardPanel:OnSortingOrderChange()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面打开时调用(用于子类重写)
|
2020-08-19 10:05:01 +08:00
|
|
|
|
function HeavenUnlockExtraRewardPanel:OnOpen(_type)
|
|
|
|
|
curType = _type
|
2020-06-03 19:09:01 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 打开,重新打开时回调
|
|
|
|
|
function HeavenUnlockExtraRewardPanel:OnShow()
|
2020-08-19 10:05:01 +08:00
|
|
|
|
if curType == 1 then
|
|
|
|
|
rewardStateData = TreasureOfHeavenManger.GetState()
|
|
|
|
|
rewardData = TreasureOfHeavenManger.GetAllRewardData()
|
|
|
|
|
HeavenUnlockExtraRewardPanel:showRewardTianGong()
|
|
|
|
|
elseif curType == 2 then
|
|
|
|
|
rewardData = QinglongSerectTreasureManager.GetAllRewardData()
|
|
|
|
|
HeavenUnlockExtraRewardPanel:showRewardQinglong()
|
|
|
|
|
end
|
2020-06-03 19:09:01 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--充值成功
|
|
|
|
|
function HeavenUnlockExtraRewardPanel:RechargeSuccessFunc()
|
2020-06-23 18:36:24 +08:00
|
|
|
|
PopupTipPanel.ShowTip(Language[11987])
|
2020-08-19 10:05:01 +08:00
|
|
|
|
FirstRechargeManager.RefreshAccumRechargeValue(type[curType].id)
|
|
|
|
|
OperatingManager.RefreshGiftGoodsBuyTimes(type[curType].goodsType,type[curType].id)
|
|
|
|
|
if curType == 1 then
|
|
|
|
|
TreasureOfHeavenManger.SetTreasureState()
|
|
|
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.TreasureOfHeaven.RechargeSuccess)
|
|
|
|
|
elseif curType == 2 then
|
|
|
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.TreasureOfHeaven.RechargeQinglongSerectSuccess)
|
|
|
|
|
end
|
|
|
|
|
|
2020-06-03 19:09:01 +08:00
|
|
|
|
this:ClosePanel()
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--直接/间接奖励
|
2020-08-19 10:05:01 +08:00
|
|
|
|
function HeavenUnlockExtraRewardPanel:showRewardTianGong()
|
2020-06-03 19:09:01 +08:00
|
|
|
|
|
|
|
|
|
local direct = {}
|
|
|
|
|
local indirect ={}
|
|
|
|
|
|
|
|
|
|
for i = 1, #rewardData do
|
|
|
|
|
if rewardStateData[i].state == 1 then--已达成但不能领取的
|
|
|
|
|
-- body
|
|
|
|
|
local reward = rewardData[i]
|
|
|
|
|
local k1 = reward.TreasureReward[1][1]
|
|
|
|
|
local v1 = reward.TreasureReward[1][2]
|
|
|
|
|
local k2 = reward.TreasureReward[2][1]
|
|
|
|
|
local v2 = reward.TreasureReward[2][2]
|
|
|
|
|
|
|
|
|
|
if not direct[k1] then
|
|
|
|
|
direct[k1] = 0
|
|
|
|
|
end
|
|
|
|
|
direct[k1] = direct[k1] + v1
|
|
|
|
|
|
|
|
|
|
if not direct[k2] then
|
|
|
|
|
direct[k2] = 0
|
|
|
|
|
end
|
|
|
|
|
direct[k2] = direct[k2] + v2
|
|
|
|
|
|
|
|
|
|
elseif rewardStateData[i].state == 0 then--未达成且不能领取的
|
|
|
|
|
local reward = rewardData[i]
|
|
|
|
|
local k1 = reward.TreasureReward[1][1]
|
|
|
|
|
local v1 = reward.TreasureReward[1][2]
|
|
|
|
|
local k2 = reward.TreasureReward[2][1]
|
|
|
|
|
local v2 = reward.TreasureReward[2][2]
|
|
|
|
|
|
|
|
|
|
if not indirect[k1] then
|
|
|
|
|
indirect[k1] = 0
|
|
|
|
|
end
|
|
|
|
|
indirect[k1] = indirect[k1] + v1
|
|
|
|
|
|
|
|
|
|
if not indirect[k2] then
|
|
|
|
|
indirect[k2] = 0
|
|
|
|
|
end
|
|
|
|
|
indirect[k2] = indirect[k2] + v2
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if #this.taskList == 0 then
|
|
|
|
|
for key, value in pairs(direct) do
|
|
|
|
|
local item = SubUIManager.Open(SubUIConfig.ItemView, this.box1.transform)
|
|
|
|
|
item:OnOpen(false,{key, value},0.9)
|
|
|
|
|
table.insert(this.taskList,{key, value})
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
for key, value in pairs(indirect) do
|
|
|
|
|
local item = SubUIManager.Open(SubUIConfig.ItemView, this.box2.transform)
|
|
|
|
|
item:OnOpen(false,{key, value},0.9)
|
|
|
|
|
table.insert(this.taskList,{key, value})
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2020-08-19 10:05:01 +08:00
|
|
|
|
--直接/间接奖励
|
|
|
|
|
function HeavenUnlockExtraRewardPanel:showRewardQinglong()
|
|
|
|
|
local direct = {}
|
|
|
|
|
local indirect ={}
|
|
|
|
|
|
|
|
|
|
for i = 1, #rewardData do
|
|
|
|
|
-- body
|
|
|
|
|
local reward = rewardData[i]
|
|
|
|
|
for j=1,#reward.Reward do
|
|
|
|
|
local id = reward.Reward[j].item[1]
|
|
|
|
|
local num = reward.Reward[j].item[2]
|
|
|
|
|
if reward.Reward[j].type == 2 then
|
|
|
|
|
if rewardData[i].state == 1 or rewardData[i].state == 0 then
|
|
|
|
|
if not direct[id] then
|
|
|
|
|
direct[id] = 0
|
|
|
|
|
end
|
|
|
|
|
direct[id] = direct[id] + num
|
|
|
|
|
elseif rewardData[i].state == -2 then
|
|
|
|
|
if not indirect[id] then
|
|
|
|
|
indirect[id] = 0
|
|
|
|
|
end
|
|
|
|
|
indirect[id] = indirect[id] + num
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if #this.taskList == 0 then
|
|
|
|
|
for key, value in pairs(direct) do
|
|
|
|
|
local item = SubUIManager.Open(SubUIConfig.ItemView, this.box1.transform)
|
|
|
|
|
item:OnOpen(false,{key, value},0.9)
|
|
|
|
|
table.insert(this.taskList,{key, value})
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
for key, value in pairs(indirect) do
|
|
|
|
|
local item = SubUIManager.Open(SubUIConfig.ItemView, this.box2.transform)
|
|
|
|
|
item:OnOpen(false,{key, value},0.9)
|
|
|
|
|
table.insert(this.taskList,{key, value})
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2020-06-03 19:09:01 +08:00
|
|
|
|
|
|
|
|
|
--界面关闭时调用(用于子类重写)
|
|
|
|
|
function HeavenUnlockExtraRewardPanel:OnClose()
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
|
|
|
function HeavenUnlockExtraRewardPanel:OnDestroy()
|
|
|
|
|
end
|
|
|
|
|
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return HeavenUnlockExtraRewardPanel
|