74 lines
2.5 KiB
Lua
74 lines
2.5 KiB
Lua
|
|
---@class _ParamCellMessageGroup
|
|||
|
|
---@field public icon string
|
|||
|
|
---@field public bgColor number
|
|||
|
|
---@field public type number
|
|||
|
|
---@field public name string
|
|||
|
|
|
|||
|
|
-- xx单元
|
|||
|
|
local _cell = {}
|
|||
|
|
---@type Coolape.CLCellLua
|
|||
|
|
local csSelf = nil
|
|||
|
|
local transform = nil
|
|||
|
|
---@type _ParamCellMessageGroup
|
|||
|
|
local mData = nil
|
|||
|
|
local uiobjs = {}
|
|||
|
|
|
|||
|
|
-- 初始化,只调用一次
|
|||
|
|
function _cell.init(csObj)
|
|||
|
|
csSelf = csObj
|
|||
|
|
transform = csSelf.transform
|
|||
|
|
uiobjs.Label = getCC(transform, "Label", "UILabel")
|
|||
|
|
uiobjs.LabelNewest = getCC(transform, "LabelNewest", "UILabel")
|
|||
|
|
uiobjs.LabelTime = getCC(transform, "LabelTime", "UILabel")
|
|||
|
|
uiobjs.LabelReddotNum = getCC(transform, "LabelReddotNum", "UILabel")
|
|||
|
|
uiobjs.SpriteIconBg = getCC(transform, "SpriteIconBg", "UISprite")
|
|||
|
|
uiobjs.Icon = getCC(uiobjs.SpriteIconBg.transform, "Icon", "UISprite")
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
-- 显示,
|
|||
|
|
-- 注意,c#侧不会在调用show时,调用refresh
|
|||
|
|
function _cell.show(go, data)
|
|||
|
|
mData = data
|
|||
|
|
uiobjs.Label.text = mData.name
|
|||
|
|
uiobjs.SpriteIconBg.color = ColorEx.getColor(mData.bgColor)
|
|||
|
|
uiobjs.Icon.spriteName = mData.icon
|
|||
|
|
if mData.type == DBMessage.MsgType.Sys then
|
|||
|
|
---@type _DBMessage
|
|||
|
|
local newestMsg = DBMessage.getNewestMessage(mData.type)
|
|||
|
|
uiobjs.LabelNewest.text = newestMsg and newestMsg.CONTENT or ""
|
|||
|
|
if newestMsg then
|
|||
|
|
local time = tonumber(newestMsg.CREATETIME) or 0
|
|||
|
|
uiobjs.LabelTime.text = DateEx.ToTimeCost(DateEx.nowMS - time * 1000)
|
|||
|
|
else
|
|||
|
|
uiobjs.LabelTime.text = ""
|
|||
|
|
end
|
|||
|
|
elseif mData.type == DBMessage.MsgType.Task then
|
|||
|
|
---@type _DBTaskCust
|
|||
|
|
-- local newestMsg = DBMessage.getNewestMessage(mData.type)
|
|||
|
|
-- local time = tonumber(newestMsg.createtime) or 0
|
|||
|
|
uiobjs.LabelTime.text = "" --DateEx.ToTimeCost(DateEx.nowMS - time * 1000)
|
|||
|
|
local num = DBMessage.getUnreadNum(mData.type)
|
|||
|
|
uiobjs.LabelNewest.text = joinStr("您有", num, "代办任务未处理")
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
if DBMessage.getUnreadNum(mData.type) > 0 then
|
|||
|
|
local unreadNum = DBMessage.getUnreadNum(mData.type) or 0
|
|||
|
|
if unreadNum and unreadNum > 9 then
|
|||
|
|
uiobjs.LabelReddotNum.text = "…"
|
|||
|
|
else
|
|||
|
|
uiobjs.LabelReddotNum.text = joinStr(unreadNum)
|
|||
|
|
end
|
|||
|
|
SetActive(uiobjs.LabelReddotNum.gameObject, true)
|
|||
|
|
else
|
|||
|
|
SetActive(uiobjs.LabelReddotNum.gameObject, false)
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
-- 取得数据
|
|||
|
|
function _cell.getData()
|
|||
|
|
return mData
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--------------------------------------------
|
|||
|
|
return _cell
|