添加电话中心页面模板

dev
曾超新 5 years ago
parent 32ddd11a67
commit 3e4b33a674
  1. 1
      frontend/controllers/DatabaseController.php
  2. 89
      frontend/views/phone-center/assign-phone.php
  3. 180
      frontend/views/phone-center/call-records.php
  4. 77
      frontend/views/phone-center/edit.php
  5. 59
      frontend/views/phone-center/sub-edit.php
  6. 114
      frontend/views/phone-center/sub-index.php
  7. 340
      frontend/views/phone-center/usercall-index.php

@ -582,6 +582,7 @@ class DatabaseController extends BaseController
$query->orderBy('id desc');
$query = $query->offset($offset)->limit($limit);
// echo $query->createCommand()->rawSql;
$items = $query->all();
$data = [];

@ -0,0 +1,89 @@
<?php
use \common\libs\MyLib;
?>
<script type="text/javascript" language="javascript" src="/js/jquery-1.8.3.js"></script><script >
$(document).bind("ajaxSend",function(elm,xhr,s) {
var csrf_param = $('meta[name=csrf-param]').prop('content');
var csrf_token = $('meta[name=csrf-token]').prop('content');
if(s.type == "POST") {
xhr.setRequestHeader('X-CSRF-Param',csrf_param);
xhr.setRequestHeader('X-CSRF-Token',csrf_token);
}
});
</script>
<script type="text/javascript" language="javascript" src="/js/ajax.js"></script>
<script type="text/javascript" language="javascript" src="/js/jquery-1.8.3.js"></script><script >
$(document).bind("ajaxSend",function(elm,xhr,s) {
var csrf_param = $('meta[name=csrf-param]').prop('content');
var csrf_token = $('meta[name=csrf-token]').prop('content');
if(s.type == "POST") {
xhr.setRequestHeader('X-CSRF-Param',csrf_param);
xhr.setRequestHeader('X-CSRF-Token',csrf_token);
}
});
</script>
<link rel="stylesheet" href="../Myfile/css/font.css?v=20190611">
<link rel="stylesheet" href="../Myfile/css/xadmin.css?v=20190605">
<link rel="stylesheet" href="../Myfile/css/theme274.min.css?v=20190605">
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<script src="../Myfile/lib/layui/layui.js?v=20190611" charset="utf-8"></script>
<script type="text/javascript" src="../Myfile/js/xadmin.js?v=20190612"></script><script type="text/javascript" language="javascript" src="/js/func.js"></script>
<script type="text/javascript" language="javascript">
//修改
function edit(id) {
window.location.href = '/phone-center/edit?id=' + id;
}
function del(id) {
if(confirm('是否确认删除?')) {
$.post('/phone-center/delete',{id:id},function(obj){
if(obj.success) {
window.location.reload();
} else {
alert(obj.msg);
}
},'json');
}
}
function sub(id) {
window.location.href = '/phone-center/sub-index?id=' + id;
}
$(function(){
$('#add-btn').click(function(){
edit(0);
});
});
</script>
<table style="width:98%;" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
<form id="searchForm">
<tr>
<td class="td_bg">
<input type="button" class="act_btn" id="add-btn" name="search-btn" value="添加">
</td>
</tr>
</form>
</table>
<table width="98%" align="center" cellpadding="3" cellspacing="1" class="table">
<tr>
<td width="" align="center" class="bg_tr">人员名称</td>
<td width="" align="center" class="bg_tr">电话号码</td>
<td width="" align="center" class="bg_tr">操作</td>
</tr>
<form id="theFrm">
<?php
foreach($phone_items as $item) {
?>
<tr onMouseOver=overColor(this) onMouseOut=outColor(this)>
<td align="center" class="td_bg" nowrap><?= $item->user->showName ?></td>
<td align="center" class="td_bg" nowrap><?= $item->phone?></td>
<td align="center" class="td_bg" nowrap>
[<a href="javascript:void(0);" onclick="edit(<?= $item['id'] ?>)">修改</a>]
[<a href="javascript:void(0);" onclick="del(<?= $item['id'] ?>)">删除</a>]
[<a href="javascript:void(0);" onclick="sub(<?= $item['id'] ?>)">小号</a>]
</td>
</tr>
<?php } ?>
</form>
</table>

@ -0,0 +1,180 @@
<?php
use \common\libs\MyLib;
?>
<script type="text/javascript" language="javascript" src="/js/jquery-1.8.3.js"></script><script >
$(document).bind("ajaxSend",function(elm,xhr,s) {
var csrf_param = $('meta[name=csrf-param]').prop('content');
var csrf_token = $('meta[name=csrf-token]').prop('content');
if(s.type == "POST") {
xhr.setRequestHeader('X-CSRF-Param',csrf_param);
xhr.setRequestHeader('X-CSRF-Token',csrf_token);
}
});
</script>
<script type="text/javascript" language="javascript" src="/js/ajax.js"></script>
<script type="text/javascript" language="javascript" src="/js/jquery-1.8.3.js"></script><script >
$(document).bind("ajaxSend",function(elm,xhr,s) {
var csrf_param = $('meta[name=csrf-param]').prop('content');
var csrf_token = $('meta[name=csrf-token]').prop('content');
if(s.type == "POST") {
xhr.setRequestHeader('X-CSRF-Param',csrf_param);
xhr.setRequestHeader('X-CSRF-Token',csrf_token);
}
});
</script>
<link rel="stylesheet" href="../Myfile/css/font.css?v=20190611">
<link rel="stylesheet" href="../Myfile/css/xadmin.css?v=20190605">
<link rel="stylesheet" href="../Myfile/css/theme274.min.css?v=20190605">
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<script src="../Myfile/lib/layui/layui.js?v=20190611" charset="utf-8"></script>
<script type="text/javascript" src="../Myfile/js/xadmin.js?v=20190612"></script><script type="text/javascript" language="javascript" src="/js/func.js"></script>
<script type="text/javascript" language="javascript" src="/js/datepicker/WdatePicker.js"></script>
<link rel="stylesheet" type="text/css" href="/copy/css/jquery.dialog.css" />
<script type="text/javascript" src="/copy/js/core.js"></script>
<script type="text/javascript" src="/copy/js/jquery.dialog.js"></script>
<script type="text/javascript" language="javascript">
//修改
function edit(id) {
window.location.href = '/fix-project/edit?id=' + id;
}
function del(id) {
if(confirm('是否确认删除?')) {
$.post('/fix-project/delete',{id:id},function(obj){
if(obj.success) {
window.location.reload();
} else {
alert(obj.msg);
}
},'json');
}
}
$(function(){
$('#add-btn').click(function(){
edit(0);
});
$("#search-btn").click(function(){
var params = $('#searchForm').serialize();
window.location.href = "/phone-center/call-records?" + params;
});
$('.exitDialog').Dialog({
title:'预约',
autoOpen: false,
width:400,
height:250
});
$('.exit').click(function(){
$('.exitDialog').Dialog('open');
var url = $(this).attr('record_url');
$("#play_url").attr('src',url);
});
$('.exitDialog input[type=button]').click(function(e) {
if($(this).hasClass('normal')){
}
});
});
</script>
<table style="width:98%;" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
<form id="searchForm">
<tr>
<td class="td_bg">
通话时间:从<input name="begin_time" type="text" value="<?=$begin_time?>" style="width:150px;" onclick="WdatePicker({ dateFmt: 'yyyy-MM-dd HH:mm:ss'})"><input name="end_time" type="text" value="<?=$end_time?>" style="width:150px;" onclick="WdatePicker({ dateFmt: 'yyyy-MM-dd HH:mm:ss'})">截止
主叫电话:<input name="caller" type="text" value="<?=$caller?>" style="width: 100px;">
被叫电话:<input name="called" type="text" value="<?=$called?>" style="width: 100px;">
通话状态:
<select name="call_result">
<option value="">请选择</option>
<option value="ANSWERED" <?= $call_result == 'ANSWERED'? 'selected':''?> >通话成功</option>
<option value="BUSY">被叫忙</option>
<option value="NO_ANSWER">被叫无应答</option>
<option value="REJECT">被叫拒接</option>
<option value="HANGUP">主叫提前挂机</option>
<option value="INVALID_NUMBER">空号</option>
<option value="POWER_OFF">关机</option>
<option value="UNAVAILABLE">暂时无法接听</option>
<option value="SUSPEND">停机</option>
<option value="TP_NO_BINDING">无绑定关系</option>
<option value="TP_TIMEOUT">号码查询接口超时</option>
<option value="BLACK">黑名单号码</option>
<option value="TP_ERROR">号码查询接口解析错误</option>
<option value="CALLED_BLACK">被叫不支持</option>
<option value="CALL_FORWARD">呼叫转移</option>
<option value="OTHER">其他失败情形</option>
</select>
通话时长:从<input name="duration_begin" type="text" value="<?=$duration_begin?>" style="width:100px;" ><input name="duration_end" type="text" value="<?=$duration_end?>" style="width:100px;" >截止
(秒为单位)
<input type="button" class="act_btn" id="search-btn" name="search-btn" value="搜索">
</td>
</tr>
</form>
</table>
<table width="98%" align="center" cellpadding="3" cellspacing="1" class="table">
<tr>
<td width="" align="center" class="bg_tr">序号</td>
<td width="" align="center" class="bg_tr">坐席人员</td>
<td width="" align="center" class="bg_tr">通话时间</td>
<td width="" align="center" class="bg_tr">主叫真实号码</td>
<td width="" align="center" class="bg_tr">被叫真实号码</td>
<td width="" align="center" class="bg_tr">主叫分配号码</td>
<td width="" align="center" class="bg_tr">被叫分配号码</td>
<td width="" align="center" class="bg_tr">通话时长</td>
<td width="" align="center" class="bg_tr">通话状态</td>
<td width="" align="center" class="bg_tr">语音</td>
</tr>
<form id="theFrm">
<?php
foreach($record_items as $item) {
?>
<tr onMouseOver=overColor(this) onMouseOut=outColor(this)>
<td align="center" class="td_bg" nowrap><?= $item->id ?></td>
<td align="center" class="td_bg" nowrap><?= $item->user?$item->user->showName:'' ?></td>
<td align="center" class="td_bg" nowrap><?= $item->begin_time ?></td>
<td align="center" class="td_bg" nowrap><?= $item->caller ?></td>
<td align="center" class="td_bg" nowrap><?= $item->called ?></td>
<td align="center" class="td_bg" nowrap><?= $item->caller_show ?></td>
<td align="center" class="td_bg" nowrap><?= $item->called_show ?></td>
<td align="center" class="td_bg" nowrap><?= MyLib::HMSByTime($item->call_duration)?></td>
<td align="center" class="td_bg" nowrap><?= MyLib::phoneCenterStatus($item->call_result) ?></td>
<td align="center" class="td_bg" nowrap>
<?php if($item->record_file_url):?>
<a class="exit" record_url="<?=$item->record_file_url?>" href="javascript:void()">播放</a>
<?php endif;?>
</td>
</tr>
<?php } ?>
</form>
</table>
<div class="exitDialog">
<table style="width:98%; margin-top: 10px; ">
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td>
<audio id="play_url" src="" controls="controls"></audio>
</td>
</tr>
</table>
</div>

@ -0,0 +1,77 @@
<?php
use \common\libs\MyLib;
?>
<table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
<form id="theFrm">
<input type="hidden" name="id" value="<?=$info->id?>">
<tr>
<td width="20%" height="25" class="td_bg">人员名称</td>
<td width="80%" height="25" class="td_bg">
<select name="user_id">
<?php
echo '<option value="0">请选择</option>';
foreach($user_items as $item) {
echo '<option value="'.$item->id.'"';
if($info->user_id == $item->id)
echo ' selected ';
echo '>'.$item->getShowName().'</option>';
}
?>
</select>
</td>
</tr>
<tr>
<td width="20%" height="25" class="td_bg">电话号码</td>
<td width="80%" height="25" class="td_bg"><input name="phone" type="text" id="phone" value="<?=$info->phone?>" size="40" /></td>
</tr>
</form>
<tr>
<td height="22" colspan="2" align="center" class="td_bg">
<input id="submit-btn" type=button class="ACT_btn" name=Submit1 value=" 提交 "/>
&nbsp;&nbsp;
<input id="back-btn" type="button" class="ACT_btn" name="Submit2" value=" 返回 ">
</td>
</tr>
</table>
<script type="text/javascript" language="javascript" src="/js/jquery-1.8.3.js"></script><script >
$(document).bind("ajaxSend",function(elm,xhr,s) {
var csrf_param = $('meta[name=csrf-param]').prop('content');
var csrf_token = $('meta[name=csrf-token]').prop('content');
if(s.type == "POST") {
xhr.setRequestHeader('X-CSRF-Param',csrf_param);
xhr.setRequestHeader('X-CSRF-Token',csrf_token);
}
});
</script>
<script type="text/javascript" language="javascript" src="/js/ajax.js"></script>
<script type="text/javascript" language="javascript" src="/js/jquery-1.8.3.js"></script>
<link rel="stylesheet" href="../Myfile/css/font.css?v=20190611">
<link rel="stylesheet" href="../Myfile/css/xadmin.css?v=20190605">
<link rel="stylesheet" href="../Myfile/css/theme274.min.css?v=20190605">
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<script src="../Myfile/lib/layui/layui.js?v=20190611" charset="utf-8"></script>
<script type="text/javascript" src="../Myfile/js/xadmin.js?v=20190612"></script><script type="text/javascript" language="javascript">
$(function () {
//提交按钮
$("#submit-btn").click(function(){
if(confirm('是否确认提交?')) {
var params = $("#theFrm").serialize();
$.post('/phone-center/save',params,function(obj){
if(obj.success) {
$('#back-btn').click();
} else {
alert(obj.msg);
}
},'json');
}
});
//返回按钮
$('#back-btn').click(function(){
window.location.href='/phone-center/assign-phone';
});
})
</script>

@ -0,0 +1,59 @@
<?php
use \common\libs\MyLib;
?>
<table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
<form id="theFrm">
<input type="hidden" name="id" value="<?=$info->id?>">
<input type="hidden" name="assign_id" value="<?=$assign_id?>">
<tr>
<td width="20%" height="25" class="td_bg">电话号码</td>
<td width="40%" height="25" class="td_bg"><input name="phone" type="text" id="phone" value="<?=$info->phone?>" size="40" /></td>
<td width="20%" height="25" class="td_bg">作为被叫号</td>
<td width="40" height="25" class="td_bg">
<input name="is_called" type="radio" id="is_called" value="0" size="40" <?=$info->is_called == 0?'checked':'' ?> />
<input name="is_called" type="radio" id="is_called" value="1" size="40" <?=$info->is_called == 1?'checked':''?> />
</td>
</tr>
</form>
<tr>
<td height="22" colspan="4" align="center" class="td_bg">
<input id="submit-btn" type=button class="ACT_btn" name=Submit1 value=" 提交 "/>
&nbsp;&nbsp;
<input id="back-btn" type="button" class="ACT_btn" name="Submit2" value=" 返回 ">
</td>
</tr>
</table>
<script type="text/javascript" language="javascript" src="/js/jquery-1.8.3.js"></script>
<script type="text/javascript" language="javascript" src="/js/ajax.js"></script>
<link rel="stylesheet" href="../Myfile/css/font.css?v=20190611">
<link rel="stylesheet" href="../Myfile/css/xadmin.css?v=20190605">
<link rel="stylesheet" href="../Myfile/css/theme274.min.css?v=20190605">
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<script src="../Myfile/lib/layui/layui.js?v=20190611" charset="utf-8"></script>
<script type="text/javascript" src="../Myfile/js/xadmin.js?v=20190612"></script><script type="text/javascript" language="javascript">
$(function () {
//提交按钮
$("#submit-btn").click(function(){
if(confirm('是否确认提交?')) {
var params = $("#theFrm").serialize();
$.post('/phone-center/sub-save',params,function(obj){
alert(obj.msg);
if(obj.success) {
$('#back-btn').click();
}
},'json');
}
});
//返回按钮
$('#back-btn').click(function(){
var params = $("#theFrm").serialize();
window.location.href='/phone-center/sub-index?id=<?=$assign_id?>';
});
})
</script>

@ -0,0 +1,114 @@
<?php
use \common\libs\MyLib;
?>
<table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
<form id="theFrm">
<input type="hidden" name="assign_id" value="<?=$assign_info->id?>">
<tr>
<td width="20%" height="25" class="td_bg">人员名称</td>
<td width="80%" height="25" class="td_bg" colspan="2">
<?=$assign_info->user->getShowName()?>
</td>
</tr>
<tr>
<td width="20%" height="25" class="td_bg">电话</td>
<td width="80%" height="25" class="td_bg" colspan="2">
<?=$assign_info->phone?>
</td>
</tr>
<tr>
<td width="20%" height="25" class="td_bg" colspan="3">&nbsp;</td>
</tr>
<tr>
<td width="20%" height="25" class="td_bg">小号</td>
<td width="80%" height="25" class="td_bg" colspan="2">
[<a href="javascript:void(0);" onclick="add(<?= $assign_info->id ?>)">添加</a>]
</td>
</tr>
<?php foreach ($sub_items as $k=>$item):?>
<tr>
<td width="20%" height="25" class="td_bg"><?=$k+1?></td>
<td width="40%" height="25" class="td_bg">
<?=$item->phone?>&nbsp;&nbsp;[<a href="javascript:void(0);" onclick="link(<?= $item['id'] ?>,<?=$assign_info->id?>)">绑定</a>]
</td>
<td height="25" class="td_bg">
[<a href="javascript:void(0);" onclick="edit(<?= $item['id'] ?>,<?= $assign_info->id ?>)">修改</a>]
[<a href="javascript:void(0);" onclick="del(<?= $item['id'] ?>)">删除</a>]
</td>
</tr>
<?php endforeach;?>
</form>
<tr>
<td height="22" colspan="3" align="center" class="td_bg" >
<input id="back-btn" type="button" class="ACT_btn" name="Submit2" value=" 返回 ">
</td>
</tr>
</table>
<script type="text/javascript" language="javascript" src="/js/jquery-1.8.3.js"></script><script >
$(document).bind("ajaxSend",function(elm,xhr,s) {
var csrf_param = $('meta[name=csrf-param]').prop('content');
var csrf_token = $('meta[name=csrf-token]').prop('content');
if(s.type == "POST") {
xhr.setRequestHeader('X-CSRF-Param',csrf_param);
xhr.setRequestHeader('X-CSRF-Token',csrf_token);
}
});
</script>
<script type="text/javascript" language="javascript" src="/js/ajax.js"></script>
<script type="text/javascript" language="javascript" src="/js/jquery-1.8.3.js"></script><script >
$(document).bind("ajaxSend",function(elm,xhr,s) {
var csrf_param = $('meta[name=csrf-param]').prop('content');
var csrf_token = $('meta[name=csrf-token]').prop('content');
if(s.type == "POST") {
xhr.setRequestHeader('X-CSRF-Param',csrf_param);
xhr.setRequestHeader('X-CSRF-Token',csrf_token);
}
});
</script>
<link rel="stylesheet" href="../Myfile/css/font.css?v=20190611">
<link rel="stylesheet" href="../Myfile/css/xadmin.css?v=20190605">
<link rel="stylesheet" href="../Myfile/css/theme274.min.css?v=20190605">
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<script src="../Myfile/lib/layui/layui.js?v=20190611" charset="utf-8"></script>
<script type="text/javascript" src="../Myfile/js/xadmin.js?v=20190612"></script><script type="text/javascript" language="javascript">
$(function () {
//返回按钮
$('#back-btn').click(function(){
window.location.href='/phone-center/assign-phone';
});
})
function edit(id,assign_id) {
window.location.href = '/phone-center/sub-edit?id=' + id + '&assign_id=' + assign_id;
}
function del(id,assign_id) {
if(confirm('是否确认删除?')) {
$.post('/phone-center/sub-delete',{id:id},function(obj){
if(obj.success) {
window.location.reload();
} else {
alert(obj.msg);
}
},'json');
}
}
function add(id) {
window.location.href = '/phone-center/sub-edit?assign_id=' + id;
}
function link(id,assign_id) {
$.get('/phone/ax-init',{id:id,assign_id:assign_id},function(obj){
alert(obj.msg);
},'json');
}
</script>

@ -0,0 +1,340 @@
<html>
<meta charset="UTF-8"/>
<head>
<title>卡尔话机WebSocket测试页</title>
</head>
<body onLoad="wsInit()">
<h1>卡尔话机WebSocket测试页</h1><h2>请使用支持webSocket的浏览器</h2>
输入server的ip和port,例如:ws://127.0.0.1:8800/<br/>
<input id="serverInfo" type="text" value="ws://127.0.0.1:8800/" size="40"/>&nbsp;&nbsp;
<input type="button" id="btn" value="重新连接" onClick="wsInit('reConn')" />
<br>
<div id="txt-e" style=" color: red; font-size: 18px; display: none;"></div>
<div id="txt-ok" style=" color: green; font-size: 18px; display: none;"></div>
<p>
发送报文:<input id="sendMsg" type="text" value='{"cmd":"LINK"}' style="width: 500px;">
<br><br>
接收报文:
<textarea style="width:500px;"id="recMsg" name="" cols="" rows="10"></textarea></p>
<p><input type="button" onClick="sendMsg('link')" value="发起link连接"></p>
<p><input type="button" onClick="sendMsg('ATD')" value="拨号">
<span style="border:2px solid #6C3;font-size:12px; color:#1a1a1a; margin-left:10px;padding:5px">
<label><input type="radio" name="sendhaoma" value="1" checked="true">隐藏号码</label>
<label><input type="radio" name="sendhaoma" value="0" >显示号码</label>
</span>
<input type="tel" id="tel" value="10010" style="margin-left:10px;"/>
</p>
<p><input type="button" onClick="sendMsg('ATH')" value="挂断"></p>
<p><input type="button" onClick="sendMsg('ATA')" value="接听"></p>
<p><input type="button" onClick="sendMsg('READIMEI')" value="读取话机imei"></p>
<p><input type="button" onClick="sendMsg('READVER')" value="读取话机版本号"></p>
<p><input type="button" onClick="sendMsg('startrecord')" value="开启录音"></p>
<p><input type="button" onClick="sendMsg('stoprecord')" value="停止录音"></p>
<p><input type="button" onClick="sendMsg('READSTATUS')" value="查询话机状态"><span style="font-size:12px; color:#333; margin-left:10px">备注:status:0挂机,1来电,2呼叫,3接通
挂机状态时,number号码为空。</span></p>
<p><input type="button" onClick="sendMsg('HIDENUMBER')" value="隐藏或显示号码">
<span style="border:2px solid #6C6;font-size:12px; color:#1a1a1a; margin-left:10px; padding:5px">
<label><input type="radio" name="laidian" value="0" >来电</label> <label><input type="radio" name="laidian" value="1" >去电</label>
</span>
<span style="border:2px solid #6C3;font-size:12px; color:#1a1a1a; margin-left:10px;padding:5px">
<label><input type="radio" name="haoma" value="1" >隐藏号码</label>
<label><input type="radio" name="haoma" value="0" >显示号码</label>
</span>
</p>
<p><input type="button" onClick="sendMsg('GETNUMBERHIDEN')" value="读取话机号码隐藏状态">
<span style="border:2px solid #6C6;font-size:12px; color:#1a1a1a; margin-left:10px; padding:5px">
<label><input name="duqvhj" type="radio" value="0" checked >来电</label>
<label><input type="radio" name="duqvhj" value="1">去电</label>
</span>
</p>
<p><input type="button" onClick="sendMsg('SETRECORDVOICE')" value="设置录音音量">
<input type="voice" id="voice" value=""/><span style="font-size:12px; color:#333; margin-left:10px">备注:声音范围 1~100。</span>
</p>
<p><input type="button" onClick="sendMsg('SETMODE')" value="设置话机通话模式">
<span style="border:2px solid #6C6;font-size:12px; color:#1a1a1a; margin-left:10px; padding:5px">
<label><input name="headsetProfile" type="radio" value="0" checked >关闭耳机模式</label>
<label><input name="headsetProfile" type="radio" value="1">开耳机模式</label>
</span>
</p>
<p><input type="button" onClick="sendMsg('GETMODE')" value="获取话机通话模式">
<span style="font-size:12px; color:#333; margin-left:10px">备注:0 关闭耳机模式,1 开耳机模式。</span>
</p>
<p><input type="button" onClick="sendMsg('SETUOC')" value="设置远端播放">
<span style="border:2px solid #6C6;font-size:12px; color:#1a1a1a; margin-left:10px; padding:5px">
<label><input name="headsetProfileRadio" type="radio" value="0" checked >关闭远端播放</label>
<label><input name="headsetProfileRadio" type="radio" value="1">开启远端播放</label>
</span>
</p>
<p><input type="button" onClick="sendMsg('GETUOC')" value="获取远端播放">
<span style="font-size:12px; color:#333; margin-left:10px">备注:0 关闭远端播放,1 开启远端播放。</span>
</p>
<p>
<input type="button" onClick="sendMsg('UPPARAM')" value="设置通话记录传平台的参数">
<span style="font-size:12px; color:#1a1a1a; margin-left:10px; padding:5px">
url:<input type="upparamurl" id="upparamurl" value="http://apis.7moor.com/sim/cdr_ytx/insertCdr/" style="margin-left:10px;"/>
坐席工号:<input type="agent" id="agent" value="100001" style="margin-left:10px;"/>
计费账号:<input type="company" id="company" value="psytest" style="margin-left:10px;"/>
本机号码:<input type="thismobile" id="thismobile" value="13212345678" style="margin-left:10px;"/>
</span>
</p>
</body>
<script>
var ws;
function wsInit(val){
//重连先关闭
if(val=='reConn'){
ws.close();
}
document.getElementById("txt-ok").innerText="";
document.getElementById("txt-e").innerText="";
if("WebSocket" in window) {
var serverInfo = document.getElementById("serverInfo").value;
// 打开一个 web socket,全局共用一个
ws = new WebSocket(serverInfo);
//console.log("已连接"+serverInfo);
ws.onopen = function() {
setTimeout(function(){
sendMsg('link')
},100);
showResult('ok');
};
ws.onmessage = function(evt) {
document.getElementById("recMsg").value=evt.data;
var data = JSON.parse(evt.data);
//console.log(data);
switch(data['cmd']) {
// 服务端ping客户端
case 'USB':
ws.send('{"cmd":"USB","connected":"true","success":"true","message":"成功"}');
break;
case 'CORG':
ws.send('{"cmd":"CORG","number":"10010","success":"true","message":"成功"}');
break;
case 'CALLING':
ws.send('{"cmd":"CALLING","number":"10010","success":"true","message":"成功"}');
break;
case 'CBEGIN':
ws.send('{"cmd":"CBEGIN","success":"true","message":"成功"}');
break;
case 'ALERT':
ws.send('{"cmd":"ALERT","success":"true","message":"成功"}');
break;
case 'CEND':
ws.send('{"cmd":"CEND","success":"true","message":"成功"}');
break;
}
};
//出现错误
ws.onerror = function(evt){
//console.log(evt);
}
//连接断开
ws.onclose = function(evt){
//console.log(evt)
showResult('error');
}
} else {
// 浏览器不支持 WebSocket
alert("您的浏览器不支持 WebSocket!");
}
}
function showResult(val){
var serverInfo = document.getElementById("serverInfo").value;
var okText = serverInfo + "连接成功";
var errText = serverInfo + "连接失败,请检查window服务、IP和端口安装并配置正确";
if(val=='ok'){
document.getElementById("txt-ok").innerText = okText;
document.getElementById("txt-ok").style.display="block";
document.getElementById("txt-e").style.display="none";
}else{
//console.log(errText)
document.getElementById("txt-e").innerText = errText;
document.getElementById("txt-ok").style.display="none";
document.getElementById("txt-e").style.display="block";
}
}
function reConn(){
ws = new WebSocket(serverInfo);
}
function sendMsg(val){
// Web Socket 已连接上,使用 send() 方法发送数据
var state=ws.readyState;
console.log("readyState:"+state);
if(state!=1){
document.getElementById("txt-e").style.display="block";
//location.reload();
return;
}else{
document.getElementById("txt-e").style.display="none";
}
if(val=="link"){
val = '{"cmd":"LINK"}';
}
/*if(val=="USB"){
val = '{"cmd":"USB","connected":"true","success":"true","message":"成功"}';
}*/
if(val=="ATD"){
function getRadioLValue(haoma){
var obj = document.getElementsByName(haoma);
for(i = 0;i<obj.length;i++){
if(obj[i].checked){
return obj[i].value;
}
}
return "undefined";
}
var sendhaoma = getRadioLValue("sendhaoma");
var number = document.getElementById("tel").value;
val = '{"cmd":"ATD","number":"'+number+'","hidden":"'+sendhaoma+'"}';
}
if(val=="ATH"){
val = '{"cmd":"ATH"}';
}
if(val=="ATA"){
val = '{"cmd":"ATA"}';
}
if(val=="READIMEI"){
val = '{"cmd":"READIMEI"}';
}
if(val=="READVER"){
val = '{"cmd":"READVER"}';
}
if(val=="READSTATUS"){
val = '{"cmd":"READSTATUS"}';
}
if(val=="startrecord"){
function getLocalTime(nS) {
return new Date(parseInt(nS) * 1000).Format("yyyyMMddhhmmss");
}
Date.prototype.Format = function(fmt) {//author: meizz
var o = {
"M+" : this.getMonth() + 1, //月份
"d+" : this.getDate(), //日
"h+" : this.getHours(), //小时
"m+" : this.getMinutes(), //分
"s+" : this.getSeconds(), //秒
"q+" : Math.floor((this.getMonth() + 3) / 3), //季度
"S" : this.getMilliseconds() //毫秒
};
if (/(y+)/.test(fmt))
fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o)
if (new RegExp("(" + k + ")").test(fmt))
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
return fmt;
}
//E:\\qtproject\\PhoneService\\kaerHjSDK\\recordfile\\20180514.mp3
var time= Math.round(new Date() / 1000) ;
var times =(getLocalTime(time));
console.log(time);
var filename= "E:/qtproject/PhoneService/kaerHjSDK/recordfile/"+times+".mp3";
val = '{"cmd":"startrecord","filename":"'+filename+'"}';
//alert(filename);
}
if(val=="stoprecord"){
val = '{"cmd":"stoprecord"}';
}
if(val=="HIDENUMBER"){
function getRadioValue(laidian){
var obj = document.getElementsByName(laidian);
for(i = 0;i<obj.length;i++){
if(obj[i].checked){
return obj[i].value;
}
}
return "undefined";
}
function getRadioLValue(haoma){
var obj = document.getElementsByName(haoma);
for(i = 0;i<obj.length;i++){
if(obj[i].checked){
return obj[i].value;
}
}
return "undefined";
}
var type=getRadioValue('laidian');
var hidden=getRadioLValue('haoma');
//console.log(type);
//console.log('号码'+hidden);
val = '{"cmd":"HIDENUMBER","type":"'+type+'","hidden":"'+hidden+'"}';
}
if(val=="GETNUMBERHIDEN"){
function getRadioDqValue(duqvhj){
var obj = document.getElementsByName(duqvhj);
for(i = 0;i<obj.length;i++){
if(obj[i].checked){
return obj[i].value;
}
}
return "undefined";
}
var type=getRadioDqValue('duqvhj');
val = '{"cmd":"GETNUMBERHIDEN","type":"'+type+'"}';
}
if(val=="SETRECORDVOICE"){
var voice= document.getElementById("voice").value;
val = '{"cmd":"SETRECORDVOICE","voice":"'+voice+'"}';
}
if(val=="SETMODE"){
function getRadioHpValue(headsetProfile){
var obj = document.getElementsByName(headsetProfile);
for(i = 0;i<obj.length;i++){
if(obj[i].checked){
return obj[i].value;
}
}
return "undefined";
}
var mode=getRadioHpValue('headsetProfile');
val = '{"cmd":"SETMODE","mode":"'+mode+'"}';
}
if(val=="GETMODE"){
val = '{"cmd":"GETMODE"}';
}
if(val=="SETUOC"){
function getRadioHpValue(headsetProfileRadio){
var obj = document.getElementsByName(headsetProfileRadio);
for(i = 0;i<obj.length;i++){
if(obj[i].checked){
return obj[i].value;
}
}
return "undefined";
}
var mode=getRadioHpValue('headsetProfileRadio');
val = '{"cmd":"SETUOC","UOC":"'+mode+'"}';
}
if(val=="GETUOC"){
val = '{"cmd":"GETUOC"}';
}
if(val=="UPPARAM"){//设置通话记录传平台的参数
var upparamurl = document.getElementById("upparamurl").value;//坐席工号
var agent = document.getElementById("agent").value;//坐席工号
var company =document.getElementById("company").value;//计费账号
var thismobile =document.getElementById("thismobile").value;//本机号码
val = '{"cmd":"UPPARAM","url":"'+upparamurl+'","agent":"'+agent+'","company":"'+company+'","thismobile":"'+thismobile+'"}';
}
document.getElementById("sendMsg").value=val;
ws.send(val);
console.log("数据已发送");
}
</script>
</html>
Loading…
Cancel
Save