Files
tianrunCRM/Assets/trCRM/upgradeRes4Dev/priority/lua/ui/panel/CSPMsg.lua

146 lines
4.3 KiB
Lua
Raw Normal View History

2020-07-04 14:41:25 +08:00
-- xx界面
local CSPMsg = {}
2020-08-04 21:58:27 +08:00
---@type Coolape.CLPanelLua
2020-07-04 14:41:25 +08:00
local csSelf = nil
local transform = nil
CSPMsg.sizeAdjust = 1
CSPMsg.contentRect = Vector4.zero
2020-08-04 21:58:27 +08:00
local isShowdDragFrefresh = false
local dragVal = Vector3.zero
2020-07-04 14:41:25 +08:00
local objs = {}
local defaulList = {
2020-08-04 21:58:27 +08:00
{icon = "news_news_1", bgColor = 0xfff1c40f, type = DBMessage.MsgType.Sys, name = "公告"}
2020-08-01 17:55:18 +08:00
-- {icon="news_news_2", bgColor=0xff2990dc,type=DBMessage.MsgType.SysNotice, name="系统消息"},
-- {icon="news_news_3", bgColor=0xff1abc9c,type=DBMessage.MsgType.Task, name="待办任务"},
2020-07-04 14:41:25 +08:00
}
-- 初始化,只会调用一次
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")
2020-08-03 23:05:29 +08:00
objs.scrollView.dampenStrength = MyUtl.dampenStrength
2020-07-04 14:41:25 +08:00
---@type UITable
objs.Table = getCC(objs.scrollView.transform, "Table", "UITable")
objs.LoopGrid = getCC(objs.Table.transform, "msgList/Grid", "CLUILoopGrid")
2020-08-04 21:58:27 +08:00
objs.ButtonEndList = getChild(objs.Table.transform, "ButtonEndList")
objs.ButtonHeadList = getCC(objs.Table.transform, "ButtonHeadList", "UILabel")
2020-07-04 14:41:25 +08:00
end
-- 设置数据
function CSPMsg.setData(paras)
end
-- 显示在c#中。show为调用refreshshow和refresh的区别在于当页面已经显示了的情况当页面再次出现在最上层时只会调用refresh
function CSPMsg.show()
2020-08-04 21:58:27 +08:00
CSPMsg.setList()
objs.Content.onClipMove = CSPMsg.onClipMove
objs.scrollView.onDragStarted = CSPMsg.onDragStart
objs.scrollView.onDragFinished = CSPMsg.onDragEnd
end
function CSPMsg.setList()
2020-07-04 14:41:25 +08:00
objs.LoopGrid:setList(defaulList, CSPMsg.initCell)
2020-08-04 21:58:27 +08:00
2020-07-04 14:41:25 +08:00
objs.Table:Reposition()
objs.scrollView:ResetPosition()
2020-08-04 21:58:27 +08:00
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()
2020-07-04 14:41:25 +08:00
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