Нет описания

main.js 25KB

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