Нет описания

main.js 25KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769
  1. if (typeof console == "undefined") {
  2. this.console = { log: function (msg) { } };
  3. }
  4. // 如果浏览器不支持websocket,会使用这个flash自动模拟websocket协议,此过程对开发者透明
  5. WEB_SOCKET_SWF_LOCATION = "./js/websocket/WebSocketMain.swf";
  6. // 开启flash的websocket debug
  7. WEB_SOCKET_DEBUG = true;
  8. var ws, n = 0,
  9. timer;
  10. var lockReconnect = false; //避免重复连接
  11. var obj = {};
  12. var Statess;
  13. var cls = 0;
  14. var lasttime = new Date().getTime();
  15. //创建scoket连接
  16. function createWebSocket() {
  17. try {
  18. $("#top-search li i").removeClass("active");
  19. Connect();
  20. } catch (e) {
  21. reconnect();
  22. }
  23. }
  24. //连接
  25. function Connect() {
  26. ws = new WebSocket("ws://" + huayi.config.socket_ip + ":" + huayi.config.socket_port);
  27. ws.onopen = function () {
  28. console.log(new Date() + " " + "建立连接");
  29. //心跳检测重置
  30. heartCheck.reset().start();
  31. cls = 0;
  32. $(".Login").addClass("active");
  33. lasttime = new Date().getTime();
  34. //自动签入
  35. // if ($.cookie("socket_state") != null) {
  36. // SetLogin($.cookie("socket_state"));
  37. // }
  38. //$(".hwzt").text('连接成功!');
  39. };
  40. //接收到消息的回调方法
  41. ws.onmessage = function (evt) {
  42. //如果获取到消息,心跳检测重置
  43. //拿到任何消息都说明当前连接是正常的
  44. heartCheck.reset().start();
  45. var myDate = new Date();
  46. console.log(myDate + " receive " + evt.data);
  47. var data = JSON.parse(evt.data)[0];
  48. if (data) {
  49. var rlt = data.Result;
  50. if (rlt == true) {
  51. var type = data.Type;
  52. switch (type.toLowerCase()) {
  53. //case "heart": HeartBack(); break;//心跳
  54. case "login":
  55. LoginBack();
  56. break; //签入
  57. case "logout":
  58. LogoutBack();
  59. break; //签出
  60. case "dropcall":
  61. DropCallBack();
  62. break; //挂断
  63. case "makecall":
  64. MakeCallBack();
  65. break; //外呼
  66. case "setstate":
  67. SetState(data);
  68. break; //置忙置闲
  69. //case "saybusy": SayBusyBack(data); break;
  70. //case "sayfree": SayFreeBack(data); break;
  71. case "meeting":
  72. MeetingBack();
  73. break; //多方通话
  74. case "transfer":
  75. TransferBack();
  76. break; //转移
  77. case "hold":
  78. HoldBack();
  79. break; //保持
  80. case "retrieve":
  81. RetrieveBack();
  82. break; //接回
  83. case "incoming":
  84. IncomingBack(data);
  85. break; //来电
  86. case "subscribe":
  87. SubScribeBack();
  88. break; //监测
  89. case "subscribecancel":
  90. SubScribeCancelBack();
  91. break; //停止监测
  92. case "agentstate":
  93. AgentStateBack(data);
  94. break; //坐席状态
  95. case "linestate":
  96. LineStateBack(data);
  97. break; //线路状态
  98. case "motorsetstate":
  99. SayFreeBack();
  100. break; //班长置闲
  101. case "linestateagent":
  102. LineStateAgentBack(data);
  103. break; //线路状态通知
  104. case "agentstateagent":
  105. AgentStateAgentBack(data);
  106. break; //坐席状态通知
  107. //case "callid":
  108. // CallIDBack(data);
  109. // break; //获取callid
  110. //case "recordpath":
  111. // RecordPathBack(data);
  112. // break; //录音返回
  113. case "getagentlist":
  114. GetAgentListBack(data);
  115. break;//在线坐席信息
  116. case "confirmtransfer":
  117. ConfirmTransfer(data);
  118. break;//确认转移 取消转移
  119. case "consult":
  120. ConsultationCall();
  121. break;//协商呼叫
  122. case "waitcount":
  123. backstageQueue();
  124. break;//后台排队
  125. }
  126. } else {
  127. if (rlt == false) {
  128. //layer.confirm('操作失败!', {
  129. // btn: ['确定']
  130. //});
  131. $(".hwzt").text('操作失败!');
  132. } else {
  133. $(".hwzt").text(rlt);
  134. //layer.confirm(rlt, {
  135. // btn: ['确定']
  136. //});
  137. }
  138. }
  139. }
  140. };
  141. //连接关闭的回调方法
  142. ws.onclose = function (evt) {
  143. if (cls == 0) {
  144. cls = 1;
  145. //console.log("连接关闭!");
  146. //layer.confirm('连接关闭!', {
  147. // btn: ['确定']
  148. //});
  149. $(".hwzt").text('连接关闭!');
  150. $("#top-search li i").removeClass("active");
  151. reconnect();
  152. }
  153. };
  154. //连接发生错误的回调方法
  155. ws.onerror = function (evt) {
  156. //产生异常
  157. $(".hwzt").text('连接出现异常!');
  158. console.log(ws);
  159. if (ws == null || ws.readyState != ws.OPEN) {
  160. console.log(new Date() + "开始重连");
  161. reconnect();
  162. }
  163. };
  164. }
  165. //重连
  166. function reconnect() {
  167. if (lockReconnect) return;
  168. lockReconnect = true;
  169. //没连接上会一直重连,设置延迟避免请求过多
  170. setTimeout(function () {
  171. console.log(new Date() + " " + "重连中……");
  172. createWebSocket("ws://" + huayi.config.socket_ip + ":" + huayi.config.socket_port);
  173. lockReconnect = false;
  174. }, 2000);
  175. }
  176. //发送
  177. function Send() {
  178. if (ws.readyState != ws.OPEN) {
  179. reconnect();
  180. }
  181. if (ws.readyState == ws.OPEN) {
  182. console.log(new Date() + " send " + JSON.stringify(obj));
  183. ws.send(JSON.stringify(obj));
  184. }
  185. }
  186. //心跳检测
  187. var heartCheck = {
  188. timeout: 25000, //25秒
  189. timeoutObj: null,
  190. serverTimeoutObj: null,
  191. reset: function () {
  192. clearTimeout(this.timeoutObj);
  193. clearTimeout(this.serverTimeoutObj);
  194. return this;
  195. },
  196. start: function () {
  197. var self = this;
  198. this.timeoutObj = setTimeout(function () {
  199. //这里发送一个心跳,后端收到后,返回一个心跳消息,
  200. //onmessage拿到返回的心跳就说明连接正常
  201. obj.Type = "Heart";
  202. Send();
  203. self.serverTimeoutObj = setTimeout(function () { //如果超过一定时间还没重置,说明后端主动断开了
  204. ws.close(); //如果onclose会执行reconnect,我们执行ws.close()就行了.如果直接执行reconnect 会触发onclose导致重连两次
  205. }, self.timeout)
  206. }, this.timeout)
  207. }
  208. }
  209. //签入
  210. function LoginBack() {
  211. $("#top-search li i").removeClass("active");
  212. $(".Logout").addClass("active");
  213. $(".SayBusy").addClass("active");
  214. $(".MakeCall").addClass("active");
  215. $(".zxzt").removeClass("br").addClass("bl");
  216. $(".fwzt").removeClass("br").addClass("bl");
  217. $(".hwzt").text('');
  218. $('.Consult').addClass("active");
  219. // if($.cookie("socket_state") == null){
  220. // SetStateCookie(0);
  221. // }
  222. $("#isml").val(1);
  223. // SetStateCookie(1);
  224. obj.Type = "SayBusy";
  225. Send();
  226. }
  227. //签出
  228. function LogoutBack() {
  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. // SetStateCookie(2);
  235. }
  236. //来电
  237. function IncomingBack(data) {
  238. $(".ldhm").val(data.Number);
  239. $(".hidTel").val(data.Number);
  240. $(".tel").text(data.Number);
  241. $(".ldtime").text(getNowFormatDate());
  242. $(".thsc").text("00:00");
  243. $(".hidCallID").val(data.CallID);
  244. //获取电话所属地
  245. $.getJSON(huayi.config.callcenter_url + 'CallInScreen/GetPhoneLocation', {
  246. "tel": $(".hidTel").val(),
  247. "token": $.cookie("token")
  248. }, function (result) {
  249. if (result.state.toLowerCase() == "success") {
  250. $(".ldlocation").text(result.data[0].F_Name);
  251. $(".khgsd").text(result.data[0].F_Name);
  252. }
  253. })
  254. //获取客户信息
  255. $(".ttsdh").text($(".hidTel").val());
  256. $(".tsdh").val($(".hidTel").val());
  257. $.getJSON(huayi.config.callcenter_url + 'CallInScreen/GetCustomerByTel', {
  258. "tel": $(".hidTel").val(),
  259. "token": $.cookie("token")
  260. }, function (result) {
  261. if (result.state.toLowerCase() == "success") {
  262. if (result.data.length > 0) {
  263. $(".khmc").val(result.data[0].F_CustomerName);
  264. $(".tkhmc").text(result.data[0].F_CustomerName);
  265. $("#khid").val(result.data[0].F_CustomerId);
  266. $(".lxdh").val(result.data[0].F_Telephone);
  267. //$(".tsdh").val(result.data[0].F_Mobile);
  268. //$(".ttsdh").text(result.data[0].F_Mobile);
  269. $(".lxr").val(result.data[0].F_CustomerEName);
  270. $(".postcode").val(result.data[0].F_PostCode);
  271. $(".email").val(result.data[0].F_Email);
  272. }
  273. else {
  274. $(".khmc").val("");
  275. $(".tkhmc").text("");
  276. $("#khid").val("");
  277. $(".lxr").val("");
  278. $(".postcode").val("");
  279. $(".email").val("");
  280. }
  281. }
  282. })
  283. $('.maxOpen').trigger("click");
  284. $('.head-pic .lahei .la-before').show();
  285. //触发来电类型第一个 点击;
  286. $("#dicValueList li:first-child").find("label").trigger('click');
  287. $('.head-pic .lahei .la-after').hide();
  288. $(".Bacha").hide();
  289. }
  290. //挂断
  291. function DropCallBack() {
  292. debugger
  293. $("#top-search li i").removeClass("active");
  294. $(".Logout").addClass("active");
  295. $(".SayBusy").removeClass("active");
  296. $(".SayFree").addClass("active");
  297. $(".MakeCall").addClass("active");
  298. $(".td-call").hide();
  299. $(".zxzt").removeClass("bl").removeClass("br").addClass("by");
  300. $(".hwzt").text('忙碌');
  301. $("#isml").val(1);
  302. // SetStateCookie(1);
  303. obj.Type = "SayBusy";
  304. Send();
  305. //$('.ldtp-con').css("display", 'none');
  306. }
  307. //线路状态通知
  308. function LineStateAgentBack(data) {
  309. //0分机不可用,1空闲,2摘机等待拨号,3正在拨号,4呼出振铃,5来电振铃,6通话中,7播放忙音中,8移除IP分机,9通话保持中
  310. if (data.State == '0') {
  311. $(".hwzt").text('分机不可用'); //左下角状态显示
  312. $(".fwzt").removeClass("br").removeClass("bl");
  313. }
  314. if (data.State == '1') {
  315. if($("#isml").val()==1){
  316. // isml=1;
  317. $(".hwzt").text('置忙'); //左下角状态显示
  318. $(".fwzt").removeClass("bl").addClass("br");
  319. }
  320. else{
  321. if ($("#RoleCode").val()=='ZJZY') {
  322. $(".hwzt").text('置忙'); //左下角状态显示
  323. $(".fwzt").removeClass("bl").addClass("br");
  324. }else{
  325. $(".hwzt").text('空闲'); //左下角状态显示
  326. $(".fwzt").removeClass("br").addClass("bl");
  327. }
  328. }
  329. // $(".hwzt").text('空闲'); //左下角状态显示
  330. // $(".fwzt").removeClass("br").addClass("bl");
  331. clearInterval(timer);
  332. //2018-10-13 clq 作废挂机
  333. //if ($(".hidTel").val() && $(".hidCallID").val()) {
  334. // $.post(huayi.config.callcenter_url + 'CallInScreen/UpdateGJ', {
  335. // callid: $(".hidCallID").val(),
  336. // "token": $.cookie("token")
  337. // }, function (result) {
  338. // result = JSON.parse(result);
  339. // if (result.state.toLowerCase() == "success") { }
  340. // })
  341. //}
  342. $("#top-search li i").removeClass("active");
  343. $(".Logout").addClass("active");
  344. if($("#isml").val()==0){
  345. $(".SayBusy").addClass("active");
  346. }
  347. else{
  348. $(".SayFree").addClass("active");
  349. }
  350. // $(".SayBusy").addClass("active");
  351. $(".MakeCall").addClass("active");
  352. $(".td-call").hide();
  353. $(".Bacha").show();
  354. //$(".hidTel").val("");
  355. //$(".hidCallID").val("");
  356. }
  357. if (data.State == '2') {
  358. $(".hwzt").text('摘机等待拨号'); //左下角状态显示
  359. }
  360. if (data.State == '3') {
  361. $(".hwzt").text('正在拨号'); //左下角状态显示
  362. }
  363. if (data.State == '4') {
  364. $(".hwzt").text('呼出振铃'); //左下角状态显示
  365. }
  366. if (data.State == '5') {
  367. $(".hwzt").text('来电振铃'); //左下角状态显示
  368. $(".fwzt").removeClass("bl").addClass("br");
  369. if ($(".hidTel").val() && $(".hidCallID").val()) {
  370. $.post(huayi.config.callcenter_url + 'CallInScreen/UpdateZL', {
  371. callid: $(".hidCallID").val(),
  372. "token": $.cookie("token")
  373. }, function (result) {
  374. result = JSON.parse(result);
  375. if (result.state.toLowerCase() == "success") { }
  376. })
  377. }
  378. }
  379. if (data.State == '6') {
  380. $(".hwzt").text('通话中'); //左下角状态显示
  381. $(".fwzt").removeClass("bl").addClass("br");
  382. $(".zxzt").removeClass("bl").addClass("br");
  383. if ($(".hidTel").val() && $(".hidCallID").val()) {
  384. $.post(huayi.config.callcenter_url + 'CallInScreen/UpdateZJ', {
  385. callid: $(".hidCallID").val(),
  386. "token": $.cookie("token")
  387. }, function (result) {
  388. result = JSON.parse(result);
  389. if (result.state.toLowerCase() == "success") { }
  390. })
  391. }
  392. $(".td-call").show();
  393. n = 0;
  394. $("#top-search li i").removeClass("active");
  395. $(".DropCall").addClass("active");
  396. $(".Hold").addClass("active");
  397. $(".Transfer").addClass("active");
  398. $(".Meeting").addClass("active");
  399. $('.TurnIvr').addClass("active");
  400. $('.Consult').addClass("active");
  401. clearInterval(timer);
  402. timer = setInterval(function () {
  403. n++;
  404. var m = parseInt(n / 60 % 60);
  405. var s = parseInt(n % 60);
  406. $(".thsc").text(toDub(m) + ":" + toDub(s));
  407. }, 1000);
  408. }
  409. if (data.State == '7') {
  410. $(".hwzt").text('播放忙音中'); //左下角状态显示
  411. }
  412. if (data.State == '8') {
  413. $(".hwzt").text('移除IP分机'); //左下角状态显示
  414. }
  415. if (data.State == '9') {
  416. $(".hwzt").text('通话保持中'); //左下角状态显示
  417. }
  418. }
  419. //坐席状态通知
  420. function AgentStateAgentBack(data) {
  421. var strr = '';
  422. console.log('坐席状态'+ data.State );
  423. switch (data.State+"") {
  424. case "0":
  425. strr = "离线";
  426. $(".zxzt").removeClass("br").removeClass("bl").removeClass("by");
  427. break; //离线
  428. case "1":
  429. break; //登录中
  430. case "2":
  431. strr = "空闲";
  432. $(".zxzt").removeClass("br").removeClass("by").addClass("bl");
  433. break; //空闲
  434. case "3":
  435. strr = "通话中";
  436. $(".zxzt").removeClass("bl").removeClass("by").addClass("br");
  437. break; //通话中
  438. case "4":
  439. strr = "话后处理中";
  440. $(".zxzt").removeClass("bl").removeClass("br").addClass("by");
  441. break; //话后处理中
  442. case "5":
  443. strr = "忙碌";
  444. $(".zxzt").removeClass("bl").removeClass("br").addClass("by");
  445. break; //小休
  446. case "6":
  447. strr = "振铃";
  448. break; //被请求
  449. case "7":
  450. strr = "注销";
  451. $(".zxzt").removeClass("br").removeClass("bl").removeClass("by");
  452. break; //注销
  453. }
  454. $(".hxzt").text(strr);
  455. }
  456. function toDub(i) {
  457. return i < 10 ? "0" + i : "" + i;
  458. }
  459. //外呼
  460. function MakeCallBack() {
  461. $("#top-search li i").removeClass("active");
  462. $(".DropCall").addClass("active");
  463. $(".Meeting").addClass("active");
  464. }
  465. //默认记忆上次是否签入,是否置忙置闲 0表示已签入 空闲,1表示签入置忙,2表示签出
  466. function SetStateCookie(state) {
  467. $.cookie("socket_state", state);
  468. }
  469. //置忙 置闲
  470. function SetState(obj) {
  471. if (obj.State == '5') {
  472. $(".SayBusy").removeClass("active");
  473. $(".SayFree").addClass("active");
  474. $(".zxzt").removeClass("bl").removeClass("br").addClass("by");
  475. $(".hwzt").text('忙碌');
  476. $("#isml").val(1);
  477. // SetStateCookie(1);
  478. }
  479. if (obj.State == '2') {
  480. $(".SayBusy").addClass("active");
  481. $(".SayFree").removeClass("active");
  482. $(".zxzt").removeClass("br").removeClass("by").addClass("bl");
  483. $(".hwzt").text('空闲');
  484. $("#isml").val(0);
  485. // SetStateCookie(0);
  486. }
  487. }
  488. // 自动签入
  489. // function SetLogin(state) {
  490. // if (state == 2) { return; }
  491. // if (obj.AgentID) {
  492. // obj.Type = "Login";
  493. // if( $("#RoleCode").val()=='DBHWY'){
  494. // obj.AgentGroup = "1";
  495. // }
  496. // else if($("#RoleCode").val()=='ZJZY'){
  497. // obj.AgentGroup = "2";
  498. // }
  499. // else{
  500. // obj.AgentGroup = "364";
  501. // }
  502. // obj.AgentType = "0";
  503. // Send();
  504. // }
  505. // if (state == 1) {
  506. // setTimeout('SayBusy()', 500);
  507. // }
  508. // }
  509. //置忙
  510. function SayBusy() {
  511. if (obj.AgentID) {
  512. obj.Type = "SayBusy";
  513. Send();
  514. }
  515. }
  516. //置忙
  517. function SayBusyBack() {
  518. $(".SayBusy").removeClass("active");
  519. $(".SayFree").addClass("active");
  520. $("#isml").val(1)
  521. }
  522. //置闲
  523. function SayFreeBack() {
  524. $(".SayBusy").addClass("active");
  525. $(".SayFree").removeClass("active");
  526. $(".zxzt").removeClass("br").addClass("bl"); //坐席状态指示
  527. $(".hwzt").text('空闲');// 增加坐席状态指示
  528. $("#isml").val(0)
  529. }
  530. //多方通话
  531. function MeetingBack() {
  532. }
  533. //转移
  534. function TransferBack() {
  535. $("#top-search li i").removeClass("active");
  536. $(".Logout").addClass("active");
  537. $(".SayBusy").addClass("active");
  538. $(".MakeCall").addClass("active");
  539. }
  540. //保持
  541. function HoldBack() {
  542. $(".Hold").removeClass("active");
  543. $(".Retrieve").addClass("active");
  544. }
  545. //接回
  546. function RetrieveBack() {
  547. $(".Hold").addClass("active");
  548. $(".Retrieve").removeClass("active");
  549. }
  550. //协商呼叫
  551. function ConsultationCall() {
  552. $('.Consult').removeClass("active");
  553. $('.ConfirmTransfer').addClass("active");//确认转移
  554. $('.CancelTransfer').addClass("active");//取消转移
  555. }
  556. //确认转移&取消转移
  557. function ConfirmTransfer(data) {
  558. if (data.State == 3) {//取消转移
  559. $('.Consult').addClass("active");
  560. $(".CancelTransfer").removeClass("active");
  561. $(".ConfirmTransfer").removeClass("active");
  562. } else {
  563. //确认转移
  564. $('.Consult').removeClass("active");
  565. $(".CancelTransfer").removeClass("active");
  566. $(".ConfirmTransfer").removeClass("active");
  567. }
  568. }
  569. //监测
  570. function SubScribeBack() {
  571. var obj = $("iframe:visible")
  572. if (obj.attr("data-id") == "./TelCall/SeatMonitor.html") {
  573. window.frames[obj.attr("name")].Start();
  574. }
  575. if (obj.attr("data-id") == "./TelCall/zxKong.html") {
  576. window.frames[obj.attr("name")].Start();
  577. }
  578. }
  579. //取消监测
  580. function SubScribeCancelBack() {
  581. var obj = $("iframe:visible")
  582. if (obj.attr("data-id") == "./TelCall/SeatMonitor.html") {
  583. window.frames[obj.attr("name")].Stop();
  584. }
  585. if (obj.attr("data-id") == "./TelCall/zxKong.html") {
  586. window.frames[obj.attr("name")].Stop();
  587. }
  588. }
  589. //班长监测返回状态
  590. //坐席状态
  591. function AgentStateBack(data) {
  592. var obj = $("iframe:visible")
  593. if (obj.attr("data-id") == "./TelCall/SeatMonitor.html") {
  594. window.frames[obj.attr("name")].UpdateAgentState(data.AgentID, data.State);
  595. }
  596. if (obj.attr("data-id") == "./TelCall/zxKong.html") {
  597. window.frames[obj.attr("name")].UpdateAgentState(data.AgentID, data.State);
  598. }
  599. }
  600. //线路状态
  601. function LineStateBack(data) {
  602. var obj = $("iframe:visible")
  603. if (obj.attr("data-id") == "./TelCall/SeatMonitor.html") {
  604. window.frames[obj.attr("name")].UpdateLineState(data.AgentID, data.State);
  605. }
  606. if (obj.attr("data-id") == "./TelCall/zxKong.html") {
  607. window.frames[obj.attr("name")].UpdateLineState(data.AgentID, data.State);
  608. }
  609. }
  610. //后台排队
  611. function backstageQueue(data) {
  612. // if (obj.attr("data-id") == "./widgets.html") {
  613. // window.frames[obj.attr("name")].realTimeMonitorQueue(data.WaitCount);
  614. // }
  615. $("#backstageQueue").text(data)
  616. }
  617. //录音返回
  618. function RecordPathBack(data) {
  619. //if ($(".hidTel").val() && $(".hidCallID").val()) {
  620. // $.post(huayi.config.callcenter_url + 'CallInScreen/UpdateLY', { callid: $(".hidCallID").val(),path:data.RecPath, "token": $.cookie("token") }, function (result) {
  621. // result = JSON.parse(result);
  622. // if (result.state.toLowerCase() == "success") {
  623. // }
  624. // })
  625. //}
  626. if ($(".hidTel").val()) {
  627. $.post(huayi.config.callcenter_url + 'CallInScreen/UpdateLY', {
  628. callid: data.CallID,
  629. path: data.RecPath,
  630. "token": $.cookie("token")
  631. }, function (result) {
  632. result = JSON.parse(result);
  633. if (result.state.toLowerCase() == "success") { }
  634. })
  635. }
  636. }
  637. //在线坐席信息
  638. function GetAgentListBack(data) {
  639. console.log(data)
  640. $.ajax({
  641. type: "get",
  642. url: huayi.config.callcenter_url + "SeatMonitoring/GetAgentList",
  643. async: true,
  644. dataType: 'json',
  645. data: {
  646. "token": $.cookie("token")
  647. },
  648. success: function (result) {
  649. var user = result.data;
  650. $(user).each(function (j, m) {
  651. $(data.AgentList).each(function (k, g) {
  652. if (g.AgentID == m.UserCode) {
  653. g.userName = m.UserName;
  654. }
  655. })
  656. })
  657. $(data.AgentList).each(function (k, m) {
  658. var strr = '';
  659. switch (m.State) {
  660. case "0":
  661. strr = "离线";
  662. break; //离线
  663. case "1":
  664. break; //登录中
  665. case "2":
  666. strr = "空闲";
  667. break; //空闲
  668. case "3":
  669. strr = "通话中";
  670. break; //通话中
  671. case "4":
  672. strr = "话后处理中";
  673. break; //话后处理中
  674. case "5":
  675. strr = "忙碌";
  676. break; //小休
  677. case "6":
  678. strr = "振铃";
  679. break; //被请求
  680. case "7":
  681. strr = "注销";
  682. break; //注销
  683. }
  684. var html = '<tr fjh="' + m.AgentExten + '">' +
  685. '<td>' + (m.userName ? '' : m.userName) + '</td>' //姓名
  686. +
  687. '<td>' + m.AgentID + '</td>' //工号
  688. +
  689. '<td>' + m.AgentExten + '</td>'//分机号
  690. +
  691. '<td class=" ' + m.UserCode + 'state">' + strr + '</td>' //状态
  692. +
  693. '</tr>';
  694. $(html).appendTo("#zxTable tbody");
  695. })
  696. }
  697. });
  698. }
  699. //获取当前的日期时间 格式“yyyy-MM-dd HH:mm:ss”
  700. function getNowFormatDate() {
  701. var date = new Date();
  702. var seperator1 = "-";
  703. var seperator2 = ":";
  704. var month = date.getMonth() + 1;
  705. var strDate = date.getDate();
  706. if (month >= 1 && month <= 9) {
  707. month = "0" + month;
  708. }
  709. if (strDate >= 0 && strDate <= 9) {
  710. strDate = "0" + strDate;
  711. }
  712. var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate +
  713. " " + date.getHours() + seperator2 + date.getMinutes() +
  714. seperator2 + date.getSeconds();
  715. return currentdate;
  716. }
  717. var iswebcloase = 1;
  718. window.onunload = function () {
  719. if (iswebcloase) {
  720. iswebcloase = 0;
  721. if (ws.readyState == ws.OPEN) {
  722. obj.Type = 'Logout';
  723. Send();
  724. ws.onclose();
  725. }
  726. }
  727. }
  728. window.onbeforeunload = function () {
  729. if (iswebcloase) {
  730. iswebcloase = 0;
  731. if (ws.readyState == ws.OPEN) {
  732. obj.Type = 'Logout';
  733. Send();
  734. ws.onclose();
  735. }
  736. }
  737. }