barscreen.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  6. <link
  7. rel="shortcut icon"
  8. href="https://www.baidu.com/favicon.ico"
  9. type="image/x-icon"
  10. />
  11. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  12. <title>条屏</title>
  13. </head>
  14. <body>
  15. <div class="container">
  16. <div class="title">
  17. <div class="title-text" id="title"></div>
  18. </div>
  19. <div class="border1"></div>
  20. <div class="content">
  21. <div class="con-info">
  22. <div class="con-info-index" id="index"></div>
  23. <div class="con-info-name" id="conInfoName"></div>
  24. <div class="con-info-state" id="conInfoState">
  25. <div class="con-info-state-icon">
  26. <img id="icon" src="./image/frees.png" />
  27. </div>
  28. <div class="con-info-state-text" id="conStateText"></div>
  29. </div>
  30. </div>
  31. <div class="con-state" id="conState">
  32. <div class="con-state-icon">
  33. <img id="icon1" src="./image/frees.png" />
  34. </div>
  35. <div class="con-state-text" id="conStateText1"></div>
  36. </div>
  37. <div class=""></div>
  38. <div class="con-now" id="conNowBox">
  39. 正在办理:<span id="conNow"></span>
  40. </div>
  41. <div class="con-wait" id="conWaitBox">
  42. 当前等待:<span id="conWait"></span>
  43. </div>
  44. </div>
  45. </div>
  46. </body>
  47. </html>
  48. <script>
  49. var wsApiUrl = "wss://pdjh.shizhi.tv/websocket/gw/";
  50. // *** 接口地址 ***
  51. var ettpApiUrl = "https://pdjh.shizhi.tv/machine/init/old/ettp";
  52. // var ettpApiUrl = "http://1.82.219.239:8092/machine/init/old/ettp"
  53. var stateApiUrl = "https://pdjh.shizhi.tv/machine/init/old/split/getRedis";
  54. // var stateApiUrl = "http://1.82.219.239:8092/machine/init/old/split/getRedis"
  55. // *** 参数信息 ***
  56. var url = window.location.search.slice(1).split("&");
  57. var tpname = url[0].slice(url[0].lastIndexOf("=") + 1);
  58. var sljgdm = url[1].slice(url[1].lastIndexOf("=") + 1);
  59. // 获取数据
  60. function getDatas() {
  61. if ("WebSocket" in window) {
  62. console.log("您的浏览器支持 WebSocket!");
  63. websocket();
  64. } else {
  65. console.log("您的浏览器不支持 WebSocket!");
  66. getEttpInit();
  67. }
  68. }
  69. // websocket
  70. function websocket() {
  71. // ws参数
  72. var msg = {
  73. userType: "ET条屏",
  74. machineName: tpname,
  75. sljgdm: sljgdm,
  76. };
  77. var wsUrl = wsApiUrl + "{" + JSON.stringify(msg) + "}";
  78. var connection = null;
  79. // 心跳倒计时
  80. var heartTimer = null;
  81. // 重连倒计时
  82. var reConnectTimer = null;
  83. function connectWS() {
  84. connection = new WebSocket(wsUrl);
  85. // ws 连接成功
  86. connection.onopen = wsOpen;
  87. function wsOpen(event) {
  88. heart();
  89. }
  90. connection.onclose = wsClose;
  91. function wsClose() {
  92. reConnect();
  93. console.log("%c" + "连接关闭,正在重连...", "color:" + "#fe4c40");
  94. }
  95. // 接收消息
  96. connection.onmessage = wsMessage;
  97. function wsMessage(event) {
  98. var response = JSON.parse(event.data);
  99. switch (response.code) {
  100. default:
  101. return;
  102. // 初始化
  103. case "ettpInit":
  104. updateDom(response.tpxxVO);
  105. break;
  106. //取号完成
  107. case "qhwc":
  108. for (var i = 0; i < response.tpList.length; i++) {
  109. if (response.tpList[i].tpbh == tpname) {
  110. var list = response.tpList[i].tpxxVO;
  111. updateDom(list);
  112. break;
  113. }
  114. }
  115. break;
  116. // 综合完成
  117. case "zhwc":
  118. for (var i = 0; i < response.tpList.length; i++) {
  119. if (response.tpList[i].tpbh == tpname) {
  120. var list = response.tpList[i].tpxxVO;
  121. updateDom(list);
  122. break;
  123. }
  124. }
  125. break;
  126. // 叫号完成
  127. case "jhwc":
  128. for (var i = 0; i < response.tpList.length; i++) {
  129. if (response.tpList[i].tpbh == tpname) {
  130. var list = response.tpList[i].tpxxVO;
  131. updateDom(list);
  132. break;
  133. }
  134. }
  135. break;
  136. // 心跳
  137. case "heart":
  138. clearTimeout(reConnectTimer);
  139. heartTimer = setTimeout(function () {
  140. heart();
  141. }, 10 * 1000);
  142. break;
  143. }
  144. }
  145. }
  146. // 心跳
  147. function heart() {
  148. clearTimeout(heartTimer);
  149. if (connection != null) {
  150. var heartText = {
  151. code: "heart",
  152. text: "这只是一个心跳",
  153. };
  154. connection.send(JSON.stringify(heartText));
  155. }
  156. reConnectTimer = setTimeout(function () {
  157. reConnect();
  158. }, 30 * 1000);
  159. }
  160. // 重连
  161. function reConnect() {
  162. clearTimeout(reConnectTimer);
  163. if (connection) {
  164. connection.close();
  165. connection = null;
  166. }
  167. connection = null;
  168. reConnectTimer = setTimeout(function () {
  169. connectWS();
  170. }, 3 * 1000);
  171. }
  172. connectWS();
  173. }
  174. // 条屏初始化信息
  175. function getEttpInit() {
  176. // *** 创建xhr的对象 ***
  177. var xhr = new XMLHttpRequest();
  178. xhr.open("post", ettpApiUrl);
  179. xhr.setRequestHeader("Content-type", "application/json;charset=UTF-8");
  180. // *** 调用send函数 ***
  181. var ettpForm = JSON.stringify({
  182. machineName: tpname,
  183. sljgdm: sljgdm,
  184. userType: "ET条屏",
  185. });
  186. xhr.send(ettpForm);
  187. // *** 监听事件 ***
  188. xhr.onreadystatechange = function () {
  189. if (xhr.readyState == 4 && xhr.status === 200) {
  190. var ettpRes = JSON.parse(xhr.responseText) || {};
  191. var ettpResInfos = ettpRes.tpxxVO || {};
  192. // *** 修改内容 ***
  193. updateDom(ettpResInfos);
  194. } else {
  195. }
  196. };
  197. setTimeout(function () {
  198. getState();
  199. }, 800);
  200. }
  201. // 条屏轮询
  202. function getState() {
  203. // *** 创建xhr的对象 ***
  204. var xhr = new XMLHttpRequest();
  205. xhr.open("get", stateApiUrl + "?machineName=" + tpname);
  206. // *** 调用send函数 ***
  207. xhr.send();
  208. // *** 监听事件 ***
  209. xhr.onreadystatechange = function () {
  210. if (xhr.readyState == 4 && xhr.status === 200) {
  211. var screenarr = JSON.parse(xhr.responseText) || {};
  212. var arr = screenarr.code == "0" ? screenarr.msg : null;
  213. if (arr != null) {
  214. var stateRes = JSON.parse(arr).tpxxVO || {};
  215. // *** 修改内容 ***
  216. updateDom(stateRes);
  217. }
  218. } else {
  219. }
  220. };
  221. setTimeout(function () {
  222. getState();
  223. }, 800);
  224. }
  225. // 更新dom
  226. function updateDom(infos) {
  227. // 标题
  228. setEleCon("title", "innerHTML", infos.dttsy || "");
  229. // 窗口号码
  230. setEleCon("index", "innerHTML", infos.ckhm || "");
  231. if (
  232. infos.slyw[0] != "征纳互动" &&
  233. infos.slyw[0] != "电子税务局" &&
  234. infos.slyw[0] != "综合服务"
  235. ) {
  236. setStyle("conInfoState", "display", "");
  237. setStyle("conState", "display", "none");
  238. setStyle("conNowBox", "display", "");
  239. setStyle("conWaitBox", "display", "");
  240. setStyle("conInfoName", "width", "750px");
  241. setStyle("conNowBox", "fontSize", "");
  242. setStyle("conNowBox", "marginLeft", "");
  243. // 业务名称
  244. if (infos.slyw) {
  245. setEleCon("conInfoName", "innerHTML", infos.slyw.join(" "));
  246. if (infos.slyw.join(" ").length > 5) {
  247. setStyle("conInfoName", "lineHeight", "150px");
  248. setStyle("conInfoName", "fontSize", "120px");
  249. } else {
  250. setStyle("conInfoName", "lineHeight", "300px");
  251. setStyle("conInfoName", "fontSize", "150px");
  252. }
  253. }
  254. // 修改图标及状态
  255. var srcs = {
  256. kx: "./image/frees.png",
  257. zt: "./image/wites.png",
  258. hj: "./image/xlb.png",
  259. };
  260. var textColors = {
  261. kx: "#00FFFF",
  262. zt: "#FFF700",
  263. hj: "#00FFFF",
  264. };
  265. var ckzt = infos.ckzt || "";
  266. setEleCon(
  267. "icon",
  268. "src",
  269. ckzt == "空闲" ? srcs.kx : ckzt === "暂停服务" ? srcs.zt : srcs.hj
  270. );
  271. setStyle(
  272. "conStateText",
  273. "color",
  274. ckzt === "空闲"
  275. ? textColors.kx
  276. : ckzt === "暂停服务"
  277. ? textColors.zt
  278. : textColors.kx
  279. );
  280. setEleCon("conStateText", "innerHTML", ckzt === "空闲" ? "工作中" : ckzt);
  281. // 正在办理
  282. setEleCon(
  283. "conNow",
  284. "innerHTML",
  285. ckzt != "空闲" && ckzt != "暂停服务" ? ckzt : "暂无"
  286. );
  287. // 等待人数
  288. setEleCon(
  289. "conWait",
  290. "innerHTML",
  291. ckzt != "暂停服务" && infos.ddrs != "0"
  292. ? (infos.ddrs || "0") + "人"
  293. : "暂无"
  294. );
  295. } else {
  296. setStyle("conInfoState", "display", "none");
  297. setStyle("conNowBox", "display", "none");
  298. setStyle("conWaitBox", "display", "none");
  299. if (infos.slyw[0] === "征纳互动" || infos.slyw[0] == "电子税务局") {
  300. setStyle("conInfoName", "width", "1555px");
  301. // 业务名称
  302. if (infos.slyw) {
  303. setStyle("conState", "display", "block");
  304. setEleCon("conInfoName", "innerHTML", infos.slyw.join(" "));
  305. setEleCon("conStateText1", "innerHTML", "工作中");
  306. setEleCon("icon1", "src", "./image/frees.png");
  307. setStyle("conInfoName", "lineHeight", "300px");
  308. setStyle("conInfoName", "fontSize", "140px");
  309. }
  310. } else if (infos.slyw[0] === "综合服务") {
  311. setStyle("conInfoName", "width", "1555px");
  312. // 业务名称
  313. if (infos.slyw) {
  314. setStyle("conState", "display", "block");
  315. setEleCon("conInfoName", "innerHTML", "潮汐窗口");
  316. setEleCon("conStateText1", "innerHTML", "暂停服务");
  317. setStyle("conStateText1", "color", "#FFF700");
  318. setEleCon("icon1", "src", "./image/wites.png");
  319. setStyle("conInfoName", "lineHeight", "300px");
  320. setStyle("conInfoName", "fontSize", "140px");
  321. }
  322. }
  323. // else if (infos.slyw[0] === "综合服务") {
  324. // setStyle("conInfoName", "width", "750px");
  325. // // 业务名称
  326. // if (infos.slyw) {
  327. // setStyle("conState", "display", "none");
  328. // setEleCon("conInfoName", "innerHTML", infos.slyw.join(" "));
  329. // setStyle("conInfoName", "lineHeight", "300px");
  330. // if (infos.slyw.join(" ").length > 5) {
  331. // setStyle("conInfoName", "fontSize", "120px");
  332. // } else {
  333. // setStyle("conInfoName", "fontSize", "150px");
  334. // }
  335. // setStyle("conInfoState", "display", "");
  336. // // 修改图标及状态
  337. // var srcs = {
  338. // kx: "./image/frees.png",
  339. // zt: "./image/wites.png",
  340. // hj: "./image/xlb.png",
  341. // };
  342. // var textColors = {
  343. // kx: "#00FFFF",
  344. // zt: "#FFF700",
  345. // hj: "#00FFFF",
  346. // };
  347. // var ckzt = infos.ckzt || "";
  348. // setEleCon("icon", "src", srcs.zt);
  349. // setStyle("conStateText", "color", textColors.zt);
  350. // setEleCon("conStateText", "innerHTML", "暂停服务");
  351. // setStyle("conNowBox", "display", "");
  352. // setEleCon("conNowBox", "innerHTML", "潮汐窗口");
  353. // setStyle("conNowBox", "fontSize", "180px");
  354. // setStyle("conNowBox", "marginLeft", "110px");
  355. // }
  356. // }
  357. }
  358. }
  359. // 修改元素内容
  360. function setEleCon(id, label, value) {
  361. var ele = document.getElementById(id);
  362. ele[label] = value;
  363. }
  364. // 设置样式
  365. function setStyle(id, label, value) {
  366. var ele = document.getElementById(id);
  367. ele.style[label] = value;
  368. }
  369. // 获取元素内容
  370. function getEleCon(id) {
  371. var ele = document.getElementById(id);
  372. return ele.innerHTML;
  373. }
  374. // 获取数据
  375. getDatas();
  376. </script>
  377. <style>
  378. html,
  379. body {
  380. margin: 0;
  381. padding: 0;
  382. }
  383. .container {
  384. width: 1920px;
  385. height: 1080px;
  386. }
  387. .title {
  388. padding: 20px 0;
  389. width: 100%;
  390. height: 100px;
  391. line-height: 100px;
  392. font-size: 70px;
  393. color: #ffffff;
  394. text-align: center;
  395. font-weight: 500;
  396. font-family: PingFang SC, PingFang SC-Medium;
  397. background-image: url(./image/bar.png);
  398. }
  399. .border1 {
  400. width: 100%;
  401. height: 10px;
  402. background: #00ffff;
  403. }
  404. .content {
  405. position: relative;
  406. width: 100%;
  407. height: 930px;
  408. background-image: url(./image/bg.png);
  409. background-size: 100% 100%;
  410. }
  411. .con-info {
  412. padding-top: 50px;
  413. width: 100%;
  414. height: 300px;
  415. }
  416. .con-info-index {
  417. float: left;
  418. margin: 25px;
  419. width: 250px;
  420. height: 250px;
  421. text-align: center;
  422. line-height: 250px;
  423. font-size: 150px;
  424. font-family: DIN, DIN-Regular;
  425. color: #ffffff;
  426. border-radius: 50%;
  427. background: #ff0000;
  428. }
  429. .con-info-name {
  430. float: left;
  431. margin-right: 65px;
  432. width: 750px;
  433. height: 300px;
  434. line-height: 300px;
  435. font-size: 120px;
  436. color: #ffffff;
  437. font-family: PingFang SC, PingFang SC-Regular;
  438. font-weight: 400;
  439. text-align: left;
  440. }
  441. .con-info-state {
  442. float: left;
  443. width: 800px;
  444. height: 300px;
  445. }
  446. .con-info-state-icon {
  447. float: left;
  448. padding: 75px 0 55px 0;
  449. width: 170px;
  450. height: 170px;
  451. }
  452. .con-info-state-icon > img {
  453. width: 100%;
  454. height: 100%;
  455. }
  456. .con-info-state-text {
  457. float: left;
  458. width: 630px;
  459. height: 300px;
  460. line-height: 300px;
  461. text-align: center;
  462. font-size: 150px;
  463. font-weight: 400;
  464. }
  465. .con-state {
  466. display: none;
  467. margin-top: 70px;
  468. margin-left: 650px;
  469. width: 1000px;
  470. height: 300px;
  471. }
  472. .con-state-icon {
  473. float: left;
  474. padding: 80px 0 60px 0;
  475. width: 170px;
  476. height: 170px;
  477. }
  478. .con-state-icon > img {
  479. width: 100%;
  480. height: 100%;
  481. }
  482. .con-state-text {
  483. margin-left: 10px;
  484. float: left;
  485. width: 660px;
  486. height: 300px;
  487. line-height: 300px;
  488. color: #00ffff;
  489. text-align: left;
  490. font-size: 165px;
  491. font-weight: 400;
  492. }
  493. .con-now {
  494. padding-left: 500px;
  495. margin-top: 120px;
  496. height: 200px;
  497. font-size: 130px;
  498. line-height: 200px;
  499. font-family: Alibaba PuHuiTi, Alibaba PuHuiTi-Regular;
  500. font-weight: 400;
  501. color: #ffffff;
  502. }
  503. .con-wait {
  504. padding-left: 500px;
  505. margin-top: 40px;
  506. height: 200px;
  507. font-size: 130px;
  508. line-height: 200px;
  509. font-family: Alibaba PuHuiTi, Alibaba PuHuiTi-Regular;
  510. font-weight: 400;
  511. color: #ffffff;
  512. }
  513. </style>