暫無描述

main.js 25KB

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