高新区管委会,以5.0标准版为基准,从双汇项目拷贝

main.js 26KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759
  1. var ws, n = 0,
  2. timer,hidTel,hidCallID,hidActionID,
  3. directType,sendType,mesCont,
  4. eorrorConnect,errorState=false,
  5. makeCallId = "",lockReconnect = false,
  6. obj = {},cls = 0,iframeOutbound=0,timeId,
  7. lasttime = new Date().getTime(),
  8. reconnecTion,recon,loginOr=false;
  9. //创建scoket连接
  10. function createWebSocket() {
  11. try {
  12. $("#top-search li i").removeClass("active");
  13. Connect();
  14. } catch(e) {
  15. reconnect();
  16. //打印日志
  17. directType="lianjie";
  18. sendType="异常错误"; //JSON.stringify(data)
  19. mesCont=e.message;
  20. debuggerLog();
  21. }
  22. }
  23. //连接
  24. function Connect() {
  25. ws = new WebSocket("ws://" + huayi.config.socket_ip + ":" + huayi.config.socket_port);
  26. ws.onopen = function() {
  27. console.log(new Date() + " " + "建立连接");
  28. //心跳检测重置
  29. heartCheck.reset().start();
  30. cls = 0;
  31. $(".Login").addClass("active");
  32. //自动签入
  33. lasttime = new Date().getTime();
  34. obj.Type = "Login";
  35. obj.AgentType = "0";
  36. Send(); /*2018-05-19zhangshaungnan注释*/
  37. };
  38. //接收到消息的回调方法
  39. ws.onmessage = function(evt) {
  40. //如果获取到消息,心跳检测重置
  41. //拿到任何消息都说明当前连接是正常的
  42. heartCheck.reset().start();
  43. var myDate = new Date();
  44. console.log(myDate + " receive " + evt.data);
  45. var data = JSON.parse(evt.data)[0];
  46. //打印日志
  47. directType="recive";
  48. sendType=data.Type; //JSON.stringify(data)
  49. mesCont=JSON.stringify(data);
  50. debuggerLog()
  51. if(data) {
  52. var rlt = data.Result;
  53. if(rlt == true) {
  54. var type = data.Type;
  55. switch(type.toLowerCase()) {
  56. //case "heart": HeartBack(); break;//心跳
  57. case "login":
  58. LoginBack();
  59. break; //签入
  60. case "logout":
  61. LogoutBack();
  62. break; //签出
  63. case "dropcall":
  64. DropCallBack();
  65. break; //挂断
  66. case "makecall": //MakeCall
  67. MakeCallBack(data);
  68. break; //外呼
  69. case "setstate":
  70. SetState(data);
  71. break; //置忙置闲
  72. //case "saybusy": SayBusyBack(data); break;
  73. //case "sayfree": SayFreeBack(data); break;
  74. case "meeting":
  75. MeetingBack();
  76. break; //多方通话
  77. case "transfer":
  78. TransferBack();
  79. break; //转移
  80. case "hold":
  81. HoldBack();
  82. break; //保持
  83. case "retrieve":
  84. RetrieveBack();
  85. break; //接回
  86. case "incoming":
  87. IncomingBack(data);
  88. break; //来电
  89. case "subscribe":
  90. SubScribeBack();
  91. break; //监测
  92. case "subscribecancel":
  93. SubScribeCancelBack();
  94. break; //停止监测
  95. case "agentstate":
  96. AgentStateBack(data);
  97. break; //坐席状态
  98. case "linestate":
  99. LineStateBack(data);
  100. break; //线路状态
  101. case "motorsetstate":
  102. SayFreeBack();
  103. break; //班长置闲
  104. case "linestateagent":
  105. LineStateAgentBack(data);
  106. break; //线路状态通知
  107. // case "agentstateagent":
  108. // AgentStateAgentBack(data);
  109. // break; //坐席状态通知
  110. case "callid":
  111. CallIDBack(data);
  112. break; //获取callid
  113. case "recordpath":
  114. RecordPathBack(data);
  115. break; //录音返回
  116. }
  117. } else {
  118. if(rlt == false) {
  119. //$(".hwzt").text('操作失败!');
  120. //外呼失败的文字展示
  121. if (data.Type.toLowerCase() == "makecall") {
  122. switch (data.ErrorCode) {
  123. case 1: $(".hwzt").text(' 挂机,请重试!'); break;
  124. case 2: $(".hwzt").text(' FS外呼命令失败,请重试!'); break;
  125. case 3: $(".hwzt").text(' 外呼获取座席失败,请重试!'); break;
  126. case 4: $(".hwzt").text(' 座席置忙禁止座席外呼,请重试!'); break;
  127. case 5: $(".hwzt").text(' 主叫座席分机非空闲或摘机拨号,请重试!'); break;
  128. case 6: $(".hwzt").text(' 为外呼设置座席状态失败,请重试!'); break;
  129. case 7: $(".hwzt").text(' 被叫座席非空闲,请重试!'); break;
  130. case 8: $(".hwzt").text(' 执行分机呼叫失败, 未找到分机通道,请重试!'); break;
  131. case 9: $(".hwzt").text(' 执行分机呼叫失败, 无法绑定分机通道,请重试!'); break;
  132. case 10: $(".hwzt").text(' 禁止分机自呼,请重试!'); break;
  133. case 11: $(".hwzt").text(' 发送分机呼叫Esl命令失败,请重试!'); break;
  134. case 12: $(".hwzt").text(' 目标分机非空闲,请重试!'); break;
  135. case 13: $(".hwzt").text(' 主控通道非空闲,请重试!'); break;
  136. case 14: $(".hwzt").text(' 校验不通过绑定本端逻辑线路失败,请重试!'); break;
  137. case 15: $(".hwzt").text(' 校验不通过本端当前线路忙,请重试!'); break;
  138. case 16: $(".hwzt").text(' 校验不通过对端线路状态忙,请重试!'); break;
  139. case 17: $(".hwzt").text(' 被叫关机,请重试!'); break;
  140. case 18: $(".hwzt").text(' 无效号码,请重试!'); break;
  141. case 19: $(".hwzt").text(' 无人接听,请重试!'); break;
  142. case 20: $(".hwzt").text(' 交换机错误(用户无法接通),请重试!'); break;
  143. case 21: $(".hwzt").text(' 话机外呼执行数据交换操作失败未找到分机通道,请重试!'); break;
  144. case 22: $(".hwzt").text(' 话机外呼执行数据交换操作失败分机通道未绑定任务,请重试!'); break;
  145. case 23: $(".hwzt").text(' 执行设备外呼任务失败无法获取对应线路,请重试!'); break;
  146. }
  147. }
  148. if(data.Type=='AcdConnectNotify'){
  149. $("#top-search li i").removeClass("active");
  150. $(".hwzt").text('Acd未连接');
  151. }
  152. } else {
  153. $(".hwzt").text(rlt);
  154. //layer.confirm(rlt, {
  155. // btn: ['确定']
  156. //});
  157. }
  158. }
  159. }
  160. };
  161. //连接关闭的回调方法
  162. ws.onclose = function(evt) {
  163. // 打印日志
  164. directType="recive";
  165. sendType="close"; //JSON.stringify(data)
  166. mesCont=JSON.stringify(evt);
  167. debuggerLog();
  168. if(cls == 0) {
  169. cls = 1;
  170. $(".hwzt").text('连接关闭!');
  171. $("#top-search li i").removeClass("active");
  172. reconnect();
  173. }
  174. };
  175. //连接发生错误的回调方法
  176. ws.onerror = function(evt) {
  177. // 打印日志
  178. directType="recive";
  179. sendType="连接错误 "; //JSON.stringify(data)
  180. mesCont=JSON.stringify(evt);
  181. debuggerLog();
  182. //产生异常
  183. $(".hwzt").text('连接出现异常!');
  184. console.log(ws);
  185. if(ws == null || ws.readyState != ws.OPEN) {
  186. console.log(new Date() + "开始重连");
  187. reconnect();
  188. }
  189. };
  190. }
  191. //重连
  192. function reconnect() {
  193. if(lockReconnect) return;
  194. lockReconnect = true;
  195. //没连接上会一直重连,设置延迟避免请求过多
  196. setTimeout(function() {
  197. // 打印日志
  198. directType="send";
  199. sendType="重连中 "; //JSON.stringify(data)
  200. mesCont="重连中";
  201. debuggerLog();
  202. console.log(new Date() + " " + "重连中……");
  203. createWebSocket("ws://" + huayi.config.socket_ip + ":" + huayi.config.socket_port);
  204. lockReconnect = false;
  205. }, 2000);
  206. }
  207. function debuggerLog(){
  208. $.post(huayi.config.callcenter_url + 'Log/CallOpt', {
  209. direct: directType,
  210. type: sendType,
  211. cont: mesCont,
  212. "token": $.cookie("token")
  213. }, function(result) {
  214. result = $.parseJSON(result);
  215. if(result.state.toLowerCase() == "warning") {
  216. //layer.msg("创建工单成功");
  217. }
  218. })
  219. }
  220. //异常重连
  221. function errorFun(){
  222. clearInterval(timer);
  223. var errorNum=0
  224. timer = setInterval(function() {
  225. errorNum++;
  226. if (errorNum>2) {
  227. $(".hwzt").text('连接异常!');
  228. }else{
  229. $("#top-search li i").removeClass("active");
  230. $(".Login").addClass("active");
  231. $(".zxzt").removeClass("bl").addClass("br");
  232. $(".fwzt").removeClass("bl").addClass("br");
  233. $(".hwzt").text('');
  234. }
  235. reconnect();
  236. $(".hwzt").text('连接异常!');
  237. }, 15000);
  238. }
  239. noLine();
  240. clearInterval(recon);
  241. recon = setInterval(function () {
  242. if(loginOr){
  243. noLine();
  244. setTimeout(function () {
  245. lineState();
  246. }, 2000);
  247. }
  248. }, 1000*10);
  249. function lineState(){
  250. if (reconnecTion) {
  251. reconnecTion=false;
  252. }else{
  253. directType="send";
  254. sendType="断网 "; //JSON.stringify(data)
  255. mesCont="断网";
  256. debuggerLog();
  257. }
  258. }
  259. function noLine(){
  260. $.ajax({
  261. type: "get",
  262. url: huayi.config.callcenter_url + 'UserAccount/GetNowUser',
  263. async: true,
  264. dataType: 'json',
  265. data: {
  266. "token": $.cookie("token")
  267. },
  268. success: function(data) {
  269. reconnecTion = data.data.user.F_UserCode;
  270. }
  271. });
  272. }
  273. //发送
  274. function Send() {
  275. if(ws.readyState != ws.OPEN) {
  276. if(loginOr){
  277. errorState=true;
  278. $("#top-search li i").removeClass("active");
  279. $(".Login").addClass("active");
  280. $(".zxzt").removeClass("bl").addClass("br");
  281. $(".fwzt").removeClass("bl").addClass("br");
  282. $(".hwzt").text('');
  283. directType="send";
  284. sendType=ws.readyState; //JSON.stringify(data)
  285. mesCont="签入时异常了";
  286. debuggerLog();
  287. $(".hwzt").text('连接异常!');
  288. reconnect();
  289. }else{
  290. errorState=false;
  291. $("#top-search li i").removeClass("active");
  292. $(".Login").addClass("active");
  293. $(".zxzt").removeClass("bl").addClass("br");
  294. $(".fwzt").removeClass("bl").addClass("br");
  295. $(".hwzt").text('');
  296. directType="send";
  297. sendType=ws.readyState; //JSON.stringify(data)
  298. mesCont="异常了";
  299. debuggerLog();
  300. $(".hwzt").text('连接异常!');
  301. reconnect();
  302. }
  303. }
  304. if(ws.readyState == ws.OPEN) {
  305. if (obj.Type) {
  306. directType="send";
  307. sendType=obj.Type;
  308. mesCont=JSON.stringify(obj);
  309. debuggerLog()
  310. }else{
  311. directType="send";
  312. sendType="建立连接";
  313. mesCont=JSON.stringify(obj);
  314. debuggerLog()
  315. }
  316. console.log(new Date() + " send " + JSON.stringify(obj));
  317. ws.send(JSON.stringify(obj));
  318. }
  319. }
  320. //心跳检测
  321. var heartCheck = {
  322. timeout: 25000, //25秒
  323. timeoutObj: null,
  324. serverTimeoutObj: null,
  325. reset: function() {
  326. clearTimeout(this.timeoutObj);
  327. clearTimeout(this.serverTimeoutObj);
  328. return this;
  329. },
  330. start: function() {
  331. var self = this;
  332. this.timeoutObj = setTimeout(function() {
  333. //这里发送一个心跳,后端收到后,返回一个心跳消息,
  334. //onmessage拿到返回的心跳就说明连接正常
  335. obj.Type = "Heart";
  336. Send();
  337. self.serverTimeoutObj = setTimeout(function() { //如果超过一定时间还没重置,说明后端主动断开了
  338. ws.close(); //如果onclose会执行reconnect,我们执行ws.close()就行了.如果直接执行reconnect 会触发onclose导致重连两次
  339. //同步签出状态
  340. $("#top-search li i").removeClass("active");
  341. $(".Login").addClass("active");
  342. $(".zxzt").removeClass("bl").addClass("br");
  343. $(".fwzt").removeClass("bl").addClass("br");
  344. $(".hwzt").text('');
  345. //打印日志
  346. directType="heart";
  347. sendType="心跳"; //JSON.stringify(data)
  348. mesCont="未收到";
  349. debuggerLog();
  350. if(cls == 0) {
  351. cls = 1;
  352. reconnect();
  353. }
  354. }, self.timeout)
  355. }, this.timeout)
  356. }
  357. }
  358. //签入
  359. function LoginBack() {
  360. $("#top-search li i").removeClass("active");
  361. $(".Logout").addClass("active");
  362. $(".SayBusy").addClass("active");
  363. $(".MakeCall").addClass("active");
  364. $(".zxzt").removeClass("br").addClass("bl");
  365. $(".fwzt").removeClass("br").addClass("bl");
  366. $(".hwzt").text('空闲');
  367. timeId = setInterval(function() {
  368. judgmentCallOut()
  369. },huayi.config.outCallTime);
  370. }
  371. //签出
  372. function LogoutBack() {
  373. $("#top-search li i").removeClass("active");
  374. $(".Login").addClass("active");
  375. $(".zxzt").removeClass("bl").addClass("br");
  376. $(".fwzt").removeClass("bl").addClass("br");
  377. $(".hwzt").text('');
  378. }
  379. //来电
  380. function IncomingBack(data) {
  381. clearInterval(timeId);
  382. if(data.CallID!=0){
  383. var p = '<a href="javascript:;" class="active J_menuTab" data-id="./callScreen/callScreen.html?tel=' + data.Number + '&CallID=' + data.CallID + '">来电弹屏' + data.Number + ' <i class="fa fa-times-circle close_call"></i></a>';
  384. $(".J_menuTab").removeClass("active");
  385. var nif = '<iframe class="J_iframe J_iframeNew" name="iframe'+ data.CallID +'" width="100%" height="100%" src="./callScreen/callScreen.html?Number=' + data.Number + '&CallID=' + data.CallID + '&ActionID=' + data.ActionID + '&callDirection=0" frameborder="0" data-id="./callScreen/callScreen.html?tel=' + data.Number + '&CallID=' + data.CallID + '" seamless></iframe>';
  386. $(".J_mainContent").find("iframe.J_iframe").hide().parents(".J_mainContent").append(nif);
  387. $(".J_menuTabs .page-tabs-content").append(p);
  388. hidTel=data.Number;
  389. hidCallID=data.CallID;
  390. hidActionID=data.ActionID;
  391. }else{
  392. var timestamp = Date.parse(new Date());
  393. var p = '<a href="javascript:;" class="active J_menuTab" data-id="./callScreen/callScreen.html?tel=' + data.Number + '&CallID='+timestamp+'">来电弹屏' + data.Number + ' <i class="fa fa-times-circle close_call"></i></a>';
  394. $(".J_menuTab").removeClass("active");
  395. var nif = '<iframe class="J_iframe J_iframeNew" name="iframe'+timestamp+'" width="100%" height="100%" src="./callScreen/callScreen.html?Number=' + data.Number + '&CallID='+timestamp+'&callDirection=0" frameborder="0" data-id="./callScreen/callScreen.html?tel=' + data.Number + '&CallID='+timestamp+'" seamless></iframe>';
  396. $(".J_mainContent").find("iframe.J_iframe").hide().parents(".J_mainContent").append(nif);
  397. $(".J_menuTabs .page-tabs-content").append(p);
  398. hidTel=data.Number;
  399. hidCallID=timestamp;
  400. }
  401. }
  402. //***************************************************
  403. function CallIDBack(data) {
  404. //$(".hidCallID").val(data.CurrID);
  405. }
  406. //挂断
  407. function DropCallBack() {
  408. var makeCallPhone = obj.DestinationNumber;
  409. $("#top-search li i").removeClass("active");
  410. $(".Logout").addClass("active");
  411. $(".SayBusy").addClass("active");
  412. $(".MakeCall").addClass("active");
  413. if(window.frames['iframe'+ hidCallID +'']){
  414. window.frames['iframe'+ hidCallID +''].$(".td-call").hide();
  415. }
  416. if ($("#isml").val() === "1") {
  417. $(".SayBusy").removeClass("active");
  418. $(".SayFree").addClass("active");
  419. $(".zxzt").removeClass("bl").addClass("br");
  420. $(".hwzt").text('置忙');
  421. }
  422. timeId = setInterval(function() {
  423. judgmentCallOut()
  424. },huayi.config.outCallTime);
  425. iframeOutbound === 0
  426. // if (iframeOutbound === 1) {
  427. // //结束通话
  428. // $.ajax({
  429. // type: "get",
  430. // url: huayi.config.callcenter_url + "RegRecordsCallOut/Update2",
  431. // async: true,
  432. // dataType: 'json',
  433. // data: {
  434. // token: $.cookie("token"),
  435. // phone: makeCallPhone,
  436. // },
  437. // success: function(result) {
  438. // if(result.state.toLowerCase() == "success") {
  439. // timeId = setInterval(function() {
  440. // judgmentCallOut()
  441. // },huayi.config.outCallTime);
  442. // }
  443. // }
  444. // });
  445. // }
  446. }
  447. //线路状态通知
  448. function LineStateAgentBack(data) {
  449. var objiframe = $("iframe:visible")
  450. //0分机不可用,1空闲,2摘机等待拨号,3正在拨号,4呼出振铃,5来电振铃,6通话中,7播放忙音中,8移除IP分机,9通话保持中
  451. if(data.State == '0') {
  452. $(".hwzt").text('分机不可用'); //左下角状态显示
  453. //$(".fwzt").removeClass("br").removeClass("bl");
  454. $(".fwzt").removeClass("bl").addClass("br");//20180509 by fanlongfei 增加话机状态灯
  455. $(".zxzt").removeClass("bl").addClass("br");//20180509 by fanlongfei 增加坐席状态灯
  456. }
  457. if(data.State == '1') {
  458. // var isml=0;
  459. if($("#isml").val()==1){
  460. // isml=1;
  461. $(".hwzt").text('置忙'); //左下角状态显示
  462. $(".zxzt").removeClass("bl").addClass("br");
  463. }
  464. else{
  465. $(".hwzt").text('空闲'); //左下角状态显示
  466. $(".zxzt").removeClass("br").addClass("bl");
  467. }
  468. $(".fwzt").removeClass("br").addClass("bl");
  469. // $(".zxzt").removeClass("br").addClass("bl");//20180509 by fanlongfei 增加坐席状态灯
  470. if(window.frames['iframe'+ hidCallID +'']){
  471. window.frames['iframe'+ hidCallID +''].clearInter();
  472. }
  473. if (hidTel && hidCallID) {
  474. $.post(huayi.config.callcenter_url + 'CallInScreen/UpdateGJ', {
  475. callid: hidTel,
  476. "token": $.cookie("token")
  477. }, function (result) {
  478. result = JSON.parse(result);
  479. if (result.state.toLowerCase() == "success") { }
  480. })
  481. }
  482. $("#top-search li i").removeClass("active");
  483. $(".Logout").addClass("active");
  484. if($("#isml").val()==0){
  485. $(".SayBusy").addClass("active");
  486. }
  487. else{
  488. $(".SayFree").addClass("active");
  489. }
  490. $(".MakeCall").addClass("active");
  491. if(window.frames['iframe'+ hidCallID +'']){
  492. window.frames['iframe'+ hidCallID +''].$(".td-call").hide();
  493. }
  494. }
  495. if(data.State == '2') {
  496. $(".hwzt").text('摘机等待拨号'); //左下角状态显示
  497. }
  498. if(data.State == '3') {
  499. $(".hwzt").text('正在拨号'); //左下角状态显示
  500. }
  501. if(data.State == '4') {
  502. $(".hwzt").text('呼出振铃'); //左下角状态显示
  503. }
  504. if(data.State == '5') {
  505. $(".hwzt").text('来电振铃'); //左下角状态显示
  506. //$(".fwzt").removeClass("bl").addClass("br");
  507. $(".fwzt").removeClass("br").addClass("bl");//20180509 by fanlongfei 增加话机状态灯
  508. $(".zxzt").removeClass("bl").addClass("br");//20180509 by fanlongfei 增加坐席状态灯
  509. if (hidTel && hidCallID) {
  510. $.post(huayi.config.callcenter_url + 'CallInScreen/UpdateZL', {
  511. callid: hidCallID,
  512. "token": $.cookie("token")
  513. }, function (result) {
  514. result = JSON.parse(result);
  515. if (result.state.toLowerCase() == "success") { }
  516. })
  517. }
  518. }
  519. if(data.State == '6') {
  520. $(".hwzt").text('通话中'); //左下角状态显示
  521. $(".fwzt").removeClass("bl").addClass("br");
  522. $(".zxzt").removeClass("bl").addClass("br");//20180509 by fanlongfei 增加坐席状态灯
  523. if(hidTel && hidCallID) {
  524. $.post(huayi.config.callcenter_url + 'CallInScreen/UpdateZJ', {
  525. callid: hidCallID,
  526. "token": $.cookie("token")
  527. }, function(result) {
  528. result = JSON.parse(result);
  529. if(result.state.toLowerCase() == "success") {}
  530. })
  531. }
  532. $("#top-search li i").removeClass("active");
  533. $(".DropCall").addClass("active");
  534. $(".Hold").addClass("active");
  535. $(".Transfer").addClass("active");
  536. $(".Meeting").addClass("active");
  537. if(data.CallDirection=="in"){
  538. // window.frames['iframe'+ hidCallID +''].window.onload = function(){
  539. // var callingFun = window.frames['iframe'+ hidCallID +''].window.calling;
  540. // callingFun();
  541. // }
  542. // if (objiframe.attr("data-id") == './callScreen/callScreen.html?tel=' + hidTel + '&CallID=' + hidCallID + '') {
  543. setTimeout (window.frames['iframe'+ hidCallID +''].calling(),500);/*2018-05-19 zhangshuangnan 修改 ps: 因软电话设置为 自动应答 通话时间不计时问题*/
  544. // }
  545. }
  546. }
  547. if(data.State == '7') {
  548. $(".hwzt").text('播放忙音中'); //左下角状态显示
  549. }
  550. if(data.State == '8') {
  551. $(".hwzt").text('移除IP分机'); //左下角状态显示
  552. }
  553. if(data.State == '9') {
  554. $(".hwzt").text('通话保持中'); //左下角状态显示
  555. }
  556. }
  557. function toDub(i) {
  558. return i < 10 ? "0" + i : "" + i;
  559. }
  560. //外呼
  561. function MakeCallBack(data) {
  562. // var makeCallPhone = $.cookie("makeCallPhone");
  563. var makeCallPhone = obj.DestinationNumber;
  564. $("#top-search li i").removeClass("active");
  565. $(".DropCall").addClass("active");
  566. //外呼弹屏
  567. debugger
  568. if(data.CallID!=0){
  569. if (iframeOutbound === 0) {
  570. var p = '<a href="javascript:;" class="active J_menuTab" data-id="./callScreen/callScreen.html?tel=' + makeCallPhone + '&CallID=' + makeCallId + '">外呼弹屏' + makeCallPhone + ' <i class="fa fa-times-circle close_call"></i></a>';
  571. $(".J_menuTab").removeClass("active");
  572. var nif = '<iframe class="J_iframe J_iframeNew" name="iframe'+ makeCallId +'" width="100%" height="100%" src="./callScreen/callScreen.html?Number=' + makeCallPhone + '&CallID=' + makeCallId + '&ActionID=' + data.ActionID + '&callDirection=1" frameborder="0" data-id="./callScreen/callScreen.html?tel=' + makeCallPhone + '&CallID=' + makeCallId + '" seamless></iframe>';
  573. $(".J_mainContent").find("iframe.J_iframe").hide().parents(".J_mainContent").append(nif);
  574. $(".J_menuTabs .page-tabs-content").append(p);
  575. hidTel=makeCallPhone;
  576. hidCallID=makeCallId;
  577. hidActionID=data.ActionID;
  578. } else if (iframeOutbound === 1) {
  579. var p = '<a href="javascript:;" class="active J_menuTab" data-id="./callScreen/callScreen.html?tel=' + makeCallPhone + '&CallID=' + makeCallId + '">外呼弹屏' + makeCallPhone + ' <i class="fa fa-times-circle close_call"></i></a>';
  580. $(".J_menuTab").removeClass("active");
  581. var nif = '<iframe class="J_iframe J_iframeNew" name="iframe'+ makeCallId +'" width="100%" height="100%" src="./callScreen/callScreen.html?Number=' + makeCallPhone + '&CallID=' + makeCallId + '&ActionID=' + data.ActionID + '&callDirection=1" frameborder="0" data-id="./callScreen/callScreen.html?tel=' + makeCallPhone + '&CallID=' + makeCallId + '" seamless></iframe>';
  582. $(".J_mainContent").find("iframe.J_iframe").hide().parents(".J_mainContent").append(nif);
  583. $(".J_menuTabs .page-tabs-content").append(p);
  584. hidTel=makeCallPhone;
  585. hidCallID=makeCallId;
  586. hidActionID=data.ActionID;
  587. }
  588. } else {
  589. var timestamp = Date.parse(new Date());
  590. var p = '<a href="javascript:;" class="active J_menuTab" data-id="./callScreen/callScreen.html?tel=' + makeCallPhone + '&CallID='+timestamp+'">外呼弹屏' + makeCallPhone + ' <i class="fa fa-times-circle close_call"></i></a>';
  591. $(".J_menuTab").removeClass("active");
  592. var nif = '<iframe class="J_iframe J_iframeNew" name="iframe'+timestamp+'" width="100%" height="100%" src="./callScreen/callScreen.html?Number=' + makeCallPhone + '&CallID='+timestamp+'&callDirection=1" frameborder="0" data-id="./callScreen/callScreen.html?tel=' + makeCallPhone + '&CallID='+timestamp+'" seamless></iframe>';
  593. $(".J_mainContent").find("iframe.J_iframe").hide().parents(".J_mainContent").append(nif);
  594. $(".J_menuTabs .page-tabs-content").append(p);
  595. hidTel=makeCallPhone;
  596. hidCallID=timestamp;
  597. }
  598. window.frames['iframe'+ hidCallID +''].window.onload = function(){
  599. var callingFun = window.frames['iframe'+ hidCallID +''].window.calling;
  600. callingFun();
  601. }
  602. // setTimeout (window.frames['iframe'+ hidCallID +''].calling(),500);
  603. // window.frames[obj.attr("name")].calling();
  604. }
  605. //置忙置闲
  606. function SetState(obj) {
  607. if(obj.State == '5') {
  608. $(".SayBusy").removeClass("active");
  609. $(".SayFree").addClass("active");
  610. $(".zxzt").removeClass("bl").addClass("br");
  611. $(".hwzt").text('置忙');
  612. $("#isml").val(1)
  613. }
  614. if(obj.State == '2') {
  615. $(".SayBusy").addClass("active");
  616. $(".SayFree").removeClass("active");
  617. $(".zxzt").removeClass("br").addClass("bl");
  618. $(".hwzt").text('空闲');
  619. $("#isml").val(0)
  620. }
  621. }
  622. //置忙
  623. function SayBusyBack() {
  624. $(".SayBusy").removeClass("active");
  625. $(".SayFree").addClass("active");
  626. $("#isml").val(1)
  627. }
  628. //坐席班长置闲
  629. function SayFreeBack() {
  630. $(".SayBusy").addClass("active");
  631. $(".SayFree").removeClass("active");
  632. $(".zxzt").removeClass("br").addClass("bl"); // 2018/05/09 by fanlongfei 增加坐席状态指示
  633. $(".hwzt").text('空闲');// 2018/05/09 by fanlongfei 增加坐席状态指示
  634. $("#isml").val(0)
  635. }
  636. //多方通话
  637. function MeetingBack() {
  638. }
  639. //转移
  640. function TransferBack() {
  641. $("#top-search li i").removeClass("active");
  642. $(".Logout").addClass("active");
  643. $(".SayBusy").addClass("active");
  644. $(".MakeCall").addClass("active");
  645. }
  646. //保持
  647. function HoldBack() {
  648. $(".Hold").removeClass("active");
  649. $(".Retrieve").addClass("active");
  650. }
  651. //接回
  652. function RetrieveBack() {
  653. $(".Hold").addClass("active");
  654. $(".Retrieve").removeClass("active");
  655. }
  656. //监测
  657. function SubScribeBack() {
  658. $('#content-main .J_iframeNew').each(function(i,n){
  659. if($(this).attr('data-id') == "./TelCall/SeatMonitor.html"){
  660. window.frames[$(this).attr("name")].Start();
  661. }
  662. })/*2018-05-24 zhangshuangnan 修改 解决通话中时 坐席监控状态不改变的问题*/
  663. }
  664. //取消监测
  665. function SubScribeCancelBack() {
  666. // var obj = $("iframe:visible")
  667. // if(obj.attr("data-id") == "./TelCall/SeatMonitor.html") {
  668. // window.frames[obj.attr("name")].();
  669. // }
  670. $('#content-main .J_iframeNew').each(function(i,n){
  671. if($(this).attr('data-id') == "./TelCall/SeatMonitor.html"){
  672. window.frames[$(this).attr("name")].Stop();
  673. }
  674. })/*2018-05-24 zhangshuangnan 修改 解决通话中时 坐席监控状态不改变的问题*/
  675. }
  676. //班长监测返回状态
  677. //坐席状态
  678. function AgentStateBack(data) {
  679. $('#content-main .J_iframeNew').each(function(i,n){
  680. if($(this).attr('data-id') == "./TelCall/SeatMonitor.html"){
  681. window.frames[$(this).attr("name")].UpdateAgentState(data.AgentID, data.State);
  682. }
  683. })/*2018-05-24 zhangshuangnan 修改 解决通话中时 坐席监控状态不改变的问题*/
  684. }
  685. //线路状态
  686. function LineStateBack(data) {
  687. $('#content-main .J_iframeNew').each(function(i,n){
  688. if($(this).attr('data-id') == "./TelCall/SeatMonitor.html"){
  689. window.frames[$(this).attr("name")].UpdateLineState(data.AgentID, data.State);
  690. }
  691. })/*2018-05-24 zhangshuangnan 修改 解决通话中时 坐席监控状态不改变的问题*/
  692. }
  693. //录音返回
  694. function RecordPathBack(data) {
  695. $(".hidCallID").val(data.CallID);
  696. //if ($(".hidTel").val() && $(".hidCallID").val()) {
  697. // $.post(huayi.config.callcenter_url + 'CallInScreen/UpdateLY', { callid: $(".hidCallID").val(),path:data.RecPath, "token": $.cookie("token") }, function (result) {
  698. // result = JSON.parse(result);
  699. // if (result.state.toLowerCase() == "success") {
  700. // }
  701. // })
  702. //}
  703. // 外呼返回CallId
  704. makeCallId = data.CallID;
  705. if(hidTel) {
  706. $.post(huayi.config.callcenter_url + 'CallInScreen/UpdateLY', {
  707. callid: data.CallID,
  708. path: data.RecPath,
  709. "token": $.cookie("token")
  710. }, function(result) {
  711. result = JSON.parse(result);
  712. if(result.state.toLowerCase() == "success") {}
  713. })
  714. }
  715. }
  716. //获取当前的日期时间 格式“yyyy-MM-dd HH:mm:ss”
  717. function getNowFormatDate() {
  718. var date = new Date();
  719. var seperator1 = "-";
  720. var seperator2 = ":";
  721. var month = date.getMonth() + 1;
  722. var strDate = date.getDate();
  723. if(month >= 1 && month <= 9) {
  724. month = "0" + month;
  725. }
  726. if(strDate >= 0 && strDate <= 9) {
  727. strDate = "0" + strDate;
  728. }
  729. var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate +
  730. " " + date.getHours() + seperator2 + date.getMinutes() +
  731. seperator2 + date.getSeconds();
  732. return currentdate;
  733. }