miduo_client/Assets/ManagedResources/~Lua/Modules/Login/NoticePopup.lua

81 lines
2.3 KiB
Lua

require("Base/BasePanel")
NoticePopup = Inherit(BasePanel)
local this = NoticePopup
local LoginRoot_Url = ServerConfigManager.GetVersionInfo("serverUrl")
--初始化组件(用于子类重写)
function NoticePopup:InitComponent()
this.BtnBack = Util.GetGameObject(self.transform, "bg/bg/btnBack")
this.TitleText=Util.GetGameObject(self.transform,"bg/bg/title"):GetComponent("Text")
this.ContentText=Util.GetGameObject(self.transform,"bg/bg/rect/content"):GetComponent("Text")
end
--绑定事件(用于子类重写)
function NoticePopup:BindEvent()
Util.AddClick(this.BtnBack, function()
self:ClosePanel()
end)
end
--添加事件监听(用于子类重写)
function NoticePopup:AddListener()
end
--移除事件监听(用于子类重写)
function NoticePopup:RemoveListener()
end
--界面打开时调用(用于子类重写)
function NoticePopup:OnOpen(...)
this.GetNotice(...)
end
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
function NoticePopup:OnShow()
end
--界面关闭时调用(用于子类重写)
function NoticePopup:OnClose()
end
--界面销毁时调用(用于子类重写)
function NoticePopup:OnDestroy()
end
function this.GetNotice(str)
-- local timeStamp = Time.realtimeSinceStartup
-- local timeSign = Util.MD5Encrypt(string.format("%s%s", timeStamp, LoginManager.sign))
-- RequestPanel.Show("正在获取公告信息")
-- networkMgr:SendGetHttp(LoginRoot_Url .. "jl_loginserver/getNotice?timestamp="..timeStamp.."&sign=".. timeSign,function (str)
-- end, nil, nil, nil)
RequestPanel.Hide()
if str == nil then
return
end
--Log(str)
local json = require 'cjson'
local data = json.decode(str)
--Log("data.parms.title:"..data.parms.title)
--Log("data.parms.content:"..data.parms.content)
if data.parms then
local titleStr = string.split(data.parms.title,"|")
this.TitleText.text =titleStr[GetCurLanguage()+1] or titleStr[1]
local contentStr = string.split(string.gsub(data.parms.content, "\\n", "\n"),"|")
this.ContentText.text = contentStr[GetCurLanguage()+1] or contentStr[1]
else
this.TitleText.text=Language[11147]
this.ContentText.text=Language[11148]
end
end
return NoticePopup