140 lines
5.3 KiB
Lua
140 lines
5.3 KiB
Lua
|
require("Base/BasePanel")
|
||
|
OpenSeverWelfarePanel = Inherit(BasePanel)
|
||
|
local this = OpenSeverWelfarePanel
|
||
|
--初始化组件(用于子类重写)
|
||
|
function OpenSeverWelfarePanel:InitComponent()
|
||
|
this.closeBtn = Util.GetGameObject(self.transform, "bg/closeBtn")
|
||
|
this.titleText = Util.GetGameObject(self.transform, "bg/titleText"):GetComponent("Text")
|
||
|
this.rewardPre = Util.GetGameObject(self.gameObject, "rewardPre")
|
||
|
local v = Util.GetGameObject(self.gameObject, "rect"):GetComponent("RectTransform").rect
|
||
|
this.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, Util.GetGameObject(self.gameObject, "rect").transform,
|
||
|
this.rewardPre, nil, Vector2.New(v.width, v.height), 1, 1, Vector2.New(0,-5))
|
||
|
this.ScrollView.moveTween.MomentumAmount = 1
|
||
|
this.ScrollView.moveTween.Strength = 1
|
||
|
this.NoviceItemList={}--存储itemview 重复利用
|
||
|
end
|
||
|
|
||
|
--绑定事件(用于子类重写)
|
||
|
function OpenSeverWelfarePanel:BindEvent()
|
||
|
Util.AddClick(this.closeBtn, function()
|
||
|
self:ClosePanel()
|
||
|
end)
|
||
|
end
|
||
|
|
||
|
--添加事件监听(用于子类重写)
|
||
|
function OpenSeverWelfarePanel:AddListener()
|
||
|
end
|
||
|
|
||
|
--移除事件监听(用于子类重写)
|
||
|
function OpenSeverWelfarePanel:RemoveListener()
|
||
|
end
|
||
|
|
||
|
--界面打开时调用(用于子类重写)
|
||
|
function OpenSeverWelfarePanel:OnOpen(...)
|
||
|
|
||
|
end
|
||
|
|
||
|
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
|
||
|
function OpenSeverWelfarePanel:OnShow()
|
||
|
this.OnShowPanelData()
|
||
|
end
|
||
|
function OpenSeverWelfarePanel:OnSortingOrderChange()
|
||
|
for i, v in pairs(this.NoviceItemList) do
|
||
|
for j = 1, #this.NoviceItemList[i] do
|
||
|
if this.NoviceItemList[i][j] and this.NoviceItemList[i][j].gameObject then
|
||
|
this.NoviceItemList[i][j]:SetEffectLayer(self.sortingOrder)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
function this.OnShowPanelData()
|
||
|
local curAllData = TaskManager.GetCurShowAllAchievementData(TaskTypeDef.Achievement)
|
||
|
local AllData = {}
|
||
|
for i, v in pairs(curAllData) do
|
||
|
table.insert(AllData,v)
|
||
|
end
|
||
|
this.RewardTabsSort(AllData)
|
||
|
this.ScrollView:SetData(AllData, function (index, go)
|
||
|
this.SingleDataShow(go, AllData[index])
|
||
|
end)
|
||
|
end
|
||
|
|
||
|
function this.SingleDataShow(go,rewardData)
|
||
|
local activityRewardGo = go
|
||
|
activityRewardGo:SetActive(true)
|
||
|
local sConFigData = achievementConfig[rewardData.missionId]
|
||
|
local titleText = Util.GetGameObject(activityRewardGo, "titleImage/titleText"):GetComponent("Text")
|
||
|
titleText.text = sConFigData.ContentsShow
|
||
|
local itemGroup = Util.GetGameObject(activityRewardGo, "content")
|
||
|
--滚动条复用重设itemview
|
||
|
if this.NoviceItemList[go] then
|
||
|
for i = 1, 4 do
|
||
|
this.NoviceItemList[go][i].gameObject:SetActive(false)
|
||
|
end
|
||
|
for i = 1, #sConFigData.Reward do
|
||
|
if this.NoviceItemList[go][i] then
|
||
|
this.NoviceItemList[go][i]:OnOpen(false, {sConFigData.Reward[i][1],sConFigData.Reward[i][2]}, 0.9,false,false,false,sortingOrder)
|
||
|
this.NoviceItemList[go][i].gameObject:SetActive(true)
|
||
|
end
|
||
|
end
|
||
|
else
|
||
|
this.NoviceItemList[go]={}
|
||
|
for i = 1, 4 do
|
||
|
this.NoviceItemList[go][i] = SubUIManager.Open(SubUIConfig.ItemView, itemGroup.transform)
|
||
|
this.NoviceItemList[go][i].gameObject:SetActive(false)
|
||
|
end
|
||
|
for i = 1, #sConFigData.Reward do
|
||
|
this.NoviceItemList[go][i]:OnOpen(false, {sConFigData.Reward[i][1],sConFigData.Reward[i][2]}, 0.9,false,false,false,sortingOrder)
|
||
|
this.NoviceItemList[go][i].gameObject:SetActive(true)
|
||
|
end
|
||
|
end
|
||
|
local lingquButton = Util.GetGameObject(activityRewardGo.gameObject, "lingquButton")
|
||
|
Util.GetGameObject(lingquButton.gameObject, "redPoint"):SetActive(false)
|
||
|
local qianwangButton = Util.GetGameObject(activityRewardGo.gameObject, "qianwangButton")
|
||
|
local getFinishText = Util.GetGameObject(activityRewardGo.gameObject, "getFinishText")
|
||
|
local getRewardProgress = Util.GetGameObject(activityRewardGo.gameObject, "getRewardProgress")
|
||
|
local state = rewardData.state
|
||
|
local value = sConFigData.Values[2][1]
|
||
|
lingquButton:SetActive(state == 1)
|
||
|
qianwangButton:SetActive(state == 0)
|
||
|
getFinishText:SetActive(state == 2)
|
||
|
getRewardProgress:SetActive(state == 0)
|
||
|
getRewardProgress:GetComponent("Text").text = math.abs(rewardData.progress) .."/"..math.abs(value)
|
||
|
Util.AddOnceClick(qianwangButton, function()
|
||
|
if sConFigData.Jump then
|
||
|
JumpManager.GoJump(sConFigData.Jump[1])
|
||
|
end
|
||
|
end)
|
||
|
Util.AddOnceClick(lingquButton, function()
|
||
|
NetManager.TakeMissionRewardRequest(TaskTypeDef.Achievement,rewardData.missionId, function(msg)
|
||
|
UIManager.OpenPanel(UIName.RewardItemPopup,msg.drop,1,function()
|
||
|
this.OnShowPanelData()
|
||
|
end)
|
||
|
end)
|
||
|
end)
|
||
|
end
|
||
|
|
||
|
local sortTable = {
|
||
|
[1] = 2,
|
||
|
[2] = 0,
|
||
|
[0] = 1,
|
||
|
}
|
||
|
function this.RewardTabsSort(missions)
|
||
|
table.sort(missions,function(a,b)
|
||
|
if a.state == b.state then
|
||
|
return a.missionId < b.missionId
|
||
|
else
|
||
|
return sortTable[a.state] > sortTable[b.state]
|
||
|
end
|
||
|
end)
|
||
|
end
|
||
|
--界面关闭时调用(用于子类重写)
|
||
|
function OpenSeverWelfarePanel:OnClose()
|
||
|
end
|
||
|
|
||
|
--界面销毁时调用(用于子类重写)
|
||
|
function OpenSeverWelfarePanel:OnDestroy()
|
||
|
end
|
||
|
|
||
|
return OpenSeverWelfarePanel
|