barscreen.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  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] != "征纳互动" || infos.slyw[0] != "电子税务局") &&
  233. infos.slyw[0] != "综合服务"
  234. ) {
  235. setStyle("conInfoState", "display", "");
  236. setStyle("conState", "display", "none");
  237. setStyle("conNowBox", "display", "");
  238. setStyle("conWaitBox", "display", "");
  239. setStyle("conInfoName", "width", "750px");
  240. setStyle("conNowBox", "fontSize", "");
  241. setStyle("conNowBox", "marginLeft", "");
  242. // 业务名称
  243. if (infos.slyw) {
  244. setEleCon("conInfoName", "innerHTML", infos.slyw.join(" "));
  245. if (infos.slyw.join(" ").length > 5) {
  246. setStyle("conInfoName", "lineHeight", "150px");
  247. setStyle("conInfoName", "fontSize", "120px");
  248. } else {
  249. setStyle("conInfoName", "lineHeight", "300px");
  250. setStyle("conInfoName", "fontSize", "150px");
  251. }
  252. }
  253. // 修改图标及状态
  254. var srcs = {
  255. kx: "./image/frees.png",
  256. zt: "./image/wites.png",
  257. hj: "./image/xlb.png",
  258. };
  259. var textColors = {
  260. kx: "#00FFFF",
  261. zt: "#FFF700",
  262. hj: "#00FFFF",
  263. };
  264. var ckzt = infos.ckzt || "";
  265. setEleCon(
  266. "icon",
  267. "src",
  268. ckzt == "空闲" ? srcs.kx : ckzt === "暂停服务" ? srcs.zt : srcs.hj
  269. );
  270. setStyle(
  271. "conStateText",
  272. "color",
  273. ckzt === "空闲"
  274. ? textColors.kx
  275. : ckzt === "暂停服务"
  276. ? textColors.zt
  277. : textColors.kx
  278. );
  279. setEleCon("conStateText", "innerHTML", ckzt === "空闲" ? "工作中" : ckzt);
  280. // 正在办理
  281. setEleCon(
  282. "conNow",
  283. "innerHTML",
  284. ckzt != "空闲" && ckzt != "暂停服务" ? ckzt : "暂无"
  285. );
  286. // 等待人数
  287. setEleCon(
  288. "conWait",
  289. "innerHTML",
  290. ckzt != "暂停服务" && infos.ddrs != "0"
  291. ? (infos.ddrs || "0") + "人"
  292. : "暂无"
  293. );
  294. } else {
  295. setStyle("conInfoState", "display", "none");
  296. setStyle("conNowBox", "display", "none");
  297. setStyle("conWaitBox", "display", "none");
  298. if (infos.slyw[0] === "征纳互动" || infos.slyw[0] == "电子税务局") {
  299. setStyle("conInfoName", "width", "1555px");
  300. // 业务名称
  301. if (infos.slyw) {
  302. setStyle("conState", "display", "block");
  303. setEleCon("conInfoName", "innerHTML", infos.slyw.join(" "));
  304. setStyle("conInfoName", "lineHeight", "300px");
  305. setStyle("conInfoName", "fontSize", "140px");
  306. }
  307. } else if (infos.slyw[0] === "综合服务") {
  308. setStyle("conInfoName", "width", "750px");
  309. // 业务名称
  310. if (infos.slyw) {
  311. setStyle("conState", "display", "none");
  312. setEleCon("conInfoName", "innerHTML", infos.slyw.join(" "));
  313. setStyle("conInfoName", "lineHeight", "300px");
  314. if (infos.slyw.join(" ").length > 5) {
  315. setStyle("conInfoName", "fontSize", "120px");
  316. } else {
  317. setStyle("conInfoName", "fontSize", "150px");
  318. }
  319. setStyle("conInfoState", "display", "");
  320. // 修改图标及状态
  321. var srcs = {
  322. kx: "./image/frees.png",
  323. zt: "./image/wites.png",
  324. hj: "./image/xlb.png",
  325. };
  326. var textColors = {
  327. kx: "#00FFFF",
  328. zt: "#FFF700",
  329. hj: "#00FFFF",
  330. };
  331. var ckzt = infos.ckzt || "";
  332. setEleCon("icon", "src", srcs.zt);
  333. setStyle("conStateText", "color", textColors.zt);
  334. setEleCon("conStateText", "innerHTML", "暂停服务");
  335. setStyle("conNowBox", "display", "");
  336. setEleCon("conNowBox", "innerHTML", "潮汐窗口");
  337. setStyle("conNowBox", "fontSize", "180px");
  338. setStyle("conNowBox", "marginLeft", "110px");
  339. }
  340. }
  341. }
  342. }
  343. // 修改元素内容
  344. function setEleCon(id, label, value) {
  345. var ele = document.getElementById(id);
  346. ele[label] = value;
  347. }
  348. // 设置样式
  349. function setStyle(id, label, value) {
  350. var ele = document.getElementById(id);
  351. ele.style[label] = value;
  352. }
  353. // 获取元素内容
  354. function getEleCon(id) {
  355. var ele = document.getElementById(id);
  356. return ele.innerHTML;
  357. }
  358. // 获取数据
  359. getDatas();
  360. </script>
  361. <style>
  362. html,
  363. body {
  364. margin: 0;
  365. padding: 0;
  366. }
  367. .container {
  368. width: 1920px;
  369. height: 1080px;
  370. }
  371. .title {
  372. padding: 20px 0;
  373. width: 100%;
  374. height: 100px;
  375. line-height: 100px;
  376. font-size: 70px;
  377. color: #ffffff;
  378. text-align: center;
  379. font-weight: 500;
  380. font-family: PingFang SC, PingFang SC-Medium;
  381. background-image: url(./image/bar.png);
  382. }
  383. .border1 {
  384. width: 100%;
  385. height: 10px;
  386. background: #00ffff;
  387. }
  388. .content {
  389. position: relative;
  390. width: 100%;
  391. height: 930px;
  392. background-image: url(./image/bg.png);
  393. background-size: 100% 100%;
  394. }
  395. .con-info {
  396. padding-top: 50px;
  397. width: 100%;
  398. height: 300px;
  399. }
  400. .con-info-index {
  401. float: left;
  402. margin: 25px;
  403. width: 250px;
  404. height: 250px;
  405. text-align: center;
  406. line-height: 250px;
  407. font-size: 150px;
  408. font-family: DIN, DIN-Regular;
  409. color: #ffffff;
  410. border-radius: 50%;
  411. background: #ff0000;
  412. }
  413. .con-info-name {
  414. float: left;
  415. margin-right: 65px;
  416. width: 750px;
  417. height: 300px;
  418. line-height: 300px;
  419. font-size: 120px;
  420. color: #ffffff;
  421. font-family: PingFang SC, PingFang SC-Regular;
  422. font-weight: 400;
  423. text-align: left;
  424. }
  425. .con-info-state {
  426. float: left;
  427. width: 780px;
  428. height: 300px;
  429. }
  430. .con-info-state-icon {
  431. float: left;
  432. padding: 75px 0 55px 0;
  433. width: 170px;
  434. height: 170px;
  435. }
  436. .con-info-state-icon > img {
  437. width: 100%;
  438. height: 100%;
  439. }
  440. .con-info-state-text {
  441. float: left;
  442. width: 610px;
  443. height: 300px;
  444. line-height: 300px;
  445. text-align: center;
  446. font-size: 150px;
  447. font-weight: 400;
  448. }
  449. .con-state {
  450. display: none;
  451. margin-top: 70px;
  452. margin-left: 650px;
  453. width: 1000px;
  454. height: 300px;
  455. }
  456. .con-state-icon {
  457. float: left;
  458. padding: 80px 0 60px 0;
  459. width: 170px;
  460. height: 170px;
  461. }
  462. .con-state-icon > img {
  463. width: 100%;
  464. height: 100%;
  465. }
  466. .con-state-text {
  467. margin-left: 10px;
  468. float: left;
  469. width: 610px;
  470. height: 300px;
  471. line-height: 300px;
  472. color: #00ffff;
  473. text-align: left;
  474. font-size: 165px;
  475. font-weight: 400;
  476. }
  477. .con-now {
  478. padding-left: 500px;
  479. margin-top: 120px;
  480. height: 200px;
  481. font-size: 130px;
  482. line-height: 200px;
  483. font-family: Alibaba PuHuiTi, Alibaba PuHuiTi-Regular;
  484. font-weight: 400;
  485. color: #ffffff;
  486. }
  487. .con-wait {
  488. padding-left: 500px;
  489. margin-top: 40px;
  490. height: 200px;
  491. font-size: 130px;
  492. line-height: 200px;
  493. font-family: Alibaba PuHuiTi, Alibaba PuHuiTi-Regular;
  494. font-weight: 400;
  495. color: #ffffff;
  496. }
  497. </style>