local UICommonTopTime = UIViewClass() function UICommonTopTime:OnOpened(context) if context.closeTime then --是进栈恢复的界面,此时需要重新计算时间 context.time = context.time - (UTL.Time.GetServerTimestamp() - context.closeTime) context.closeTime = nil end if context.time <= 0 then self:CloseView() return end self.openTime = UTL.Time.GetServerTimestamp() UIUtils.SetLabelText(self.lab_TimeTitle, context.titleIDS) self.timer:SetCustomString(context.timeFormat, 1, context.timeCustomType) self.timer:ResetAndBeginTimer(false, context.time) end --被压栈的时候,刷新一下倒计时 function UICommonTopTime:OnClosed() if self.openTime then self.context.time = self.context.time - (UTL.Time.GetServerTimestamp() - self.openTime) self.context.closeTime = UTL.Time.GetServerTimestamp() end end return UICommonTopTime