Нет описания

main.js 25KB

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