151 lines
4.8 KiB
Lua
151 lines
4.8 KiB
Lua
|
|
local TRPMakeCall = {}
|
|||
|
|
|
|||
|
|
local csSelf = nil
|
|||
|
|
local transform = nil
|
|||
|
|
local InputNumber
|
|||
|
|
local grid
|
|||
|
|
local cursorPosition = -1
|
|||
|
|
local currRecordName
|
|||
|
|
local LabelTitle
|
|||
|
|
|
|||
|
|
-- 初始化,只会调用一次
|
|||
|
|
function TRPMakeCall.init(csObj)
|
|||
|
|
csSelf = csObj
|
|||
|
|
transform = csObj.transform
|
|||
|
|
grid = getChild(transform, "AnchorBottom/grid"):GetComponent("UIGrid")
|
|||
|
|
|
|||
|
|
local contentRect = MyUtl.getUIContent(csSelf)
|
|||
|
|
grid.cellWidth = NumEx.getIntPart((contentRect.z - 100) / 3)
|
|||
|
|
|
|||
|
|
InputNumber = getChild(transform, "AnchorBottom/InputNumber"):GetComponent("UIInput")
|
|||
|
|
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.onClickCell)
|
|||
|
|
end
|
|||
|
|
)
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
-- 设置数据
|
|||
|
|
function TRPMakeCall.setData(paras)
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
-- 显示,在c#中。show为调用refresh,show和refresh的区别在于,当页面已经显示了的情况,当页面再次出现在最上层时,只会调用refresh
|
|||
|
|
function TRPMakeCall.show()
|
|||
|
|
UIInput.selection = InputNumber
|
|||
|
|
InputNumber.value = ""
|
|||
|
|
cursorPosition = -1
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
function TRPMakeCall.onClickCell(cell, data)
|
|||
|
|
UIInput.selection = InputNumber
|
|||
|
|
InputNumber:Insert(data)
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
-- 刷新
|
|||
|
|
function TRPMakeCall.refresh()
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
-- 关闭页面
|
|||
|
|
function TRPMakeCall.hide()
|
|||
|
|
UIInput.selection = nil
|
|||
|
|
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)
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
-- 处理ui上的事件,例如点击等
|
|||
|
|
function TRPMakeCall.uiEventDelegate(go)
|
|||
|
|
local goName = go.name
|
|||
|
|
if (goName == "ButtonCancel") then
|
|||
|
|
CLPanelManager.hideTopPanel()
|
|||
|
|
elseif goName == "InputNumber" then
|
|||
|
|
cursorPosition = InputNumber.cursorPosition
|
|||
|
|
elseif goName == "ButtonCall" then
|
|||
|
|
if InputNumber.value == nil or InputNumber.value == "" then
|
|||
|
|
CLAlert.add("请输入要呼叫的号码", Color.white, 1)
|
|||
|
|
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)
|
|||
|
|
return
|
|||
|
|
end
|
|||
|
|
local selfPhoneNum = Prefs.getSelfPhoneNum()
|
|||
|
|
showHotWheel()
|
|||
|
|
CLLNet.callCust2(selfPhoneNum, InputNumber.value)
|
|||
|
|
elseif goName == "ButtonDel" then
|
|||
|
|
TRPMakeCall.DoBackspace()
|
|||
|
|
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)
|
|||
|
|
|
|||
|
|
CLPanelManager.getPanelAsy("PanelEndCallRemark", onLoadedPanelTT, func)
|
|||
|
|
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 true
|
|||
|
|
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
|