99 lines
2.9 KiB
Lua
99 lines
2.9 KiB
Lua
|
---- 百宝商会活动弹窗 ----
|
||
|
require("Base/BasePanel")
|
||
|
local TreasureStorePopup = Inherit(BasePanel)
|
||
|
local this=TreasureStorePopup
|
||
|
local itemConfig=ConfigManager.GetConfig(ConfigName.ItemConfig)
|
||
|
|
||
|
function TreasureStorePopup:InitComponent()
|
||
|
this.panel=Util.GetGameObject(this.gameObject,"Panel")
|
||
|
this.backBtn=Util.GetGameObject(this.panel,"BackBtn")
|
||
|
this.time=Util.GetGameObject(this.panel,"Time")
|
||
|
|
||
|
this.scroll=Util.GetGameObject(this.panel,"Scroll")
|
||
|
this.scrollPre=Util.GetGameObject(this.scroll,"Pre")
|
||
|
this.scrollView=SubUIManager.Open(SubUIConfig.ScrollCycleView,this.scroll.transform,this.scrollPre, nil,--
|
||
|
Vector2.New(this.scroll.transform.rect.width,this.scroll.transform.rect.height),1,1,Vector2.New(0,10))
|
||
|
this.scrollView.gameObject:GetComponent("RectTransform").anchoredPosition= Vector2.New(0,0)
|
||
|
this.scrollView.gameObject:GetComponent("RectTransform").anchorMin = Vector2.New(0.5, 0.5)
|
||
|
this.scrollView.gameObject:GetComponent("RectTransform").anchorMax = Vector2.New(0.5, 0.5)
|
||
|
this.scrollView.gameObject:GetComponent("RectTransform").pivot = Vector2.New(0.5, 0.5)
|
||
|
this.scrollView.moveTween.MomentumAmount = 1
|
||
|
this.scrollView.moveTween.Strength = 2
|
||
|
end
|
||
|
|
||
|
function TreasureStorePopup:BindEvent()
|
||
|
Util.AddClick(this.backBtn,function()
|
||
|
self:ClosePanel()
|
||
|
end)
|
||
|
end
|
||
|
|
||
|
function TreasureStorePopup:AddListener()
|
||
|
end
|
||
|
|
||
|
function TreasureStorePopup:RemoveListener()
|
||
|
end
|
||
|
|
||
|
function TreasureStorePopup:OnOpen(...)
|
||
|
|
||
|
end
|
||
|
|
||
|
function TreasureStorePopup:OnShow()
|
||
|
this.RefreshPanel()
|
||
|
end
|
||
|
|
||
|
function TreasureStorePopup:OnClose()
|
||
|
if this.timer then
|
||
|
this.timer:Stop()
|
||
|
this.timer = nil
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function TreasureStorePopup:OnDestroy()
|
||
|
this.scrollView=nil
|
||
|
end
|
||
|
|
||
|
|
||
|
--刷新面板
|
||
|
function this.RefreshPanel()
|
||
|
-- this.TimeCountDown(timeDown)
|
||
|
local data={1,2,3}
|
||
|
this.scrollView:SetData(data,function(index,root)
|
||
|
this.SetScrollPre(root,data[index])
|
||
|
end)
|
||
|
this.scrollView:SetIndex(1)
|
||
|
end
|
||
|
|
||
|
--设置每一条
|
||
|
function this.SetScrollPre(root,data)
|
||
|
local title=Util.GetGameObject(root,"Title"):GetComponent("Text")
|
||
|
local iRoot=Util.GetGameObject(root,"ItemRoot")
|
||
|
local oldNum=Util.GetGameObject(root,"OldNum"):GetComponent("Text")
|
||
|
local buyBtn=Util.GetGameObject(root,"BuyBtn")
|
||
|
local buyNum=Util.GetGameObject(root,"BuyBtn/BuyNum"):GetComponent("Text")
|
||
|
local tip=Util.GetGameObject(root,"Tip"):GetComponent("Text")
|
||
|
|
||
|
end
|
||
|
|
||
|
|
||
|
--倒计时
|
||
|
function this.TimeCountDown(timeDown)
|
||
|
if this.timer then
|
||
|
this.timer:Stop()
|
||
|
this.timer = nil
|
||
|
end
|
||
|
this.time.text = "剩余时间:"..TimeToHMS(timeDown)
|
||
|
this.timer = Timer.New(function()
|
||
|
if timeDown < 1 then
|
||
|
this.timer:Stop()
|
||
|
this.timer = nil
|
||
|
this.RefreshPanel()
|
||
|
return
|
||
|
end
|
||
|
timeDown = timeDown - 1
|
||
|
this.time.text = "剩余时间:"..TimeToHMS(timeDown)
|
||
|
end, 1, -1, true)
|
||
|
this.timer:Start()
|
||
|
end
|
||
|
|
||
|
return TreasureStorePopup
|