StartTimeTip = StartTimeTip or BaseClass(BaseView)
|
|
local StartTimeTip = StartTimeTip
|
|
|
|
--[[
|
|
活动开始321倒计时
|
|
使用范例
|
|
local data = {
|
|
time = time,--倒计时时间(目前只有3/2/1,多的数字要去加资源哦)
|
|
call_back = function() --时间到期回调函数
|
|
self.model:Fire(BeachConst.REQ_QUIT_SCENE)
|
|
end,
|
|
}
|
|
GlobalEventSystem:Fire(EventName.OPEN_START_TIME_TIP,data)
|
|
--]]
|
|
|
|
function StartTimeTip:__init()
|
|
self.base_file = "common"
|
|
self.layout_file = "StartTimeTip"
|
|
self.layer_name = "Main"
|
|
self.destroy_imm = true
|
|
self.change_scene_close = false
|
|
self.append_to_ctl_queue = false --是否要添加进界面堆栈
|
|
self.need_show_money = false --是否要显示顶部的金钱栏
|
|
self.change_scene_close = true
|
|
-- self.is_set_zdepth = true
|
|
self.click_bg_toClose = false
|
|
------------------------
|
|
-- 一级全屏界面:
|
|
self.hide_maincancas = false --隐藏主界面
|
|
self.use_background = false --不一定显示遮罩
|
|
------------------------
|
|
|
|
self.load_callback = function ()
|
|
self:LoadSuccess()
|
|
end
|
|
self.open_callback = function ( )
|
|
self:OpenSuccess()
|
|
end
|
|
self.close_win_callback = function ( )
|
|
self:Close()
|
|
end
|
|
self.destroy_callback = function ( )
|
|
self:DestroySuccess()
|
|
end
|
|
end
|
|
|
|
function StartTimeTip:Open( data )
|
|
self.data = data
|
|
self.data.end_time = data.time + TimeUtil:getServerTime() --把时间段转为时间戳,兼容计时器帧率不稳定的问题
|
|
BaseView.Open(self)
|
|
end
|
|
|
|
function StartTimeTip:LoadSuccess()
|
|
local nodes = {
|
|
"container/startTimeText:txt", "container:obj", "container/startTimeBg:img",
|
|
}
|
|
self:GetChildren(nodes)
|
|
lua_resM:setOutsideImageSprite(self, self.startTimeBg_img, GameResPath.GetCommonImage("com_start_tip"),true)
|
|
self:AddEvent()
|
|
-------------------------
|
|
SetSizeDelta(self.transform, ScreenWidth, ScreenHeight)
|
|
SetAnchoredPositionY(self.container, -209)
|
|
end
|
|
|
|
function StartTimeTip:AddEvent()
|
|
|
|
end
|
|
|
|
function StartTimeTip:OpenSuccess()
|
|
self:UpdateView()
|
|
end
|
|
|
|
function StartTimeTip:UpdateView()
|
|
self.clock_time = self.data.end_time - TimeUtil:getServerTime()
|
|
local call_back = self.data and self.data.call_back
|
|
|
|
local function clockFun()
|
|
self.startTimeText_txt.text = math.ceil(self.clock_time)
|
|
self.clock_time = self.data.end_time - TimeUtil:getServerTime()
|
|
if self.clock_time <= 0 then
|
|
self:Close()
|
|
if call_back then
|
|
call_back()
|
|
end
|
|
end
|
|
end
|
|
-- clockFun()
|
|
self.close_time_id = self.close_time_id or GlobalTimerQuest:AddPeriodQuest(clockFun, 0.3, -1)
|
|
end
|
|
|
|
function StartTimeTip:DestroySuccess( )
|
|
if self.close_time_id then
|
|
GlobalTimerQuest:CancelQuest(self.close_time_id)
|
|
self.close_time_id = nil
|
|
end
|
|
end
|