Files
tianrunCRM/Assets/trCRM/upgradeRes4Dev/priority/lua/ui/panel/CSPMain.lua
2020-07-04 14:41:25 +08:00

103 lines
3.3 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- xx界面
CSPMain = {}
---@type Coolape.CLPanelLua
local csSelf = nil
local transform = nil
CSPMain.sizeAdjust = 1
CSPMain.contentRect = Vector4.zero
local objs = {}
local bottomBtns = {
-- {id = 2, name = "培训", panel = "PanelTraining", Background = "icon_icon_73_peixun", Checkmark = "icon_icon_78_peixun2"},
{id = 1, name = "消息", panel = "PanelMsg", Background = "main_icon_news", Checkmark = "main_icon_news2"},
{id = 2, name = "工作", panel = "PanelTasks", Background = "main_icon_work", Checkmark = "main_icon_work2"},
{id = 3, name = "我的", panel = "PanelMine", Background = "main_icon_me", Checkmark = "main_icon_me2"}
}
-- 初始化,只会调用一次
function CSPMain.init(csObj)
csSelf = csObj
transform = csObj.transform
CSPMain.contentRect = MyUtl.getUIContent(csSelf)
--objs.Content = getCC(transform, "PanelContent", "UIPanel")
--objs.Content.transform.localPosition = Vector3.zero;
--objs.Content.clipOffset = Vector2.zero;
--objs.Content.baseClipRegion = CSPMain.contentRect;
-----@type UIScrollView
--objs.scrollView = objs.Content:GetComponent("UIScrollView");
objs.LabelTitle = getCC(transform, "AnchorTop/offset/LabelTitle", "UILabel")
objs.bottomGrid = getCC(transform, "AnchorBottom/offset/Grid", "UIGrid")
objs.bottomCellPrefab = getChild(objs.bottomGrid.transform, "00000").gameObject
end
-- 设置数据
function CSPMain.setData(paras)
end
-- 显示在c#中。show为调用refreshshow和refresh的区别在于当页面已经显示了的情况当页面再次出现在最上层时只会调用refresh
function CSPMain.show()
--objs.scrollView:ResetPosition()
CSPMain.setBottomBtns()
end
function CSPMain.setBottomBtns()
local width = NumEx.getIntPart(CSPMain.contentRect.z / #bottomBtns)
objs.bottomGrid.cellWidth = width
CLUIUtl.resetList4Lua(objs.bottomGrid, objs.bottomCellPrefab, bottomBtns, CSPMain.initBottomBtn)
end
function CSPMain.initBottomBtn(cell, data)
data.width = objs.bottomGrid.cellWidth
cell:init(data, CSPMain.onClickBottonBtn)
if data.id == 2 then
CSPMain.onClickBottonBtn(cell, data)
end
end
function CSPMain.onClickBottonBtn(cell, data)
cell.luaTable.setSelected(true)
objs.LabelTitle.text = data.name
if CLPanelManager.topPanel ~= nil and CLPanelManager.topPanel ~= csSelf then
hideTopPanel()
end
if not isNilOrEmpty(data.panel) then
getPanelAsy(data.panel, onLoadedPanelTT, data.params)
end
end
-- 刷新
function CSPMain.refresh()
end
-- 关闭页面
function CSPMain.hide()
end
-- 网络请求的回调cmd指命succ成功失败msg消息paras服务器下行数据
function CSPMain.procNetwork(cmd, succ, msg, paras)
--[[
if(succ == 1) then
if(cmd == "xxx") then
-- TODO:
end
end
--]]
end
-- 处理ui上的事件例如点击等
function CSPMain.uiEventDelegate(go)
local goName = go.name
if (goName == "Button01") then
end
end
-- 当按了返回键时关闭自己返值为true时关闭
function CSPMain.hideSelfOnKeyBack()
return false
end
--------------------------------------------
return CSPMain