barscreen.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513
  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://swjh.shizhi.tv/websocket/gw/";
  50. // *** 接口地址 ***
  51. var ettpApiUrl = "https://swjh.shizhi.tv/machine/init/old/ettp";
  52. // var ettpApiUrl = "http://1.82.219.239:8092/machine/init/old/ettp"
  53. var stateApiUrl = "https://swjh.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. }, 2000);
  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. }, 2000);
  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. }
  324. }
  325. // 修改元素内容
  326. function setEleCon(id, label, value) {
  327. var ele = document.getElementById(id);
  328. ele[label] = value;
  329. }
  330. // 设置样式
  331. function setStyle(id, label, value) {
  332. var ele = document.getElementById(id);
  333. ele.style[label] = value;
  334. }
  335. // 获取元素内容
  336. function getEleCon(id) {
  337. var ele = document.getElementById(id);
  338. return ele.innerHTML;
  339. }
  340. // 获取数据
  341. getDatas();
  342. </script>
  343. <style>
  344. html,
  345. body {
  346. margin: 0;
  347. padding: 0;
  348. }
  349. .container {
  350. width: 1920px;
  351. height: 1080px;
  352. }
  353. .title {
  354. padding: 20px 0;
  355. width: 100%;
  356. height: 100px;
  357. line-height: 100px;
  358. font-size: 70px;
  359. color: #ffffff;
  360. text-align: center;
  361. font-weight: 500;
  362. font-family: PingFang SC, PingFang SC-Medium;
  363. background-image: url(./image/bar.png);
  364. }
  365. .border1 {
  366. width: 100%;
  367. height: 10px;
  368. background: #00ffff;
  369. }
  370. .content {
  371. position: relative;
  372. width: 100%;
  373. height: 930px;
  374. background-image: url(./image/bg.png);
  375. background-size: 100% 100%;
  376. }
  377. .con-info {
  378. padding-top: 50px;
  379. width: 100%;
  380. height: 300px;
  381. }
  382. .con-info-index {
  383. float: left;
  384. margin: 25px;
  385. width: 250px;
  386. height: 250px;
  387. text-align: center;
  388. line-height: 250px;
  389. font-size: 150px;
  390. font-family: DIN, DIN-Regular;
  391. color: #ffffff;
  392. border-radius: 50%;
  393. background: #ff0000;
  394. }
  395. .con-info-name {
  396. float: left;
  397. margin-right: 65px;
  398. width: 750px;
  399. height: 300px;
  400. line-height: 300px;
  401. font-size: 120px;
  402. color: #ffffff;
  403. font-family: PingFang SC, PingFang SC-Regular;
  404. font-weight: 400;
  405. text-align: left;
  406. }
  407. .con-info-state {
  408. float: left;
  409. width: 800px;
  410. height: 300px;
  411. }
  412. .con-info-state-icon {
  413. float: left;
  414. padding: 75px 0 55px 0;
  415. width: 170px;
  416. height: 170px;
  417. }
  418. .con-info-state-icon > img {
  419. width: 100%;
  420. height: 100%;
  421. }
  422. .con-info-state-text {
  423. float: left;
  424. width: 630px;
  425. height: 300px;
  426. line-height: 300px;
  427. text-align: center;
  428. font-size: 150px;
  429. font-weight: 400;
  430. }
  431. .con-state {
  432. display: none;
  433. margin-top: 70px;
  434. margin-left: 650px;
  435. width: 1000px;
  436. height: 300px;
  437. }
  438. .con-state-icon {
  439. float: left;
  440. padding: 80px 0 60px 0;
  441. width: 170px;
  442. height: 170px;
  443. }
  444. .con-state-icon > img {
  445. width: 100%;
  446. height: 100%;
  447. }
  448. .con-state-text {
  449. margin-left: 10px;
  450. float: left;
  451. width: 660px;
  452. height: 300px;
  453. line-height: 300px;
  454. color: #00ffff;
  455. text-align: left;
  456. font-size: 165px;
  457. font-weight: 400;
  458. }
  459. .con-now {
  460. padding-left: 500px;
  461. margin-top: 120px;
  462. height: 200px;
  463. font-size: 130px;
  464. line-height: 200px;
  465. font-family: Alibaba PuHuiTi, Alibaba PuHuiTi-Regular;
  466. font-weight: 400;
  467. color: #ffffff;
  468. }
  469. .con-wait {
  470. padding-left: 500px;
  471. margin-top: 40px;
  472. height: 200px;
  473. font-size: 130px;
  474. line-height: 200px;
  475. font-family: Alibaba PuHuiTi, Alibaba PuHuiTi-Regular;
  476. font-weight: 400;
  477. color: #ffffff;
  478. }
  479. </style>