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

80 lines
2.3 KiB
Lua
Raw Normal View History

2020-08-06 17:52:32 +08:00
require("Base/BasePanel")
2020-05-09 13:31:21 +08:00
NoticePopup = Inherit(BasePanel)
local this = NoticePopup
local LoginRoot_Url = VersionManager: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()
local timeStamp = Time.realtimeSinceStartup
local timeSign = Util.MD5Encrypt(string.format("%s%s", timeStamp, LoginManager.sign))
2020-06-23 18:36:24 +08:00
RequestPanel.Show(Language[11128])
2020-05-09 13:31:21 +08:00
networkMgr:SendGetHttp(LoginRoot_Url .. "jl_loginserver/getNotice?timestamp="..timeStamp.."&sign=".. timeSign,
function (str)
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
this.TitleText.text=data.parms.title
this.ContentText.text=string.gsub(data.parms.content, "\\n", "\n")
else
2020-06-23 18:36:24 +08:00
this.TitleText.text=Language[11129]
this.ContentText.text=Language[11130]
2020-05-09 13:31:21 +08:00
end
end, nil, nil, nil)
end
2020-06-23 18:36:24 +08:00
return NoticePopup