信阳市12345演示系统-前端代码

main.js 24KB

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