--通用消息弹出框View --author:-- MsgWindow = {} MsgWindow.MsgMode = { OkAndCancel = 1, OnlyOk = 2 } MsgWindow.RES_LIST = { "MessageBox", "MessageBox1" } local M = MsgWindow function MsgWindow.new(blur_view, tip, mode, url, showCheck, data) setmetatable(M, { __index = BaseWindow }) local self = setmetatable({}, { __index = M }) self.class = "MsgWindow" self._blur_view = blur_view self._close_destroy = true self._tip = tip self._mode = mode self.onOk = event("onOk", true) self.onCancel = event("onCancel", true) self.showCheck = showCheck self.data = data local self_url = url and url or "ui://Common/" .. MsgWindow.RES_LIST[self._mode] self:init(self_url) return self end function M:init(url) BaseWindow.init(self, url) self._close_destroy = true if not self.data or not self.data.closeZone then self._close_zone = false end local view = self._view local btn_ok = view:GetChild("btn_ok") btn_ok.onClick:Add(function() self.onOk() self:Destroy() end) local tex_message = view:GetChild("tex_message") if (self._tip) then tex_message.text = self._tip end local btn_close = view:GetChild('btn_close1') if not self.data or not self.data.openClose then btn_close.visible = false end if (btn_close ~= nil) then btn_close.onClick:Add( function() self:CloseEvent() end --self:Destroy() ) end self.btnCheck = view:GetChild("btnCheck") if self.btnCheck then self.btnCheck.visible = false if self.showCheck then self.btnCheck.selected = true self.btnCheck.visible = true end end if self.data and self.data.titleUrl then view:GetChild('n18').icon = self.data.titleUrl end end function M:Close() BaseWindow.Close(self) if (self._mode == MsgWindow.MsgMode.OkAndCancel) then self.onCancel() end end