安图前端代码

main.js 27KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802
  1. var ws, n = 0,
  2. timer,hidTel,hidCallID,hidActionID;
  3. var lockReconnect = false; //避免重复连接
  4. var obj = {};
  5. var directType;
  6. var sendType;
  7. var mesCont;
  8. var eorrorConnect;
  9. var cls = 0;
  10. var lasttime = new Date().getTime();
  11. var errorState;
  12. var reconnecTion;
  13. var recon;
  14. var loginOr;
  15. //创建scoket连接
  16. function createWebSocket() {
  17. try {
  18. $("#top-search li i").removeClass("active");
  19. Connect();
  20. } catch(e) {
  21. //打印日志
  22. directType="lianjie";
  23. sendType="异常错误"; //JSON.stringify(data)
  24. mesCont=e.message;
  25. debuggerLog();
  26. reconnect();
  27. }
  28. }
  29. //连接
  30. function Connect() {
  31. ws = new WebSocket("ws://" + huayi.config.socket_ip + ":" + huayi.config.socket_port);
  32. ws.onopen = function() {
  33. console.log(new Date() + " " + "建立连接");
  34. //心跳检测重置
  35. heartCheck.reset().start();
  36. cls = 0;
  37. $(".Login").addClass("active");
  38. console.log(errorState)
  39. if (errorState) {
  40. //自动签入
  41. lasttime = new Date().getTime();
  42. obj.Type = "Login";
  43. obj.AgentType = "0";
  44. Send();
  45. directType="recive";
  46. sendType="自动签入 "; //JSON.stringify(data)
  47. //mesCont=JSON.stringify(data);
  48. debuggerLog();
  49. clearInterval(timer);
  50. //loginOr=false;
  51. errorState=false;
  52. }else{
  53. //签入
  54. Send();
  55. }
  56. //自动签入
  57. //lasttime = new Date().getTime();
  58. //obj.Type = "Login";
  59. //obj.AgentType = "0";
  60. //Send(); /*2018-05-19zhangshaungnan注释*/
  61. };
  62. //接收到消息的回调方法
  63. ws.onmessage = function(evt) {
  64. //如果获取到消息,心跳检测重置
  65. //拿到任何消息都说明当前连接是正常的
  66. heartCheck.reset().start();
  67. var myDate = new Date();
  68. console.log(myDate + " receive " + evt.data);
  69. var data = JSON.parse(evt.data)[0];
  70. //打印日志
  71. directType="recive";
  72. sendType=data.Type; //JSON.stringify(data)
  73. mesCont=JSON.stringify(data);
  74. debuggerLog()
  75. if(data) {
  76. var rlt = data.Result;
  77. if(rlt == true) {
  78. clearInterval(timer);
  79. $('title').text('安图生物呼叫中心管理系统');
  80. var type = data.Type;
  81. if (eorrorConnect) {
  82. LoginBack();
  83. obj.Type = "Login";
  84. Send();
  85. eorrorConnect=false;
  86. }
  87. switch(type.toLowerCase()) {
  88. //case "heart": HeartBack(); break;//心跳
  89. case "login":
  90. LoginBack();
  91. break; //签入
  92. case "logout":
  93. LogoutBack();
  94. break; //签出
  95. case "dropcall":
  96. DropCallBack();
  97. break; //挂断
  98. case "makecall":
  99. MakeCallBack();
  100. break; //外呼
  101. case "setstate":
  102. SetState(data);
  103. break; //置忙置闲
  104. //case "saybusy": SayBusyBack(data); break;
  105. //case "sayfree": SayFreeBack(data); break;
  106. case "meeting":
  107. MeetingBack();
  108. break; //多方通话
  109. case "transfer":
  110. TransferBack();
  111. break; //转移
  112. case "hold":
  113. HoldBack();
  114. break; //保持
  115. case "retrieve":
  116. RetrieveBack();
  117. break; //接回
  118. case "incoming":
  119. IncomingBack(data);
  120. break; //来电
  121. case "subscribe":
  122. SubScribeBack();
  123. break; //监测
  124. case "subscribecancel":
  125. SubScribeCancelBack();
  126. break; //停止监测
  127. case "agentstate":
  128. AgentStateBack(data);
  129. break; //坐席状态
  130. case "linestate":
  131. LineStateBack(data);
  132. break; //线路状态
  133. case "motorsetstate":
  134. SayFreeBack();
  135. break; //班长置闲
  136. case "linestateagent":
  137. LineStateAgentBack(data);
  138. break; //线路状态通知
  139. // case "agentstateagent":
  140. // AgentStateAgentBack(data);
  141. // break; //坐席状态通知
  142. case "callid":
  143. CallIDBack(data);
  144. break; //获取callid
  145. case "recordpath":
  146. RecordPathBack(data);
  147. break; //录音返回
  148. }
  149. } else {
  150. if(rlt == false) {
  151. //$(".hwzt").text('操作失败!');
  152. //外呼失败的文字展示
  153. if (data.Type.toLowerCase() == "makecall") {
  154. switch (data.ErrorCode) {
  155. case 1: $(".hwzt").text(' 挂机,请重试!'); break;
  156. case 2: $(".hwzt").text(' FS外呼命令失败,请重试!'); break;
  157. case 3: $(".hwzt").text(' 外呼获取座席失败,请重试!'); break;
  158. case 4: $(".hwzt").text(' 座席置忙禁止座席外呼,请重试!'); break;
  159. case 5: $(".hwzt").text(' 主叫座席分机非空闲或摘机拨号,请重试!'); break;
  160. case 6: $(".hwzt").text(' 为外呼设置座席状态失败,请重试!'); break;
  161. case 7: $(".hwzt").text(' 被叫座席非空闲,请重试!'); break;
  162. case 8: $(".hwzt").text(' 执行分机呼叫失败, 未找到分机通道,请重试!'); break;
  163. case 9: $(".hwzt").text(' 执行分机呼叫失败, 无法绑定分机通道,请重试!'); break;
  164. case 10: $(".hwzt").text(' 禁止分机自呼,请重试!'); break;
  165. case 11: $(".hwzt").text(' 发送分机呼叫Esl命令失败,请重试!'); break;
  166. case 12: $(".hwzt").text(' 目标分机非空闲,请重试!'); break;
  167. case 13: $(".hwzt").text(' 主控通道非空闲,请重试!'); break;
  168. case 14: $(".hwzt").text(''); break;
  169. //case 14: $(".hwzt").text(' 校验不通过绑定本端逻辑线路失败,请重试!'); break;
  170. case 15: $(".hwzt").text(' 校验不通过本端当前线路忙,请重试!'); break;
  171. case 16: $(".hwzt").text(' 校验不通过对端线路状态忙,请重试!'); break;
  172. case 17: $(".hwzt").text(' 被叫关机,请重试!'); break;
  173. case 18: $(".hwzt").text(' 无效号码,请重试!'); break;
  174. case 19: $(".hwzt").text(' 无人接听,请重试!'); break;
  175. case 20: $(".hwzt").text(' 交换机错误(用户无法接通),请重试!'); break;
  176. case 21: $(".hwzt").text(' 话机外呼执行数据交换操作失败未找到分机通道,请重试!'); break;
  177. case 22: $(".hwzt").text(' 话机外呼执行数据交换操作失败分机通道未绑定任务,请重试!'); break;
  178. case 23: $(".hwzt").text(' 执行设备外呼任务失败无法获取对应线路,请重试!'); break;
  179. }
  180. }
  181. if(data.Type=='AcdConnectNotify'){
  182. $("#top-search li i").removeClass("active");
  183. $(".hwzt").text('Acd未连接');
  184. }
  185. } else {
  186. $(".hwzt").text(rlt);
  187. //layer.confirm(rlt, {
  188. // btn: ['确定']
  189. //});
  190. }
  191. }
  192. }
  193. };
  194. //连接关闭的回调方法
  195. ws.onclose = function(evt) {
  196. directType="recive";
  197. sendType="close"; //JSON.stringify(data)
  198. mesCont=JSON.stringify(evt);
  199. debuggerLog();
  200. alert("连接关闭");
  201. if(cls == 0) {
  202. cls = 1;
  203. //console.log("连接关闭!");
  204. $(".hwzt").text('连接关闭!');
  205. $("#top-search li i").removeClass("active");
  206. showMsgNotification('呼叫系统提示', '话务连接关闭'); //暂时关闭
  207. reconnect();
  208. }
  209. };
  210. //连接发生错误的回调方法
  211. ws.onerror = function(evt) {
  212. directType="recive";
  213. sendType="连接错误 "; //JSON.stringify(data)
  214. mesCont=JSON.stringify(evt);
  215. debuggerLog();
  216. //产生异常
  217. $(".hwzt").text('连接出现异常!');
  218. showMsgNotification('呼叫系统提示', '连接出现异常'); //暂时关闭
  219. console.log(ws);
  220. if(ws == null || ws.readyState != ws.OPEN) {
  221. console.log(new Date() + "开始重连");
  222. reconnect();
  223. }
  224. };
  225. }
  226. //重连
  227. function reconnect() {
  228. if(lockReconnect) return;
  229. lockReconnect = true;
  230. //没连接上会一直重连,设置延迟避免请求过多
  231. setTimeout(function() {
  232. directType="send";
  233. sendType="重连中 "; //JSON.stringify(data)
  234. mesCont="重连中";
  235. debuggerLog();
  236. console.log(new Date() + " " + "重连中……");
  237. createWebSocket("ws://" + huayi.config.socket_ip + ":" + huayi.config.socket_port);
  238. lockReconnect = false;
  239. }, 2000);
  240. }
  241. function debuggerLog(){
  242. $.post(huayi.config.callcenter_url + 'Log/CallOpt', {
  243. direct: directType,
  244. type: sendType,
  245. cont: mesCont,
  246. "token": $.cookie("token")
  247. }, function(result) {
  248. result = $.parseJSON(result);
  249. if(result.state.toLowerCase() == "warning") {
  250. //layer.msg("创建工单成功");
  251. }
  252. })
  253. }
  254. //异常重连
  255. function errorFun(){
  256. clearInterval(timer);
  257. var errorNum=0
  258. timer = setInterval(function() {
  259. errorNum++;
  260. if (errorNum>2) {
  261. //$("#top-search li i").removeClass("active");
  262. $(".hwzt").text('连接异常!');
  263. }else{
  264. LogoutBack();
  265. }
  266. reconnect();
  267. $(".hwzt").text('连接异常!');
  268. }, 15000);
  269. }
  270. noLine();
  271. clearInterval(recon);
  272. recon = setInterval(function () {
  273. if(loginOr){
  274. noLine();
  275. setTimeout(function () {
  276. lineState();
  277. }, 2000);
  278. }
  279. }, 1000*10);
  280. function lineState(){
  281. if (reconnecTion) {
  282. reconnecTion=false;
  283. }else{
  284. directType="send";
  285. sendType="断网 "; //JSON.stringify(data)
  286. mesCont="断网";
  287. debuggerLog();
  288. errorState=true;
  289. errorFun();
  290. var numEorr=0;
  291. numEorr++;
  292. if (numEorr>2) {
  293. $("#top-search li i").removeClass("active");
  294. }
  295. LogoutBack();
  296. $(".hwzt").text('网络异常!');
  297. }
  298. }
  299. function noLine(){
  300. $.ajax({
  301. type: "get",
  302. url: huayi.config.callcenter_url + 'UserAccount/GetNowUser',
  303. async: true,
  304. dataType: 'json',
  305. data: {
  306. "token": $.cookie("token")
  307. },
  308. success: function(data) {
  309. reconnecTion = data.data.user.F_UserCode;
  310. }
  311. });
  312. }
  313. //发送
  314. function Send() {
  315. if(ws.readyState != ws.OPEN) {
  316. if(loginOr){
  317. errorState=true;
  318. LogoutBack();
  319. errorFun();
  320. directType="send";
  321. sendType=ws.readyState; //JSON.stringify(data)
  322. mesCont="异常了";
  323. debuggerLog();
  324. $(".hwzt").text('连接异常!');
  325. reconnect();
  326. }else{
  327. errorState=false;
  328. LogoutBack();
  329. errorFun();
  330. directType="send";
  331. sendType=ws.readyState; //JSON.stringify(data)
  332. mesCont="异常了";
  333. debuggerLog();
  334. $(".hwzt").text('连接异常!');
  335. reconnect();
  336. }
  337. }
  338. if(ws.readyState == ws.OPEN) {
  339. if (obj.Type) {
  340. directType="send";
  341. sendType=obj.Type;
  342. mesCont=JSON.stringify(obj);
  343. debuggerLog()
  344. }else{
  345. directType="send";
  346. sendType="建立连接";
  347. mesCont=JSON.stringify(obj);
  348. debuggerLog()
  349. }
  350. console.log(new Date() + " send " + JSON.stringify(obj));
  351. ws.send(JSON.stringify(obj));
  352. }
  353. }
  354. //心跳检测
  355. var heartCheck = {
  356. timeout: 1000, //25秒
  357. timeoutObj: null,
  358. serverTimeoutObj: null,
  359. reset: function() {
  360. clearTimeout(this.timeoutObj);
  361. clearTimeout(this.serverTimeoutObj);
  362. return this;
  363. },
  364. start: function() {
  365. var self = this;
  366. this.timeoutObj = setTimeout(function() {
  367. //这里发送一个心跳,后端收到后,返回一个心跳消息,
  368. //onmessage拿到返回的心跳就说明连接正常
  369. obj.Type = "Heart";
  370. Send();
  371. self.serverTimeoutObj = setTimeout(function() { //如果超过一定时间还没重置,说明后端主动断开了
  372. ws.close(); //如果onclose会执行reconnect,我们执行ws.close()就行了.如果直接执行reconnect 会触发onclose导致重连两次
  373. //同步签出状态
  374. $("#top-search li i").removeClass("active");
  375. $(".Login").addClass("active");
  376. $(".zxzt").removeClass("bl").addClass("br");
  377. $(".fwzt").removeClass("bl").addClass("br");
  378. $(".hwzt").text('');
  379. //打印日志
  380. directType="heart";
  381. sendType="心跳"; //JSON.stringify(data)
  382. mesCont="未收到";
  383. debuggerLog();
  384. }, self.timeout)
  385. }, this.timeout)
  386. }
  387. }
  388. //签入
  389. function LoginBack() {
  390. loginOr=true;
  391. $("#top-search li i").removeClass("active");
  392. $(".Logout").addClass("active");
  393. $(".SayBusy").addClass("active");
  394. $(".MakeCall").addClass("active");
  395. $(".zxzt").removeClass("br").addClass("bl");
  396. $(".fwzt").removeClass("br").addClass("bl");
  397. $(".hwzt").text('空闲');
  398. }
  399. //签出
  400. function LogoutBack() {
  401. loginOr=false;
  402. $("#top-search li i").removeClass("active");
  403. $(".Login").addClass("active");
  404. $(".zxzt").removeClass("bl").addClass("br");
  405. $(".fwzt").removeClass("bl").addClass("br");
  406. $(".hwzt").text('');
  407. }
  408. //来电
  409. function IncomingBack(data) {
  410. if(data.CallID!=0){
  411. var p = '<a href="javascript:;" class="active J_menuTab" data-id="./callScreen/callScreen.html?tel=' + data.Number + '&CallID=' + data.CallID + '">来电弹屏' + data.Number + ' <i class="fa fa-times-circle"></i></a>';
  412. $(".J_menuTab").removeClass("active");
  413. var nif = '<iframe class="J_iframe J_iframeNew" name="iframe'+ data.CallID +'" width="100%" height="100%" src="./callScreen/callScreen.html?Number=' + data.Number + '&CallID=' + data.CallID + '&ActionID=' + data.ActionID + '" frameborder="0" data-id="./callScreen/callScreen.html?tel=' + data.Number + '&CallID=' + data.CallID + '" seamless></iframe>';
  414. $(".J_mainContent").find("iframe.J_iframe").hide().parents(".J_mainContent").append(nif);
  415. $(".J_menuTabs .page-tabs-content").append(p);
  416. hidTel=data.Number;
  417. hidCallID=data.CallID;
  418. hidActionID=data.ActionID;
  419. }else{
  420. var timestamp = Date.parse(new Date());
  421. var p = '<a href="javascript:;" class="active J_menuTab" data-id="./callScreen/callScreen.html?tel=' + data.Number + '&CallID='+timestamp+'">来电弹屏' + data.Number + ' <i class="fa fa-times-circle"></i></a>';
  422. $(".J_menuTab").removeClass("active");
  423. var nif = '<iframe class="J_iframe J_iframeNew" name="iframe'+timestamp+'" width="100%" height="100%" src="./callScreen/callScreen.html?Number=' + data.Number + '&CallID='+timestamp+'" frameborder="0" data-id="./callScreen/callScreen.html?tel=' + data.Number + '&CallID='+timestamp+'" seamless></iframe>';
  424. $(".J_mainContent").find("iframe.J_iframe").hide().parents(".J_mainContent").append(nif);
  425. $(".J_menuTabs .page-tabs-content").append(p);
  426. hidTel=data.Number;
  427. hidCallID=timestamp;
  428. }
  429. }
  430. //***************************************************
  431. function CallIDBack(data) {
  432. //$(".hidCallID").val(data.CurrID);
  433. }
  434. //挂断
  435. function DropCallBack() {
  436. $("#top-search li i").removeClass("active");
  437. $(".Logout").addClass("active");
  438. $(".SayBusy").addClass("active");
  439. $(".MakeCall").addClass("active");
  440. var obj = $("iframe:visible")
  441. // if (obj.attr("data-id") == './callScreen/callScreen.html?tel=' + hidTel + '&CallID=' + hidCallID + '') {
  442. // window.frames[obj.attr("name")].$(".td-call").hide();
  443. // window.frames['iframe'+ hidCallID +''].$(".td-call").hide();
  444. // }
  445. if(window.frames['iframe'+ hidCallID +'']){
  446. window.frames['iframe'+ hidCallID +''].$(".td-call").hide();
  447. }
  448. }
  449. //线路状态通知
  450. function LineStateAgentBack(data) {
  451. var objiframe = $("iframe:visible")
  452. //0分机不可用,1空闲,2摘机等待拨号,3正在拨号,4呼出振铃,5来电振铃,6通话中,7播放忙音中,8移除IP分机,9通话保持中
  453. if(data.State == '0') {
  454. $(".hwzt").text('分机不可用'); //左下角状态显示
  455. //$(".fwzt").removeClass("br").removeClass("bl");
  456. $(".fwzt").removeClass("bl").addClass("br");//20180509 by fanlongfei 增加话机状态灯
  457. $(".zxzt").removeClass("bl").addClass("br");//20180509 by fanlongfei 增加坐席状态灯
  458. }
  459. if(data.State == '1') {
  460. // var isml=0;
  461. if($("#isml").val()==1){
  462. // isml=1;
  463. $(".hwzt").text('置忙'); //左下角状态显示
  464. $(".zxzt").removeClass("bl").addClass("br");
  465. }
  466. else{
  467. $(".hwzt").text('空闲'); //左下角状态显示
  468. $(".zxzt").removeClass("br").addClass("bl");
  469. }
  470. $(".fwzt").removeClass("br").addClass("bl");
  471. // $(".zxzt").removeClass("br").addClass("bl");//20180509 by fanlongfei 增加坐席状态灯
  472. if(window.frames['iframe'+ hidCallID +'']){
  473. window.frames['iframe'+ hidCallID +''].clearInter();
  474. }
  475. //2019-03-26 clq 作废挂机
  476. //if (hidTel && hidCallID) {
  477. // $.post(huayi.config.callcenter_url + 'CallInScreen/UpdateGJ', {
  478. // callid: hidTel,
  479. // "token": $.cookie("token")
  480. // }, function (result) {
  481. // result = JSON.parse(result);
  482. // if (result.state.toLowerCase() == "success") { }
  483. // })
  484. // }
  485. $("#top-search li i").removeClass("active");
  486. $(".Logout").addClass("active");
  487. if($("#isml").val()==0){
  488. $(".SayBusy").addClass("active");
  489. }
  490. else{
  491. $(".SayFree").addClass("active");
  492. }
  493. $(".MakeCall").addClass("active");
  494. if(window.frames['iframe'+ hidCallID +'']){
  495. window.frames['iframe'+ hidCallID +''].$(".td-call").hide();
  496. }
  497. }
  498. if(data.State == '2') {
  499. $(".hwzt").text('摘机等待拨号'); //左下角状态显示
  500. }
  501. if(data.State == '3') {
  502. $(".hwzt").text('正在拨号'); //左下角状态显示
  503. }
  504. if(data.State == '4') {
  505. $(".hwzt").text('呼出振铃'); //左下角状态显示
  506. }
  507. if(data.State == '5') {
  508. $(".hwzt").text('来电振铃'); //左下角状态显示
  509. //$(".fwzt").removeClass("bl").addClass("br");
  510. $(".fwzt").removeClass("br").addClass("bl");//20180509 by fanlongfei 增加话机状态灯
  511. $(".zxzt").removeClass("bl").addClass("br");//20180509 by fanlongfei 增加坐席状态灯
  512. if (hidTel && hidCallID) {
  513. $.post(huayi.config.callcenter_url + 'CallInScreen/UpdateZL', {
  514. callid: hidCallID,
  515. "token": $.cookie("token")
  516. }, function (result) {
  517. result = JSON.parse(result);
  518. if (result.state.toLowerCase() == "success") { }
  519. })
  520. }
  521. }
  522. if(data.State == '6') {
  523. $(".hwzt").text('通话中'); //左下角状态显示
  524. $(".fwzt").removeClass("bl").addClass("br");
  525. $(".zxzt").removeClass("bl").addClass("br");//20180509 by fanlongfei 增加坐席状态灯
  526. if(hidTel && hidCallID) {
  527. $.post(huayi.config.callcenter_url + 'CallInScreen/UpdateZJ', {
  528. callid: hidCallID,
  529. "token": $.cookie("token")
  530. }, function(result) {
  531. result = JSON.parse(result);
  532. if(result.state.toLowerCase() == "success") {}
  533. })
  534. }
  535. $("#top-search li i").removeClass("active");
  536. $(".DropCall").addClass("active");
  537. $(".Hold").addClass("active");
  538. $(".Transfer").addClass("active");
  539. $(".Meeting").addClass("active");
  540. var aaa=data.CallDirection;
  541. if(data.CallDirection=="in"){
  542. // if (objiframe.attr("data-id") == './callScreen/callScreen.html?tel=' + hidTel + '&CallID=' + hidCallID + '') {
  543. setTimeout(window.frames['iframe'+ hidCallID +''].calling(),500);/*2018-05-19 zhangshuangnan 修改 ps: 因软电话设置为 自动应答 通话时间不计时问题*/
  544. // }
  545. }
  546. }
  547. if(data.State == '7') {
  548. $(".hwzt").text('播放忙音中'); //左下角状态显示
  549. }
  550. if(data.State == '8') {
  551. $(".hwzt").text('移除IP分机'); //左下角状态显示
  552. }
  553. if(data.State == '9') {
  554. $(".hwzt").text('通话保持中'); //左下角状态显示
  555. }
  556. }
  557. function toDub(i) {
  558. return i < 10 ? "0" + i : "" + i;
  559. }
  560. //外呼
  561. function MakeCallBack() {
  562. $("#top-search li i").removeClass("active");
  563. $(".DropCall").addClass("active");
  564. // alert('1');
  565. // window.frames[obj.attr("name")].calling();
  566. }
  567. //置忙置闲
  568. function SetState(obj) {
  569. if(obj.State == '5') {
  570. $(".SayBusy").removeClass("active");
  571. $(".SayFree").addClass("active");
  572. $(".zxzt").removeClass("bl").addClass("br");
  573. $(".hwzt").text('置忙');
  574. $("#isml").val(1)
  575. }
  576. if(obj.State == '2') {
  577. $(".SayBusy").addClass("active");
  578. $(".SayFree").removeClass("active");
  579. $(".zxzt").removeClass("br").addClass("bl");
  580. $(".hwzt").text('空闲');
  581. $("#isml").val(0)
  582. }
  583. }
  584. //置忙
  585. function SayBusyBack() {
  586. $(".SayBusy").removeClass("active");
  587. $(".SayFree").addClass("active");
  588. $("#isml").val(1)
  589. }
  590. //坐席班长置闲
  591. function SayFreeBack() {
  592. $(".SayBusy").addClass("active");
  593. $(".SayFree").removeClass("active");
  594. $(".zxzt").removeClass("br").addClass("bl"); // 2018/05/09 by fanlongfei 增加坐席状态指示
  595. $(".hwzt").text('空闲');// 2018/05/09 by fanlongfei 增加坐席状态指示
  596. $("#isml").val(0)
  597. }
  598. //多方通话
  599. function MeetingBack() {
  600. }
  601. //转移
  602. function TransferBack() {
  603. $("#top-search li i").removeClass("active");
  604. $(".Logout").addClass("active");
  605. $(".SayBusy").addClass("active");
  606. $(".MakeCall").addClass("active");
  607. }
  608. //保持
  609. function HoldBack() {
  610. $(".Hold").removeClass("active");
  611. $(".Retrieve").addClass("active");
  612. }
  613. //接回
  614. function RetrieveBack() {
  615. $(".Hold").addClass("active");
  616. $(".Retrieve").removeClass("active");
  617. }
  618. //监测
  619. function SubScribeBack() {
  620. $('#content-main .J_iframeNew').each(function(i,n){
  621. if($(this).attr('data-id') == "./TelCall/SeatMonitor.html"){
  622. window.frames[$(this).attr("name")].Start();
  623. }
  624. })/*2018-05-24 zhangshuangnan 修改 解决通话中时 坐席监控状态不改变的问题*/
  625. }
  626. //取消监测
  627. function SubScribeCancelBack() {
  628. // var obj = $("iframe:visible")
  629. // if(obj.attr("data-id") == "./TelCall/SeatMonitor.html") {
  630. // window.frames[obj.attr("name")].();
  631. // }
  632. $('#content-main .J_iframeNew').each(function(i,n){
  633. if($(this).attr('data-id') == "./TelCall/SeatMonitor.html"){
  634. window.frames[$(this).attr("name")].Stop();
  635. }
  636. })/*2018-05-24 zhangshuangnan 修改 解决通话中时 坐席监控状态不改变的问题*/
  637. }
  638. //班长监测返回状态
  639. //坐席状态
  640. function AgentStateBack(data) {
  641. $('#content-main .J_iframeNew').each(function(i,n){
  642. if($(this).attr('data-id') == "./TelCall/SeatMonitor.html"){
  643. window.frames[$(this).attr("name")].UpdateAgentState(data.AgentID, data.State);
  644. }
  645. })/*2018-05-24 zhangshuangnan 修改 解决通话中时 坐席监控状态不改变的问题*/
  646. }
  647. //线路状态
  648. function LineStateBack(data) {
  649. $('#content-main .J_iframeNew').each(function(i,n){
  650. if($(this).attr('data-id') == "./TelCall/SeatMonitor.html"){
  651. window.frames[$(this).attr("name")].UpdateLineState(data.AgentID, data.State);
  652. }
  653. })/*2018-05-24 zhangshuangnan 修改 解决通话中时 坐席监控状态不改变的问题*/
  654. }
  655. //录音返回
  656. function RecordPathBack(data) {
  657. $(".hidCallID").val(data.CallID);
  658. //if ($(".hidTel").val() && $(".hidCallID").val()) {
  659. // $.post(huayi.config.callcenter_url + 'CallInScreen/UpdateLY', { callid: $(".hidCallID").val(),path:data.RecPath, "token": $.cookie("token") }, function (result) {
  660. // result = JSON.parse(result);
  661. // if (result.state.toLowerCase() == "success") {
  662. // }
  663. // })
  664. //}
  665. if(hidTel) {
  666. $.post(huayi.config.callcenter_url + 'CallInScreen/UpdateLY', {
  667. callid: data.CallID,
  668. path: data.RecPath,
  669. "token": $.cookie("token")
  670. }, function(result) {
  671. result = JSON.parse(result);
  672. if(result.state.toLowerCase() == "success") {}
  673. })
  674. }
  675. }
  676. //获取当前的日期时间 格式“yyyy-MM-dd HH:mm:ss”
  677. function getNowFormatDate() {
  678. var date = new Date();
  679. var seperator1 = "-";
  680. var seperator2 = ":";
  681. var month = date.getMonth() + 1;
  682. var strDate = date.getDate();
  683. if(month >= 1 && month <= 9) {
  684. month = "0" + month;
  685. }
  686. if(strDate >= 0 && strDate <= 9) {
  687. strDate = "0" + strDate;
  688. }
  689. var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate +
  690. " " + date.getHours() + seperator2 + date.getMinutes() +
  691. seperator2 + date.getSeconds();
  692. return currentdate;
  693. }
  694. //桌面弹出提示
  695. function showMsgNotification(title, msg) {
  696. // var Notification = window.Notification || window.mozNotification || window.webkitNotification;
  697. //
  698. // if(Notification) {//支持桌面通知
  699. // if(Notification.permission == "granted") {//已经允许通知
  700. // var instance = new Notification(title, {
  701. // body: msg,
  702. // tag:msg,
  703. // icon: "img/tips.png",
  704. // requireInteraction:true,
  705. // renotify:true
  706. //
  707. // });
  708. //
  709. // instance.onclick = function() {
  710. //// $('body').css({'background': 'red'});
  711. //// console.log('onclick');
  712. //// instance.close();
  713. // };
  714. // instance.onerror = function() {
  715. // console.log('onerror');
  716. // };
  717. // instance.onshow = function() {
  718. // console.log('onshow');
  719. // };
  720. // instance.onclose = function() {
  721. // console.log('onclose');
  722. // };
  723. // }else {//第一次询问或已经禁止通知(如果用户之前已经禁止显示通知,那么浏览器不会再次询问用户的意见,Notification.requestPermission()方法无效)
  724. // Notification.requestPermission(function(status) {
  725. // if (status === "granted") {//用户允许
  726. // var instance = new Notification(title, {
  727. // body: msg,
  728. // tag:msg,
  729. // icon: "img/tips.png",
  730. // requireInteraction:true,
  731. // renotify:true
  732. // });
  733. //
  734. // instance.onclick = function() {
  735. // // Something to do
  736. // };
  737. // instance.onerror = function() {
  738. // // Something to do
  739. // };
  740. // instance.onshow = function() {
  741. // // Something to do
  742. // };
  743. // instance.onclose = function() {
  744. // // Something to do
  745. // };
  746. // }else {//用户禁止
  747. // return false
  748. // }
  749. // });
  750. // }
  751. // }else {//不支持(IE等)
  752. var index = 0;
  753. clearInterval(timer);
  754. timer = setInterval(function() {
  755. if(index%2) {
  756. $('title').text('【 】'+ title);//这里是中文全角空格,其他不行
  757. }else {
  758. $('title').text('【'+ msg+'】'+ title);
  759. }
  760. index++;
  761. // if(index > 20) {
  762. // clearInterval(timer);
  763. // }
  764. }, 500);
  765. // }
  766. }