Files
tianrunCRM/Assets/trCRM/upgradeRes4Dev/priority/lua/ui/panel/TRPMakeCall.lua

269 lines
8.9 KiB
Lua
Raw Normal View History

2020-08-18 17:24:02 +08:00
local TRPMakeCall = {}
2020-08-26 19:56:45 +08:00
---@type Coolape.CLPanelLua
2020-08-18 17:24:02 +08:00
local csSelf = nil
local transform = nil
2020-08-26 19:56:45 +08:00
---@type UIInput
2020-08-18 17:24:02 +08:00
local InputNumber
local grid
local cursorPosition = -1
local currRecordName
2020-08-26 19:56:45 +08:00
local ButtonDel
local uiobjs = {}
2020-08-18 17:24:02 +08:00
-- 初始化,只会调用一次
function TRPMakeCall.init(csObj)
csSelf = csObj
transform = csObj.transform
2020-08-26 19:56:45 +08:00
MyUtl.setContentView(getChild(transform, "PanelContent"), 298, MyUtl.defaultBottomHeight)
uiobjs.InputSeachKey = getCC(transform, "Top/InputSeachKey", "UIInput")
---@type CLUIScrollViewWithEvent
uiobjs.scrollView = getCC(transform, "PanelContent", "CLUIScrollViewWithEvent")
uiobjs.scrollView.dampenStrength = MyUtl.dampenStrength
uiobjs.scrollView:init(TRPMakeCall.onShowRefreshFlg, TRPMakeCall.onhideRefreshFlg, TRPMakeCall.refreshList)
---@type Coolape.CLUILoopGrid
uiobjs.Grid = getCC(uiobjs.scrollView.transform, "Grid", "CLUILoopGrid")
uiobjs.ButtonEndList = getChild(uiobjs.Grid.transform, "ButtonEndList")
uiobjs.ButtonEndListLb = getCC(uiobjs.ButtonEndList, "Label", "UILabel")
uiobjs.ButtonHeadList = getChild(uiobjs.Grid.transform, "ButtonHeadList")
---@type TweenPosition
uiobjs.bottomOffset = getCC(transform, "AnchorBottom/offset", "TweenPosition")
grid = getChild(uiobjs.bottomOffset.transform, "grid"):GetComponent("UIGrid")
2020-08-18 17:24:02 +08:00
local contentRect = MyUtl.getUIContent(csSelf)
grid.cellWidth = NumEx.getIntPart((contentRect.z - 100) / 3)
2020-08-26 19:56:45 +08:00
InputNumber = getChild(uiobjs.bottomOffset.transform, "InputNumber"):GetComponent("UIInput")
ButtonDel = getChild(InputNumber.transform, "ButtonDel").gameObject
2020-08-18 17:24:02 +08:00
local prefabCell = getChild(grid.transform, "00000").gameObject
local list = {1, 2, 3, 4, 5, 6, 7, 8, 9, "*", 0, "#"}
CLUIUtl.resetList4Lua(
grid,
prefabCell,
list,
function(cell, data)
2020-08-26 19:56:45 +08:00
cell:init(data, TRPMakeCall.onClickNumCell)
2020-08-18 17:24:02 +08:00
end
)
2020-08-26 19:56:45 +08:00
uiobjs.ButtonShow = getChild(transform, "AnchorBottom/ButtonShow").gameObject
uiobjs.ButtonHide = getChild(uiobjs.bottomOffset.transform, "ButtonHide").gameObject
TRPMakeCall.showList()
2020-08-18 17:24:02 +08:00
end
-- 设置数据
function TRPMakeCall.setData(paras)
end
-- 显示在c#中。show为调用refreshshow和refresh的区别在于当页面已经显示了的情况当页面再次出现在最上层时只会调用refresh
function TRPMakeCall.show()
UIInput.selection = InputNumber
InputNumber.value = ""
2020-08-26 19:56:45 +08:00
SetActive(ButtonDel, false)
2020-08-18 17:24:02 +08:00
cursorPosition = -1
2020-08-26 19:56:45 +08:00
-- uiobjs.bottomOffset:ResetToBeginning()
SetActive(uiobjs.bottomOffset.gameObject, true)
SetActive(uiobjs.ButtonShow, false)
NetProto.send.query_cust_calllog(uiobjs.InputSeachKey.value, nil, 1)
2020-08-18 17:24:02 +08:00
end
2020-08-26 19:56:45 +08:00
function TRPMakeCall.onClickNumCell(cell, data)
2020-08-18 17:24:02 +08:00
UIInput.selection = InputNumber
InputNumber:Insert(data)
end
2020-08-26 19:56:45 +08:00
function TRPMakeCall.showList(list)
list = list or {}
SetActive(uiobjs.ButtonHeadList.gameObject, false)
if #list > 0 then
SetActive(uiobjs.ButtonEndList.gameObject, false)
else
SetActive(uiobjs.ButtonEndList.gameObject, true)
end
uiobjs.Grid:setList(list or {}, TRPMakeCall.initCell, TRPMakeCall.onHeadList, TRPMakeCall.onEndList)
TRPMakeCall.reposition()
csSelf:invoke4Lua(TRPMakeCall.reposition, 0.1)
end
function TRPMakeCall.reposition()
uiobjs.scrollView:ResetPosition()
end
function TRPMakeCall.appList(list)
SetActive(uiobjs.ButtonEndList.gameObject, false)
uiobjs.Grid:appendList(list)
end
function TRPMakeCall.onShowRefreshFlg()
if uiobjs.Grid.list.Count > 0 then
uiobjs.ButtonHeadList.transform.localPosition = Vector3(0, 166, 0)
else
uiobjs.ButtonHeadList.transform.localPosition = Vector3(0, 100, 0)
end
SetActive(uiobjs.ButtonHeadList.gameObject, true)
end
function TRPMakeCall.onhideRefreshFlg()
SetActive(uiobjs.ButtonHeadList.gameObject, false)
if uiobjs.Grid.list.Count == 0 then
uiobjs.scrollView:ResetPosition()
end
end
function TRPMakeCall.refreshList()
local queryKey = uiobjs.InputSeachKey.value
showHotWheel()
NetProto.send.query_cust_calllog(uiobjs.InputSeachKey.value, nil, 1)
end
function TRPMakeCall.onHeadList(head)
printw("到最顶端了")
-- uiobjs.ButtonHeadList.transform.localPosition = Vector3(0, 250, 0)
-- SetActive(uiobjs.ButtonHeadList.gameObject, true)
end
function TRPMakeCall.onEndList(tail)
printw("到最后了==" .. tail.name)
if TRPMakeCall.pageInfo and TRPMakeCall.pageInfo.current_page < TRPMakeCall.pageInfo.total_pages then
local queryKey = uiobjs.InputSeachKey.value
showHotWheel()
-- 取得下一页
NetProto.send.query_cust_calllog(uiobjs.InputSeachKey.value, nil, TRPMakeCall.pageInfo.current_page + 1)
else
uiobjs.ButtonEndList.localPosition = tail.transform.localPosition + Vector3.up * -170
SetActive(uiobjs.ButtonEndList.gameObject, true)
end
end
function TRPMakeCall.initCell(cell, data)
cell:init(data, TRPMakeCall.onClickCell)
end
function TRPMakeCall.onClickCell(cell, data)
getPanelAsy("PanelCallLogDetail", onLoadedPanelTT, data)
end
2020-08-18 17:24:02 +08:00
-- 刷新
function TRPMakeCall.refresh()
end
-- 关闭页面
function TRPMakeCall.hide()
UIInput.selection = nil
2020-08-26 19:56:45 +08:00
csSelf:cancelInvoke4Lua()
2020-08-18 17:24:02 +08:00
end
-- 网络请求的回调cmd指命succ成功失败msg消息paras服务器下行数据
function TRPMakeCall.procNetwork(cmd, succ, msg, paras)
2020-08-26 19:56:45 +08:00
if succ == NetSuccess then
if cmd == NetProto.cmds.query_cust_calllog then
local result = paras.result or {}
TRPMakeCall.pageInfo = result.meta
if TRPMakeCall.pageInfo and TRPMakeCall.pageInfo.current_page > 1 then
TRPMakeCall.appList(result.data)
else
TRPMakeCall.showList(result.data)
end
hideHotWheel()
2020-08-18 17:24:02 +08:00
end
end
end
-- 处理ui上的事件例如点击等
function TRPMakeCall.uiEventDelegate(go)
local goName = go.name
if (goName == "ButtonCancel") then
2020-08-26 19:56:45 +08:00
hideTopPanel()
2020-08-18 17:24:02 +08:00
elseif goName == "InputNumber" then
cursorPosition = InputNumber.cursorPosition
2020-08-26 19:56:45 +08:00
if isNilOrEmpty(InputNumber.value) then
SetActive(ButtonDel, false)
else
SetActive(ButtonDel, true)
end
2020-08-18 17:24:02 +08:00
elseif goName == "ButtonCall" then
2020-08-26 19:56:45 +08:00
-- CLLCallListner.ready2Call("TRPMakeCall.onEndCall", InputNumber.value)
-- MyUtl.callPhone(InputNumber.value)
2020-08-18 17:24:02 +08:00
if InputNumber.value == nil or InputNumber.value == "" then
2020-08-26 19:56:45 +08:00
MyUtl.toastW("请输入要呼叫的号码")
2020-08-18 17:24:02 +08:00
return
end
2020-11-30 22:39:38 +08:00
MyUtl.callCustByNative(InputNumber.value)
2020-08-18 17:24:02 +08:00
elseif goName == "ButtonCallYun" then
if InputNumber.value == nil or InputNumber.value == "" then
2020-08-26 19:56:45 +08:00
MyUtl.toastW("请输入要呼叫的号码")
2020-08-18 17:24:02 +08:00
return
end
showHotWheel()
2020-08-26 19:56:45 +08:00
MyUtl.doCall(
nil,
InputNumber.value,
nil,
function()
InputNumber.value = ""
end
)
2020-08-18 17:24:02 +08:00
elseif goName == "ButtonDel" then
TRPMakeCall.DoBackspace()
2020-08-26 19:56:45 +08:00
elseif goName == "ButtonShow" then
SetActive(uiobjs.ButtonShow, false)
-- uiobjs.bottomOffset:Play(true)
SetActive(uiobjs.bottomOffset.gameObject, true)
elseif goName == "ButtonHide" then
SetActive(uiobjs.ButtonShow, true)
-- uiobjs.bottomOffset:Play(false)
SetActive(uiobjs.bottomOffset.gameObject, false)
2020-08-18 17:24:02 +08:00
end
end
2020-08-26 19:56:45 +08:00
function TRPMakeCall.onPressButtonDel()
csSelf:invoke4Lua(TRPMakeCall.invokeBackspace, 0.25)
end
2020-08-18 17:24:02 +08:00
2020-08-26 19:56:45 +08:00
function TRPMakeCall.onReleaseButtonDel()
csSelf:cancelInvoke4Lua(TRPMakeCall.invokeBackspace)
end
function TRPMakeCall.invokeBackspace()
TRPMakeCall.DoBackspace()
if not isNilOrEmpty(InputNumber.value) then
csSelf:invoke4Lua(TRPMakeCall.invokeBackspace, 0.05)
end
2020-08-18 17:24:02 +08:00
end
-- 当结束回播通话
function TRPMakeCall.onEndIncomingCall(orgs)
local id = orgs.id
local func = function(remark)
showHotWheel()
CLLNet.saveRemark4Call2(id, remark)
end
CLPanelManager.getPanelAsy("PanelEndCallRemark", onLoadedPanelTT, func)
end
-- 当按了返回键时关闭自己返值为true时关闭
function TRPMakeCall.hideSelfOnKeyBack()
2020-08-26 19:56:45 +08:00
return false
2020-08-18 17:24:02 +08:00
end
function TRPMakeCall.DoBackspace()
UIInput.selection = InputNumber
if (InputNumber.value ~= nil and InputNumber.value ~= "") then
if (InputNumber.selectionStart == InputNumber.selectionEnd) then
if (InputNumber.selectionStart < 1) then
return
end
InputNumber.selectionEnd = InputNumber.selectionEnd - 1
end
InputNumber:Insert("")
end
end
--------------------------------------------
return TRPMakeCall