local this = class("pageGatewayAnnouncementWindow", G_UIPageBase)

function this.bind()
  return {
    txtOK = "",
    title = "",
    moduleWebView = {
      moduleName = "pages/common/modules/webView"
    }
  }
end

function this.methods()
  return {
    onClick_bg = function(self)
      L_UI:close(self.pageName)
      if self.onClickCloseCallback then
        self.onClickCloseCallback()
      end
    end,
    onClick_close = function(self)
      L_UI:close(self.pageName)
      if self.onClickCloseCallback then
        self.onClickCloseCallback()
      end
    end,
    onClick_ok = function(self)
      L_UI:close(self.pageName)
      if self.onClickOkCallback then
        self.onClickOkCallback()
      end
    end
  }
end

function this:created(...)
  this.super.created(self, ...)
end

function this:preOpen(options)
  this.super.preOpen(self, options)
  self:initOptions(options)
end

function this:initOptions(options)
  options = options or {}
  if options.title then
    self.bind.title = options.title
  end
  if options.txtOK then
    self.bind.txtOK = options.txtOK
  end
  self.onClickOkCallback = options.onClickOkCallback
  self.onClickCloseCallback = options.onClickCloseCallback
  self.resourceUrl = options.url
  if self.resourceUrl then
    local cdnUrl = C_InfoManager.CdnUrl
    local newCdnUrl = string.sub(cdnUrl, 1, -11)
    local url = newCdnUrl .. self.resourceUrl
    printf(string.format("\231\189\145\229\133\179\229\133\172\229\145\138,  newCdnUrl=%s,  resourceUrl=%s,  url=%s", newCdnUrl, self.resourceUrl, url))
    self.modules.moduleWebView:setUrl(url)
  else
    errorf("\230\178\161\230\156\137\231\189\145\229\133\179\229\133\172\229\145\138\229\134\133\229\174\185url")
  end
end

function this:open()
  this.super.open(self)
  self:openWebView()
end

function this:close()
  this.super.close(self)
end

function this:openWebView()
  self.modules.moduleWebView:setResolution(1)
  self.modules.moduleWebView:showLoading(false)
  if self.messageHandler == nil then
    self.messageHandler = handler(self, self.onMessageHandler)
  end
  self.modules.moduleWebView:setMessageHandler(self.messageHandler)
end

function this:onMessageHandler(message)
end

return this
