269 lines
8.9 KiB
Lua
269 lines
8.9 KiB
Lua
local TRPMakeCall = {}
|
||
|
||
---@type Coolape.CLPanelLua
|
||
local csSelf = nil
|
||
local transform = nil
|
||
---@type UIInput
|
||
local InputNumber
|
||
local grid
|
||
local cursorPosition = -1
|
||
local currRecordName
|
||
local ButtonDel
|
||
local uiobjs = {}
|
||
|
||
-- 初始化,只会调用一次
|
||
function TRPMakeCall.init(csObj)
|
||
csSelf = csObj
|
||
transform = csObj.transform
|
||
|
||
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")
|
||
|
||
local contentRect = MyUtl.getUIContent(csSelf)
|
||
grid.cellWidth = NumEx.getIntPart((contentRect.z - 100) / 3)
|
||
|
||
InputNumber = getChild(uiobjs.bottomOffset.transform, "InputNumber"):GetComponent("UIInput")
|
||
ButtonDel = getChild(InputNumber.transform, "ButtonDel").gameObject
|
||
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)
|
||
cell:init(data, TRPMakeCall.onClickNumCell)
|
||
end
|
||
)
|
||
|
||
uiobjs.ButtonShow = getChild(transform, "AnchorBottom/ButtonShow").gameObject
|
||
uiobjs.ButtonHide = getChild(uiobjs.bottomOffset.transform, "ButtonHide").gameObject
|
||
|
||
TRPMakeCall.showList()
|
||
end
|
||
|
||
-- 设置数据
|
||
function TRPMakeCall.setData(paras)
|
||
end
|
||
|
||
-- 显示,在c#中。show为调用refresh,show和refresh的区别在于,当页面已经显示了的情况,当页面再次出现在最上层时,只会调用refresh
|
||
function TRPMakeCall.show()
|
||
UIInput.selection = InputNumber
|
||
InputNumber.value = ""
|
||
SetActive(ButtonDel, false)
|
||
cursorPosition = -1
|
||
|
||
-- uiobjs.bottomOffset:ResetToBeginning()
|
||
SetActive(uiobjs.bottomOffset.gameObject, true)
|
||
SetActive(uiobjs.ButtonShow, false)
|
||
NetProto.send.query_cust_calllog(uiobjs.InputSeachKey.value, nil, 1)
|
||
end
|
||
|
||
function TRPMakeCall.onClickNumCell(cell, data)
|
||
UIInput.selection = InputNumber
|
||
InputNumber:Insert(data)
|
||
end
|
||
|
||
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
|
||
|
||
-- 刷新
|
||
function TRPMakeCall.refresh()
|
||
end
|
||
|
||
-- 关闭页面
|
||
function TRPMakeCall.hide()
|
||
UIInput.selection = nil
|
||
csSelf:cancelInvoke4Lua()
|
||
end
|
||
|
||
-- 网络请求的回调;cmd:指命,succ:成功失败,msg:消息;paras:服务器下行数据
|
||
function TRPMakeCall.procNetwork(cmd, succ, msg, paras)
|
||
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()
|
||
end
|
||
end
|
||
end
|
||
|
||
-- 处理ui上的事件,例如点击等
|
||
function TRPMakeCall.uiEventDelegate(go)
|
||
local goName = go.name
|
||
if (goName == "ButtonCancel") then
|
||
hideTopPanel()
|
||
elseif goName == "InputNumber" then
|
||
cursorPosition = InputNumber.cursorPosition
|
||
if isNilOrEmpty(InputNumber.value) then
|
||
SetActive(ButtonDel, false)
|
||
else
|
||
SetActive(ButtonDel, true)
|
||
end
|
||
elseif goName == "ButtonCall" then
|
||
-- CLLCallListner.ready2Call("TRPMakeCall.onEndCall", InputNumber.value)
|
||
-- MyUtl.callPhone(InputNumber.value)
|
||
if InputNumber.value == nil or InputNumber.value == "" then
|
||
MyUtl.toastW("请输入要呼叫的号码")
|
||
return
|
||
end
|
||
MyUtl.callCustByNative(InputNumber.value)
|
||
elseif goName == "ButtonCallYun" then
|
||
if InputNumber.value == nil or InputNumber.value == "" then
|
||
MyUtl.toastW("请输入要呼叫的号码")
|
||
return
|
||
end
|
||
showHotWheel()
|
||
MyUtl.doCall(
|
||
nil,
|
||
InputNumber.value,
|
||
nil,
|
||
function()
|
||
InputNumber.value = ""
|
||
end
|
||
)
|
||
elseif goName == "ButtonDel" then
|
||
TRPMakeCall.DoBackspace()
|
||
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)
|
||
end
|
||
end
|
||
|
||
function TRPMakeCall.onPressButtonDel()
|
||
csSelf:invoke4Lua(TRPMakeCall.invokeBackspace, 0.25)
|
||
end
|
||
|
||
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
|
||
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()
|
||
return false
|
||
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
|