2020-08-25 15:46:38 +08:00
|
|
|
|
local LeiJiChongZhiPage = quick_class("LeiJiChongZhiPage")
|
2020-08-20 17:36:19 +08:00
|
|
|
|
local allData={}
|
|
|
|
|
local itemsGrid = {}--item重复利用
|
2020-08-20 18:32:14 +08:00
|
|
|
|
local this=LeiJiChongZhiPage
|
2020-08-20 17:36:19 +08:00
|
|
|
|
local parent
|
|
|
|
|
local endtime = 0
|
2020-08-21 18:30:44 +08:00
|
|
|
|
local rechargeNum
|
2020-11-04 03:51:04 +08:00
|
|
|
|
local type = 0
|
2020-08-20 18:32:14 +08:00
|
|
|
|
function LeiJiChongZhiPage:ctor(mainPanel, gameObject)
|
2020-08-20 17:36:19 +08:00
|
|
|
|
self.mainPanel = mainPanel
|
|
|
|
|
self.gameObject = gameObject
|
|
|
|
|
self:InitComponent(gameObject)
|
|
|
|
|
self:BindEvent()
|
|
|
|
|
end
|
|
|
|
|
|
2020-08-20 18:32:14 +08:00
|
|
|
|
function LeiJiChongZhiPage:InitComponent(gameObject)
|
2020-08-21 18:30:44 +08:00
|
|
|
|
this.time = Util.GetGameObject(gameObject, "tiao/time"):GetComponent("Text")
|
|
|
|
|
this.itemPre = Util.GetGameObject(gameObject, "ItemPre")
|
|
|
|
|
this.scrollItem = Util.GetGameObject(gameObject, "grid")
|
2020-09-24 17:26:27 +08:00
|
|
|
|
local rootHight = this.scrollItem.transform.rect.height
|
|
|
|
|
local width = this.scrollItem.transform.rect.width
|
2020-08-20 17:36:19 +08:00
|
|
|
|
this.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, this.scrollItem.transform,
|
2020-09-24 17:26:27 +08:00
|
|
|
|
this.itemPre, nil, Vector2.New(width, rootHight), 1, 1, Vector2.New(0, 30))
|
2020-08-20 17:36:19 +08:00
|
|
|
|
this.ScrollView.moveTween.MomentumAmount = 1
|
|
|
|
|
this.ScrollView.moveTween.Strength = 2
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--绑定事件(用于子类重写)
|
2020-08-20 18:32:14 +08:00
|
|
|
|
function LeiJiChongZhiPage:BindEvent()
|
2020-08-20 17:36:19 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--添加事件监听(用于子类重写)
|
2020-08-20 18:32:14 +08:00
|
|
|
|
function LeiJiChongZhiPage:AddListener()
|
2020-08-21 18:30:44 +08:00
|
|
|
|
|
2020-08-20 17:36:19 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--移除事件监听(用于子类重写)
|
2020-08-20 18:32:14 +08:00
|
|
|
|
function LeiJiChongZhiPage:RemoveListener()
|
2020-08-21 18:30:44 +08:00
|
|
|
|
|
2020-08-20 17:36:19 +08:00
|
|
|
|
end
|
|
|
|
|
local sortingOrder = 0
|
|
|
|
|
--界面打开时调用(用于子类重写)
|
2020-08-20 18:32:14 +08:00
|
|
|
|
function LeiJiChongZhiPage:OnOpen()
|
2020-08-20 17:36:19 +08:00
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
|
2020-11-04 03:51:04 +08:00
|
|
|
|
function LeiJiChongZhiPage:OnShow(_sortingOrder,_parent,_type)
|
|
|
|
|
type = _type
|
2020-08-21 18:30:44 +08:00
|
|
|
|
rechargeNum= VipManager.GetChargedNum()--已经充值的金额
|
2020-08-20 17:36:19 +08:00
|
|
|
|
sortingOrder = _sortingOrder
|
|
|
|
|
parent = _parent
|
2020-08-21 18:30:44 +08:00
|
|
|
|
this.Refresh()
|
2020-08-20 17:36:19 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this.Refresh()
|
|
|
|
|
this:OnShowData()
|
|
|
|
|
this:SetTime()
|
|
|
|
|
end
|
|
|
|
|
|
2020-08-20 18:32:14 +08:00
|
|
|
|
function LeiJiChongZhiPage:SetTime()
|
2020-08-20 17:36:19 +08:00
|
|
|
|
if self.timer then
|
|
|
|
|
self.timer:Stop()
|
|
|
|
|
self.timer = nil
|
|
|
|
|
end
|
2020-08-21 18:30:44 +08:00
|
|
|
|
local timeDown = endtime - GetTimeStamp()
|
2020-08-25 15:46:38 +08:00
|
|
|
|
this.time.text = Language[10028]..TimeToDHMS(timeDown)
|
2020-08-20 17:36:19 +08:00
|
|
|
|
self.timer = Timer.New(function()
|
2020-08-21 18:30:44 +08:00
|
|
|
|
timeDown = timeDown - 1
|
|
|
|
|
if timeDown < 1 then
|
2020-10-21 23:18:39 +08:00
|
|
|
|
self.timer:Stop()
|
|
|
|
|
self.timer = nil
|
|
|
|
|
this.time.text = Language[10028]..TimeToDHMS(0)
|
2020-08-21 18:30:44 +08:00
|
|
|
|
return
|
2020-08-20 17:36:19 +08:00
|
|
|
|
end
|
2020-08-25 15:46:38 +08:00
|
|
|
|
this.time.text = Language[10028]..TimeToDHMS(timeDown)
|
2020-08-20 17:36:19 +08:00
|
|
|
|
end, 1, -1, true)
|
|
|
|
|
self.timer:Start()
|
|
|
|
|
end
|
|
|
|
|
|
2020-08-20 18:32:14 +08:00
|
|
|
|
function LeiJiChongZhiPage:OnShowData()
|
2020-11-04 03:51:04 +08:00
|
|
|
|
allData =OperatingManager.InitLeiJiChongZhiData(type)
|
2020-08-20 17:36:19 +08:00
|
|
|
|
if allData then
|
2020-11-04 05:23:46 +08:00
|
|
|
|
endtime = ActivityGiftManager.GetTaskEndTime(type)
|
2020-08-20 17:36:19 +08:00
|
|
|
|
this.SortData(allData)
|
|
|
|
|
this.ScrollView:SetData(allData, function (index, go)
|
|
|
|
|
this.SingleDataShow(go, allData[index])
|
|
|
|
|
end)
|
|
|
|
|
else
|
|
|
|
|
parent.OnPageTabChange(1)
|
2020-08-25 15:46:38 +08:00
|
|
|
|
PopupTipPanel.ShowTip(Language[12320])
|
2020-08-20 17:36:19 +08:00
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
2020-08-21 18:30:44 +08:00
|
|
|
|
local typeIndex = {
|
|
|
|
|
[0] = 2,
|
|
|
|
|
[1] = 3,
|
|
|
|
|
[2] = 1,
|
|
|
|
|
}
|
2020-08-20 18:32:14 +08:00
|
|
|
|
function LeiJiChongZhiPage:SortData()
|
2020-08-20 17:36:19 +08:00
|
|
|
|
if allData==nil then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
table.sort(allData, function(a,b)
|
2020-08-21 18:30:44 +08:00
|
|
|
|
if typeIndex[a.state] == typeIndex[b.state] then
|
2020-08-20 17:36:19 +08:00
|
|
|
|
return a.id < b.id
|
2020-08-21 18:30:44 +08:00
|
|
|
|
else
|
|
|
|
|
return typeIndex[a.state] < typeIndex[b.state]
|
|
|
|
|
end
|
2020-08-20 17:36:19 +08:00
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
local type={
|
2020-08-25 15:46:38 +08:00
|
|
|
|
[0]={sprite = "s_slbz_1anniuhuangse",text = Language[10023]},
|
|
|
|
|
[1]={sprite = "s_slbz_1anniuhuise",text = Language[10350]},
|
|
|
|
|
[2]={sprite = "s_slbz_1anniuongse",text = Language[10022]},
|
2020-08-20 17:36:19 +08:00
|
|
|
|
}
|
|
|
|
|
--刷新每一条的显示数据
|
|
|
|
|
function this.SingleDataShow(pre,value)
|
|
|
|
|
if pre==nil or value==nil then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
--绑定组件
|
|
|
|
|
local activityRewardGo = pre
|
|
|
|
|
activityRewardGo:SetActive(true)
|
|
|
|
|
local sConFigData = value
|
|
|
|
|
|
2020-08-25 21:09:44 +08:00
|
|
|
|
local num = Util.GetGameObject(activityRewardGo, "context/num"):GetComponent("Text")
|
|
|
|
|
num.text = sConFigData.value
|
|
|
|
|
-- this:NumToNum(num, sConFigData.value)
|
2020-08-21 20:11:24 +08:00
|
|
|
|
-- num.text = sConFigData.value
|
2020-08-21 18:30:44 +08:00
|
|
|
|
local progress = Util.GetGameObject(activityRewardGo, "context/progress"):GetComponent("Text")
|
2020-08-25 15:46:38 +08:00
|
|
|
|
progress.text =Language[10471].."("..(sConFigData.progress > sConFigData.value and sConFigData.value or sConFigData.progress) .."/"..sConFigData.value..")"
|
2020-08-21 18:30:44 +08:00
|
|
|
|
|
|
|
|
|
local reward = Util.GetGameObject(activityRewardGo.gameObject, "scrollView/grid")
|
2020-08-20 17:36:19 +08:00
|
|
|
|
if (not itemsGrid) then
|
|
|
|
|
itemsGrid = {}
|
|
|
|
|
end
|
|
|
|
|
if not itemsGrid[pre] then
|
2020-08-21 18:30:44 +08:00
|
|
|
|
itemsGrid[pre] = {}
|
|
|
|
|
end
|
2020-08-22 20:50:45 +08:00
|
|
|
|
for _, item in pairs(itemsGrid[pre]) do
|
|
|
|
|
item.gameObject:SetActive(false)
|
|
|
|
|
end
|
2020-08-21 18:30:44 +08:00
|
|
|
|
for k,v in ipairs(sConFigData.reward) do
|
|
|
|
|
if not itemsGrid[pre][k] then
|
|
|
|
|
itemsGrid[pre][k] = SubUIManager.Open(SubUIConfig.ItemView,reward.transform)
|
|
|
|
|
end
|
|
|
|
|
itemsGrid[pre][k]:OnOpen(false, {v[1],v[2]}, 0.9, false)
|
2020-08-22 20:50:45 +08:00
|
|
|
|
itemsGrid[pre][k].gameObject:SetActive(true)
|
2020-08-20 17:36:19 +08:00
|
|
|
|
end
|
|
|
|
|
|
2020-08-21 18:30:44 +08:00
|
|
|
|
local lingquButton = Util.GetGameObject(activityRewardGo.gameObject, "btnBuy")
|
|
|
|
|
local state = sConFigData.state
|
2020-08-20 17:36:19 +08:00
|
|
|
|
local red = Util.GetGameObject(lingquButton.gameObject, "redPoint")
|
|
|
|
|
red:SetActive(state == 2)
|
|
|
|
|
|
2020-08-21 18:30:44 +08:00
|
|
|
|
Util.GetGameObject(lingquButton.gameObject, "price"):GetComponent("Text").text = type[state].text
|
|
|
|
|
lingquButton:GetComponent("Image").sprite = Util.LoadSprite(type[state].sprite)
|
|
|
|
|
lingquButton:GetComponent("Button").enabled = (state ~= 1)
|
2020-08-20 17:36:19 +08:00
|
|
|
|
|
2020-08-21 18:30:44 +08:00
|
|
|
|
Util.AddOnceClick(lingquButton, function()
|
2020-08-20 17:36:19 +08:00
|
|
|
|
if state == 2 then
|
2020-11-04 05:23:46 +08:00
|
|
|
|
local curActivityId = ActivityGiftManager.GetActivityIdByType(type)
|
2020-08-22 20:50:45 +08:00
|
|
|
|
NetManager.GetActivityRewardRequest(sConFigData.id, curActivityId,function(drop)
|
|
|
|
|
UIManager.OpenPanel(UIName.RewardItemPopup, drop, 1)
|
2020-08-20 17:36:19 +08:00
|
|
|
|
this.Refresh()
|
|
|
|
|
end)
|
|
|
|
|
elseif state == 0 then
|
|
|
|
|
if sConFigData.jump then
|
2020-08-21 18:30:44 +08:00
|
|
|
|
JumpManager.GoJump(sConFigData.jump)
|
2020-08-20 17:36:19 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
2020-08-21 20:11:24 +08:00
|
|
|
|
function LeiJiChongZhiPage:NumToNum(num,_value)
|
|
|
|
|
local value = _value
|
|
|
|
|
local isFirst = true
|
|
|
|
|
for i = 1, 5 do
|
|
|
|
|
local m = Util.GetGameObject(num,"num"..i)
|
|
|
|
|
m:SetActive(false)
|
|
|
|
|
local t1 = math.floor(value/math.pow(10, (5-i)))
|
|
|
|
|
value = value%(math.pow(10, (5-i)))
|
|
|
|
|
if t1<1 and isFirst then
|
|
|
|
|
m:SetActive(false)
|
|
|
|
|
else
|
|
|
|
|
m:SetActive(true)
|
|
|
|
|
isFirst = false
|
|
|
|
|
m:GetComponent("Text").text = t1
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2020-08-20 17:36:19 +08:00
|
|
|
|
--界面打开时调用(用于子类重写)
|
2020-08-20 18:32:14 +08:00
|
|
|
|
function LeiJiChongZhiPage:OnOpen()
|
2020-08-20 17:36:19 +08:00
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this.RechargeSuccessFunc(id)
|
2020-08-21 18:30:44 +08:00
|
|
|
|
|
2020-08-20 17:36:19 +08:00
|
|
|
|
end
|
|
|
|
|
|
2020-08-20 18:32:14 +08:00
|
|
|
|
function LeiJiChongZhiPage:OnClose()
|
2020-08-20 17:36:19 +08:00
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面销毁时调用(用于子类重写)
|
2020-08-20 18:32:14 +08:00
|
|
|
|
function LeiJiChongZhiPage:OnDestroy()
|
2020-08-22 10:09:30 +08:00
|
|
|
|
if self.timer then
|
|
|
|
|
self.timer:Stop()
|
|
|
|
|
self.timer = nil
|
|
|
|
|
end
|
2020-08-20 17:36:19 +08:00
|
|
|
|
sortingOrder = 0
|
2020-08-21 18:30:44 +08:00
|
|
|
|
allData={}
|
|
|
|
|
itemsGrid = {}
|
2020-08-20 17:36:19 +08:00
|
|
|
|
end
|
|
|
|
|
|
2020-08-20 18:32:14 +08:00
|
|
|
|
function LeiJiChongZhiPage:OnHide()
|
2020-08-22 10:09:30 +08:00
|
|
|
|
if self.timer then
|
|
|
|
|
self.timer:Stop()
|
|
|
|
|
self.timer = nil
|
|
|
|
|
end
|
2020-08-20 17:36:19 +08:00
|
|
|
|
sortingOrder = 0
|
|
|
|
|
end
|
|
|
|
|
--- 将一段时间转换为天时分秒
|
2020-08-20 18:32:14 +08:00
|
|
|
|
function LeiJiChongZhiPage:TimeToDHMS(second)
|
2020-08-20 17:36:19 +08:00
|
|
|
|
local day = math.floor(second / (24 * 3600))
|
|
|
|
|
local minute = math.floor(second / 60) % 60
|
|
|
|
|
local sec = second % 60
|
|
|
|
|
local hour = math.floor(math.floor(second - day * 24 * 3600 - sec - minute * 60) / 3600)
|
|
|
|
|
if day <= 0 and hour <= 0 then
|
|
|
|
|
return string.format(Language[12231],minute, sec)
|
|
|
|
|
else
|
|
|
|
|
return string.format(Language[12232],day, hour)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2020-08-20 18:32:14 +08:00
|
|
|
|
return LeiJiChongZhiPage
|