Bez popisu

main.js 26KB

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