Нет описания

main.js 26KB

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