upgrade
This commit is contained in:
@@ -1,23 +1,44 @@
|
||||
local TRPMakeCall = {}
|
||||
|
||||
---@type Coolape.CLPanelLua
|
||||
local csSelf = nil
|
||||
local transform = nil
|
||||
---@type UIInput
|
||||
local InputNumber
|
||||
local grid
|
||||
local cursorPosition = -1
|
||||
local currRecordName
|
||||
local LabelTitle
|
||||
local ButtonDel
|
||||
local uiobjs = {}
|
||||
|
||||
-- 初始化,只会调用一次
|
||||
function TRPMakeCall.init(csObj)
|
||||
csSelf = csObj
|
||||
transform = csObj.transform
|
||||
grid = getChild(transform, "AnchorBottom/grid"):GetComponent("UIGrid")
|
||||
|
||||
|
||||
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(transform, "AnchorBottom/InputNumber"):GetComponent("UIInput")
|
||||
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(
|
||||
@@ -25,9 +46,14 @@ function TRPMakeCall.init(csObj)
|
||||
prefabCell,
|
||||
list,
|
||||
function(cell, data)
|
||||
cell:init(data, TRPMakeCall.onClickCell)
|
||||
cell:init(data, TRPMakeCall.onClickNumCell)
|
||||
end
|
||||
)
|
||||
|
||||
uiobjs.ButtonShow = getChild(transform, "AnchorBottom/ButtonShow").gameObject
|
||||
uiobjs.ButtonHide = getChild(uiobjs.bottomOffset.transform, "ButtonHide").gameObject
|
||||
|
||||
TRPMakeCall.showList()
|
||||
end
|
||||
|
||||
-- 设置数据
|
||||
@@ -38,12 +64,88 @@ end
|
||||
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)
|
||||
UIInput.selection = InputNumber
|
||||
InputNumber:Insert(data)
|
||||
getPanelAsy("PanelCallLogDetail", onLoadedPanelTT, data)
|
||||
end
|
||||
|
||||
-- 刷新
|
||||
@@ -53,21 +155,21 @@ end
|
||||
-- 关闭页面
|
||||
function TRPMakeCall.hide()
|
||||
UIInput.selection = nil
|
||||
csSelf:cancelInvoke4Lua()
|
||||
end
|
||||
|
||||
-- 网络请求的回调;cmd:指命,succ:成功失败,msg:消息;paras:服务器下行数据
|
||||
function TRPMakeCall.procNetwork(cmd, succ, msg, paras)
|
||||
if (succ == 0) then
|
||||
if (cmd == "8888") then
|
||||
-- 回拨已调用成功
|
||||
local orgs = Hashtable()
|
||||
orgs.callback = "TRPMakeCall.onEndIncomingCall"
|
||||
orgs.id = msg
|
||||
CLLCallListner.waite4Callback(JSON.JsonEncode(orgs))
|
||||
CLUIUtl.showConfirm("云呼叫中,请准备接听电话", nil)
|
||||
elseif cmd == "1018" then
|
||||
-- 保存通话记录完成
|
||||
CLLRecordMgr.moveRecord2Upload(currRecordName)
|
||||
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
|
||||
@@ -76,46 +178,61 @@ end
|
||||
function TRPMakeCall.uiEventDelegate(go)
|
||||
local goName = go.name
|
||||
if (goName == "ButtonCancel") then
|
||||
CLPanelManager.hideTopPanel()
|
||||
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
|
||||
CLAlert.add("请输入要呼叫的号码", Color.white, 1)
|
||||
MyUtl.toastW("请输入要呼叫的号码")
|
||||
return
|
||||
end
|
||||
CLLCallListner.ready2Call("TRPMakeCall.onEndCall", InputNumber.value)
|
||||
MyUtl.callPhone(InputNumber.value)
|
||||
elseif goName == "ButtonCallYun" then
|
||||
if InputNumber.value == nil or InputNumber.value == "" then
|
||||
CLAlert.add("请输入要呼叫的号码", Color.white, 1)
|
||||
MyUtl.toastW("请输入要呼叫的号码")
|
||||
return
|
||||
end
|
||||
local selfPhoneNum = Prefs.getSelfPhoneNum()
|
||||
showHotWheel()
|
||||
CLLNet.callCust2(selfPhoneNum, InputNumber.value)
|
||||
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.onEndCall(orgs)
|
||||
local func = function(remark)
|
||||
local data = Hashtable()
|
||||
data.remark = remark
|
||||
data.caller_number = Prefs.getSelfPhoneNum()
|
||||
data.destination_number = orgs.phone
|
||||
data.created_time = orgs.created_time
|
||||
data.answered_time = orgs.answered_time
|
||||
data.over_time = orgs.over_time
|
||||
data.recording_file_name = Path.GetFileName(orgs.soundRecordFile)
|
||||
showHotWheel()
|
||||
CLLNet.saveCall(data)
|
||||
end
|
||||
currRecordName = Path.GetFileName(orgs.soundRecordFile)
|
||||
function TRPMakeCall.onPressButtonDel()
|
||||
csSelf:invoke4Lua(TRPMakeCall.invokeBackspace, 0.25)
|
||||
end
|
||||
|
||||
CLPanelManager.getPanelAsy("PanelEndCallRemark", onLoadedPanelTT, func)
|
||||
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
|
||||
|
||||
-- 当结束回播通话
|
||||
@@ -130,7 +247,7 @@ end
|
||||
|
||||
-- 当按了返回键时,关闭自己(返值为true时关闭)
|
||||
function TRPMakeCall.hideSelfOnKeyBack()
|
||||
return true
|
||||
return false
|
||||
end
|
||||
|
||||
function TRPMakeCall.DoBackspace()
|
||||
|
||||
Reference in New Issue
Block a user