84 lines
2.4 KiB
Lua
84 lines
2.4 KiB
Lua
---@class _ParamModifyField
|
||
---@field label string 字段名
|
||
---@field key string 字段key
|
||
---@field value any 字段value
|
||
---@field canNull boolean
|
||
|
||
---@type IDBasePanel
|
||
local TRBasePanel = require("ui.panel.TRBasePanel")
|
||
---@class TRPModifyFiled:TRBasePanel
|
||
local TRPModifyFiled = class("TRPModifyFiled", TRBasePanel)
|
||
|
||
local uiobjs = {}
|
||
-- 初始化,只会调用一次
|
||
function TRPModifyFiled:init(csObj)
|
||
TRPModifyFiled.super.init(self, csObj)
|
||
|
||
self:setEventDelegate()
|
||
---@type CLUIElement
|
||
uiobjs.element = getCC(self.transform, "Top/Input", "CLUIElement")
|
||
uiobjs.Input = getCC(self.transform, "Top/Input", "UIInput")
|
||
uiobjs.Label = getCC(uiobjs.Input.transform, "Label2", "UILabel")
|
||
end
|
||
|
||
-- 设置数据
|
||
---@param paras _ParamTRPModifyFiled
|
||
function TRPModifyFiled:setData(paras)
|
||
---@type _ParamModifyField
|
||
self.mdata = paras
|
||
end
|
||
|
||
-- 显示,在c#中。show为调用refresh,show和refresh的区别在于,当页面已经显示了的情况,当页面再次出现在最上层时,只会调用refresh
|
||
function TRPModifyFiled:show()
|
||
uiobjs.element.jsonKey = self.mdata.jsonKey
|
||
uiobjs.element.canNull = self.mdata.canNull
|
||
uiobjs.Label.text = self.mdata.label
|
||
uiobjs.Input.value = self.mdata.value
|
||
end
|
||
|
||
-- 刷新
|
||
function TRPModifyFiled:refresh()
|
||
end
|
||
|
||
-- 关闭页面
|
||
function TRPModifyFiled:hide()
|
||
end
|
||
|
||
-- 网络请求的回调;cmd:指命,succ:成功失败,msg:消息;paras:服务器下行数据
|
||
function TRPModifyFiled:procNetwork(cmd, succ, msg, paras)
|
||
if (succ == NetSuccess) then
|
||
--[[
|
||
if cmd == xx then
|
||
end
|
||
]]
|
||
end
|
||
end
|
||
|
||
function TRPModifyFiled:setEventDelegate()
|
||
self.EventDelegate = {
|
||
ButtonOkay = function()
|
||
local err = uiobjs.element:checkValid()
|
||
if not isNilOrEmpty(err) then
|
||
MyUtl.toastW(err)
|
||
return
|
||
end
|
||
Utl.doCallback(self.mdata.callback, self.mdata.key, uiobjs.Input.value)
|
||
hideTopPanel(self.csSelf)
|
||
end
|
||
}
|
||
end
|
||
-- 处理ui上的事件,例如点击等
|
||
function TRPModifyFiled:uiEventDelegate(go)
|
||
local func = self.EventDelegate[go.name]
|
||
if func then
|
||
func()
|
||
end
|
||
end
|
||
|
||
-- 当顶层页面发生变化时回调
|
||
function TRPModifyFiled:onTopPanelChange(topPanel)
|
||
end
|
||
|
||
--------------------------------------------
|
||
return TRPModifyFiled
|