民权县12345_前端

main.js 22KB

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