高新区管委会,以5.0标准版为基准,从双汇项目拷贝

main.js 25KB

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