103 lines
3.3 KiB
Lua
103 lines
3.3 KiB
Lua
-- 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为调用refresh,show和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
|