商丘12345 前端

main.js 24KB

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