146 lines
4.3 KiB
Lua
146 lines
4.3 KiB
Lua
-- xx界面
|
||
local CSPMsg = {}
|
||
|
||
---@type Coolape.CLPanelLua
|
||
local csSelf = nil
|
||
local transform = nil
|
||
CSPMsg.sizeAdjust = 1
|
||
CSPMsg.contentRect = Vector4.zero
|
||
local isShowdDragFrefresh = false
|
||
local dragVal = Vector3.zero
|
||
local objs = {}
|
||
local defaulList = {
|
||
{icon = "news_news_1", bgColor = 0xfff1c40f, type = DBMessage.MsgType.Sys, name = "公告"}
|
||
-- {icon="news_news_2", bgColor=0xff2990dc,type=DBMessage.MsgType.SysNotice, name="系统消息"},
|
||
-- {icon="news_news_3", bgColor=0xff1abc9c,type=DBMessage.MsgType.Task, name="待办任务"},
|
||
}
|
||
|
||
-- 初始化,只会调用一次
|
||
function CSPMsg.init(csObj)
|
||
csSelf = csObj
|
||
transform = csObj.transform
|
||
CSPMsg.contentRect = MyUtl.getUIContent(csSelf, nil, nil, true)
|
||
|
||
objs.Content = getCC(transform, "PanelContent", "UIPanel")
|
||
objs.Content.transform.localPosition = Vector3.zero
|
||
objs.Content.clipOffset = Vector2.zero
|
||
objs.Content.baseClipRegion = CSPMsg.contentRect
|
||
|
||
---@type UIScrollView
|
||
objs.scrollView = objs.Content:GetComponent("UIScrollView")
|
||
objs.scrollView.dampenStrength = MyUtl.dampenStrength
|
||
---@type UITable
|
||
objs.Table = getCC(objs.scrollView.transform, "Table", "UITable")
|
||
objs.LoopGrid = getCC(objs.Table.transform, "msgList/Grid", "CLUILoopGrid")
|
||
|
||
objs.ButtonEndList = getChild(objs.Table.transform, "ButtonEndList")
|
||
objs.ButtonHeadList = getCC(objs.Table.transform, "ButtonHeadList", "UILabel")
|
||
end
|
||
|
||
-- 设置数据
|
||
function CSPMsg.setData(paras)
|
||
end
|
||
|
||
-- 显示,在c#中。show为调用refresh,show和refresh的区别在于,当页面已经显示了的情况,当页面再次出现在最上层时,只会调用refresh
|
||
function CSPMsg.show()
|
||
CSPMsg.setList()
|
||
|
||
objs.Content.onClipMove = CSPMsg.onClipMove
|
||
objs.scrollView.onDragStarted = CSPMsg.onDragStart
|
||
objs.scrollView.onDragFinished = CSPMsg.onDragEnd
|
||
end
|
||
|
||
function CSPMsg.setList()
|
||
objs.LoopGrid:setList(defaulList, CSPMsg.initCell)
|
||
|
||
objs.Table:Reposition()
|
||
objs.scrollView:ResetPosition()
|
||
csSelf:invoke4Lua(CSPMsg.repositon, 0.1)
|
||
end
|
||
|
||
function CSPMsg.onClipMove(panel)
|
||
if (not isShowdDragFrefresh) and objs.ButtonHeadList.isVisible then
|
||
isShowdDragFrefresh = true
|
||
dragVal = objs.Content.transform.localPosition
|
||
end
|
||
end
|
||
|
||
function CSPMsg.onDragStart()
|
||
objs.ButtonHeadList.transform.localPosition = Vector3.up * 30
|
||
SetActive(objs.ButtonHeadList.gameObject, true)
|
||
dragVal = Vector3.zero
|
||
isShowdDragFrefresh = false
|
||
end
|
||
|
||
function CSPMsg.onDragEnd()
|
||
SetActive(objs.ButtonHeadList.gameObject, false)
|
||
local offset = objs.Content.transform.localPosition - dragVal
|
||
if offset.y < -50 then
|
||
-- 刷数据
|
||
NetProto.send.announcement_query()
|
||
end
|
||
if isShowdDragFrefresh then
|
||
CSPMsg.repositon()
|
||
end
|
||
end
|
||
|
||
function CSPMsg.repositon()
|
||
objs.scrollView:ResetPosition()
|
||
end
|
||
|
||
function CSPMsg.initCell(cell, data)
|
||
cell:init(data, CSPMsg.onClickCell)
|
||
end
|
||
|
||
function CSPMsg.onClickCell(cell, data)
|
||
getPanelAsy("PanelSysMsgList", onLoadedPanelTT, data)
|
||
end
|
||
|
||
-- 刷新
|
||
function CSPMsg.refresh()
|
||
end
|
||
|
||
-- 关闭页面
|
||
function CSPMsg.hide()
|
||
end
|
||
|
||
-- 网络请求的回调;cmd:指命,succ:成功失败,msg:消息;paras:服务器下行数据
|
||
function CSPMsg.procNetwork(cmd, succ, msg, paras)
|
||
--[[
|
||
if(succ == 1) then
|
||
if(cmd == "xxx") then
|
||
-- TODO:
|
||
end
|
||
end
|
||
--]]
|
||
end
|
||
|
||
-- 处理ui上的事件,例如点击等
|
||
function CSPMsg.uiEventDelegate(go)
|
||
local goName = go.name
|
||
if (goName == "Button01") then
|
||
getPanelAsy("PanelPasswordSave", onLoadedPanelTT)
|
||
--[[
|
||
if isNilOrEmpty(__uid__) then
|
||
getPanelAsy("PanelLogin", onLoadedPanelTT, {function (uid)
|
||
if uid then
|
||
getPanelAsy("PanelPasswordSave", onLoadedPanelTT)
|
||
end
|
||
end}
|
||
)
|
||
else
|
||
-- 密码保护
|
||
getPanelAsy("PanelPasswordSave", onLoadedPanelTT)
|
||
end
|
||
--]]
|
||
end
|
||
end
|
||
|
||
-- 当按了返回键时,关闭自己(返值为true时关闭)
|
||
function CSPMsg.hideSelfOnKeyBack()
|
||
return false
|
||
end
|
||
|
||
--------------------------------------------
|
||
return CSPMsg
|