2020-07-04 14:41:25 +08:00
|
|
|
|
-- xx界面
|
|
|
|
|
|
local TRPConnect = {}
|
|
|
|
|
|
|
|
|
|
|
|
---@type Coolape.CLPanelLua
|
|
|
|
|
|
local csSelf = nil
|
|
|
|
|
|
---@type UnityEngine.Transform
|
|
|
|
|
|
local transform = nil
|
|
|
|
|
|
local companyInfro
|
|
|
|
|
|
local uiobjs = {}
|
|
|
|
|
|
|
|
|
|
|
|
-- 初始化,只会调用一次
|
|
|
|
|
|
function TRPConnect.init(csObj)
|
|
|
|
|
|
csSelf = csObj
|
|
|
|
|
|
transform = csObj.transform
|
|
|
|
|
|
--[[
|
|
|
|
|
|
上的组件:getChild(transform, "offset", "Progress BarHong"):GetComponent("UISlider");
|
|
|
|
|
|
--]]
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
-- 设置数据
|
|
|
|
|
|
function TRPConnect.setData(paras)
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--当有通用背板显示时的回调
|
|
|
|
|
|
function TRPConnect.onShowFrame()
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
-- 显示,在c#中。show为调用refresh,show和refresh的区别在于,当页面已经显示了的情况,当页面再次出现在最上层时,只会调用refresh
|
|
|
|
|
|
function TRPConnect.show()
|
|
|
|
|
|
local phone = Prefs.getUserName()
|
|
|
|
|
|
local currGroup = Prefs.getCurrGroup(Prefs.getUserName())
|
|
|
|
|
|
companyInfro = json.decode(currGroup)
|
|
|
|
|
|
DBUser.onGetUsers(companyInfro.loginNoList) -- 缓存工号相关信息
|
|
|
|
|
|
NetProto.socketInit(companyInfro.company_id, companyInfro.login_no, companyInfro.group_id)
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
-- 刷新
|
|
|
|
|
|
function TRPConnect.refresh()
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
-- 关闭页面
|
|
|
|
|
|
function TRPConnect.hide()
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
-- 网络请求的回调;cmd:指命,succ:成功失败,msg:消息;paras:服务器下行数据
|
|
|
|
|
|
function TRPConnect.procNetwork(cmd, succ, msg, paras)
|
|
|
|
|
|
if (succ == NetSuccess) then
|
|
|
|
|
|
if (cmd == "connect") then
|
|
|
|
|
|
-- socket正常
|
|
|
|
|
|
require "db.DBRoot"
|
|
|
|
|
|
DBRoot.init()
|
|
|
|
|
|
TRPConnect.getDataFromServer()
|
|
|
|
|
|
end
|
|
|
|
|
|
else
|
2020-07-11 20:53:21 +08:00
|
|
|
|
if (cmd == "connect") then
|
|
|
|
|
|
CLUIUtl.showConfirm(
|
|
|
|
|
|
"服务器连接失败,确认网络连接正常。",
|
|
|
|
|
|
function()
|
|
|
|
|
|
NetProto.socketInit(companyInfro.company_id, companyInfro.login_no)
|
|
|
|
|
|
end,
|
|
|
|
|
|
nil
|
|
|
|
|
|
)
|
|
|
|
|
|
end
|
2020-07-04 14:41:25 +08:00
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
---public 从服务器取得数据
|
|
|
|
|
|
function TRPConnect.getDataFromServer()
|
|
|
|
|
|
if DBRoot then
|
|
|
|
|
|
DBRoot.clean()
|
|
|
|
|
|
end
|
|
|
|
|
|
NetProto.send.filter_customers(
|
|
|
|
|
|
function(content)
|
|
|
|
|
|
if content.success then
|
|
|
|
|
|
getPanelAsy("PanelMain", onLoadedPanel)
|
|
|
|
|
|
else
|
|
|
|
|
|
CLUIUtl.showConfirm(
|
|
|
|
|
|
"网络错误,请重试",
|
|
|
|
|
|
function()
|
|
|
|
|
|
TRPConnect.getDataFromServer()
|
|
|
|
|
|
end
|
|
|
|
|
|
)
|
|
|
|
|
|
end
|
|
|
|
|
|
end,
|
|
|
|
|
|
5
|
|
|
|
|
|
)
|
2020-07-09 08:50:24 +08:00
|
|
|
|
NetProto.send.announcement_query()
|
2020-07-11 20:53:21 +08:00
|
|
|
|
NetProto.send.booking_query()
|
|
|
|
|
|
NetProto.send.replenish_query()
|
|
|
|
|
|
NetProto.send.load_wfTicket_Settings()
|
|
|
|
|
|
NetProto.send.selectProductInfo()
|
2020-07-04 14:41:25 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
-- 处理ui上的事件,例如点击等
|
|
|
|
|
|
function TRPConnect.uiEventDelegate(go)
|
|
|
|
|
|
local goName = go.name
|
|
|
|
|
|
--[[
|
|
|
|
|
|
if(goName == "xxx") then
|
|
|
|
|
|
--TODO:
|
|
|
|
|
|
end
|
|
|
|
|
|
--]]
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
-- 当顶层页面发生变化时回调
|
|
|
|
|
|
function TRPConnect.onTopPanelChange(topPanel)
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
-- 当按了返回键时,关闭自己(返值为true时关闭)
|
|
|
|
|
|
function TRPConnect.hideSelfOnKeyBack()
|
|
|
|
|
|
return false
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--------------------------------------------
|
|
|
|
|
|
return TRPConnect
|