autodoor.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659
  1. <template>
  2. <view style="overflow: auto; height: 100%">
  3. <!-- 建议放在外层 -->
  4. <u-navbar :title="name" @leftClick="backPage" :bgImage="backPic">
  5. <view class="u-nav-slot" slot="left">
  6. <u-icon name="arrow-left" size="20"> </u-icon>
  7. </view>
  8. </u-navbar>
  9. <view class="main">
  10. <view class="u-page container">
  11. <div class="button-grid flcard" v-if="this.TabCur == 'gate'">
  12. <u-button
  13. type="primary"
  14. shape="circle"
  15. text="打开前门"
  16. @click="showPasswordDialog('frontGateOpen_S')"
  17. ></u-button>
  18. <u-button
  19. type="primary"
  20. shape="circle"
  21. text="关闭前门"
  22. @click="showPasswordDialog('frontGateClose_S')"
  23. ></u-button>
  24. <u-button
  25. type="primary"
  26. shape="circle"
  27. text="打开后门"
  28. @click="showPasswordDialog('rearGateOpen_S')"
  29. ></u-button>
  30. <u-button
  31. type="primary"
  32. shape="circle"
  33. text="关闭后门"
  34. @click="showPasswordDialog('rearGateClose_S')"
  35. ></u-button>
  36. <u-button
  37. type="primary"
  38. shape="circle"
  39. text="打开前后门"
  40. @click="showPasswordDialog('sameTimeOpen')"
  41. ></u-button>
  42. <u-button
  43. type="primary"
  44. shape="circle"
  45. text="关闭前后门"
  46. @click="showPasswordDialog('sameTimeClose')"
  47. ></u-button>
  48. </div>
  49. <div
  50. class="button-grid flcard"
  51. v-if="this.TabCur == 'window' && this.nwindownum == 1"
  52. >
  53. <u-button
  54. type="primary"
  55. shape="circle"
  56. text="设定面积"
  57. @click="showPasswordDialog('frontSetValue')"
  58. ></u-button>
  59. </div>
  60. <div
  61. class="button-grid flcard"
  62. v-if="this.TabCur == 'window' && this.nwindownum == 2"
  63. >
  64. <u-button
  65. type="primary"
  66. shape="circle"
  67. text="设定前窗面积"
  68. @click="showPasswordDialog('frontSetValue')"
  69. ></u-button>
  70. <u-button
  71. type="primary"
  72. shape="circle"
  73. text="设定后窗面积"
  74. @click="showPasswordDialog('rearSetValue')"
  75. ></u-button>
  76. </div>
  77. <div class="flcard" v-if="this.TabCur == 'gate'">
  78. <doorAnimate
  79. :gatestate1="frontGateStatus"
  80. :gatestate2="rearGateStatus"
  81. :videoURL="viedeoUrl"
  82. :height="height"
  83. :doorcount="ndoorcount"
  84. ></doorAnimate>
  85. </div>
  86. <div class="flcard" v-if="this.TabCur == 'windrect'">
  87. <windrectAnimate
  88. :state="state"
  89. :title="title"
  90. :videoURL="viedeoUrl"
  91. :height="height"
  92. :type="deviceType"
  93. ></windrectAnimate>
  94. </div>
  95. <div class="flcard" v-if="this.TabCur == 'fanlocal'">
  96. <fanlocalAnimate
  97. :fan1State="fan1State"
  98. :fan2State="fan2State"
  99. :title="title"
  100. :videoURL="viedeoUrl"
  101. :height="height"
  102. ></fanlocalAnimate>
  103. </div>
  104. <div
  105. class="flcard"
  106. v-if="this.TabCur == 'window' && this.nwindownum == 1"
  107. >
  108. <windowAnimate
  109. :windowAngle="windowAngle"
  110. :height="height"
  111. :windowcount="nwindownum"
  112. ></windowAnimate>
  113. </div>
  114. <div
  115. class="flcard"
  116. v-if="this.TabCur == 'window' && this.nwindownum == 2"
  117. >
  118. <windowAnimate
  119. :windowAngle="windowAngle"
  120. :windowAngle1="windowAngle1"
  121. :height="height"
  122. :windowcount="nwindownum"
  123. ></windowAnimate>
  124. </div>
  125. <div class="flcard">
  126. <div class="flex-container">
  127. <div
  128. class="itemback"
  129. v-for="(item, index) in typeList"
  130. :key="index"
  131. v-show="item.appShow == 1"
  132. >
  133. <div class="datacardtime" v-if="item.monitorcode == 'readTime'">
  134. <view
  135. class="demo-layout bg-purple-light"
  136. style="margin-top: 10rpx; color: #3787fe"
  137. >
  138. {{ tableData[item.monitorcode] }}
  139. </view>
  140. </div>
  141. <div class="datacard" v-if="item.monitorcode !== 'readTime'">
  142. <div class="left-content">
  143. <view v-if="item.monitorcode == 'ndoortype'"
  144. class="demo-layout bg-purple-light"
  145. style="margin-top: 10rpx; color: #3787fe"
  146. >
  147. {{ tableData[item.monitorcode] == '1'?'行人':tableData[item.monitorcode] == '2'?'行车':'-' }}
  148. </view>
  149. <view v-else
  150. class="demo-layout bg-purple-light"
  151. style="margin-top: 10rpx; color: #3787fe"
  152. >
  153. {{ tableData[item.monitorcode] == null || tableData[item.monitorcode] == ''?'-':tableData[item.monitorcode]}}
  154. </view>
  155. <div class="spacer"></div>
  156. <!-- 间距 -->
  157. <view
  158. class="demo-layout bg-purple-light"
  159. style="color: #677799"
  160. >
  161. {{ item.des }}
  162. </view>
  163. </div>
  164. <div
  165. class="right-content"
  166. :style="{
  167. backgroundImage:
  168. item.monitorcode === 'frontRearDP' ||
  169. item.monitorcode === 'frontRearDifference'
  170. ? 'url(\'../../../../static/model/Pa.png\')'
  171. : item.monitorcode === 'sourcePressure'
  172. ? 'url(\'../../../../static/model/MPa.png\')'
  173. : item.monitorcode === 'frontGateOpen'
  174. ? 'url(\'../../../../static/model/doorNet.png\')'
  175. : item.monitorcode === 'rearGateOpen'
  176. ? 'url(\'../../../../static/model/doorNet.png\')'
  177. : item.monitorcode === 'midGateOpen'
  178. ? 'url(\'../../../../static/model/doorNet.png\')'
  179. : item.monitorcode === 'warnFlag'
  180. ? 'url(\'../../../../static/model/9432.png\')'
  181. : item.monitorcode === 'netStatus'
  182. ? 'url(\'../../../../static/model/9431.png\')'
  183. : item.monitorcode === 'm3'
  184. ? 'url(\'../../../../static/model/windM3.png\')'
  185. : item.monitorcode === 'fsectarea'
  186. ? 'url(\'../../../../static/model/duanArea.png\')'
  187. : item.monitorcode === 'incipientWindSpeed1' ||
  188. item.monitorcode === 'incipientWindSpeed2' ||
  189. item.monitorcode === 'incipientWindSpeed3' ||
  190. item.monitorcode === 'va'
  191. ? 'url(\'../../../../static/model/fengsu.png\')'
  192. : 'url(\'\')',
  193. backgroundSize: '100% 100%',
  194. }"
  195. ></div>
  196. </div>
  197. </div>
  198. </div>
  199. </div>
  200. </view>
  201. </view>
  202. <view class="passwordPopup">
  203. <u-popup
  204. :show="show"
  205. mode="bottom"
  206. :round="14"
  207. :safeAreaInsetBottom="false"
  208. >
  209. <view style="margin-top: 15px" v-if="this.TabCur == 'window'"
  210. >风窗面积:</view
  211. >
  212. <u-input
  213. style="margin-top: 15px"
  214. v-model="windowArea"
  215. v-if="this.TabCur == 'window'"
  216. ></u-input>
  217. <view style="margin-top: 15px">请输入密码:</view>
  218. <u-input
  219. style="margin-top: 15px"
  220. v-model="password"
  221. type="password"
  222. ></u-input>
  223. <view class="btns">
  224. <u-button type="primary" shape="circle" @click="confirmPassword()"
  225. >确认</u-button
  226. >
  227. <u-button shape="circle" @click="cancelPassword()">取消</u-button>
  228. </view>
  229. </u-popup>
  230. </view>
  231. </view>
  232. </template>
  233. <script>
  234. import api from "@/api/api";
  235. import initDictOptions from "@/common/util/dictUtil.js";
  236. import doorAnimate from "../doorAnimate/doorAnimate.vue";
  237. import windowAnimate from "../windowAnimate/windowAnimate.vue";
  238. import windrectAnimate from "../windrectAnimate/windrectAnimate.vue";
  239. import fanlocalAnimate from "../fanlocalAnimate/fanlocalAnimate2.vue";
  240. export default {
  241. data() {
  242. return {
  243. tableData: [], //监测数据
  244. typeList: [], //展示字段
  245. itemId: "", // 初始化 itemId
  246. name: "", // 初始化 name
  247. deviceid: "", //初始化设备id
  248. TabCur: "",
  249. checked: [],
  250. backPic: "url(../../../../static/topnavbar.png)",
  251. frontAngle: "", //风窗打开角度
  252. nwindownum: "", //风窗道数
  253. ndoorcount: "", //风门道数
  254. deviceType: "", //设备类型
  255. show: false, //密码弹窗是否显示
  256. password: "", //控制设备密码
  257. paramcode: "", //控制字段
  258. height: "200px",
  259. popupStyle: {
  260. // 弹窗样式
  261. "background-color": "#fff",
  262. padding: "20px",
  263. "box-shadow": "0 2px 4px rgba(0, 0, 0, 0.1)",
  264. },
  265. frontGateStatus: "", //前门状态
  266. rearGateStatus: "", //后门状态
  267. windowAngle: 0, //前窗打开角度
  268. windowAngle1: 0, //后窗打开角度
  269. windowArea: "", //风窗面积设定值
  270. viedeoUrl: "", //监控url
  271. sign:"",
  272. title:"测风设备",
  273. fan1State:'',
  274. fan2State:''
  275. };
  276. },
  277. onLoad(query) {
  278. //保存id到 data 中 可以在整个页面中使用
  279. this.itemId = query.id;
  280. this.name = query.name;
  281. this.TabCur = query.type;
  282. this.getShowList();
  283. this.ndoorcount = 2;
  284. },
  285. components: { doorAnimate, windowAnimate,windrectAnimate,fanlocalAnimate },
  286. created() {
  287. this.getDeviceInfo(this.itemId);
  288. this.getVideoUrlById(this.itemId);
  289. },
  290. mounted() {
  291. this.startTimer();
  292. },
  293. methods: {
  294. startTimer() {
  295. this.timer = setInterval(() => {
  296. // 执行定时任务
  297. this.getDeviceInfo(this.itemId);
  298. }, 5000);
  299. },
  300. stopTimer() {
  301. // 停止定时器
  302. clearInterval(this.timer);
  303. },
  304. // 返回上一个页面
  305. backPage() {
  306. this.$destroy();
  307. uni.navigateBack({
  308. delta: 1,
  309. });
  310. },
  311. //获取app展示字段数据
  312. getShowList() {
  313. const params = {
  314. devicekind: this.TabCur,
  315. pagetype: "detail",
  316. pageNo: 1,
  317. pageSize: 100,
  318. };
  319. new Promise((resolve, reject) => {
  320. api
  321. .getShowColumList(params)
  322. .then((response) => {
  323. if (response.data.code == 200) {
  324. this.typeList = response.data.result.records;
  325. } else {
  326. resolve(response);
  327. }
  328. })
  329. .catch((error) => {
  330. reject(error);
  331. });
  332. });
  333. },
  334. //获取详情数据
  335. getDeviceInfo(ID) {
  336. let IDString = String(ID); // 将 ID 转换为字符串
  337. new Promise((resolve, reject) => {
  338. api
  339. .getDeviceMonitor({ devicetype: this.TabCur, ids: IDString })
  340. .then((response) => {
  341. if (response.data.code == 200 && response.data.result.msgTxt[0].datalist.length>0) {
  342. var result = response.data.result.msgTxt[0].datalist[0];
  343. this.tableData =
  344. result.readData;
  345. if (this.tableData.frontGateOpen == "1") {
  346. this.tableData.frontGateOpen = "打开";
  347. } else {
  348. this.tableData.frontGateOpen = "关闭";
  349. }
  350. if (this.tableData.midGateOpen == "1") {
  351. this.tableData.midGateOpen = "打开";
  352. } else {
  353. this.tableData.midGateOpen = "关闭";
  354. }
  355. if (this.tableData.rearGateOpen == "1") {
  356. this.tableData.rearGateOpen = "打开";
  357. } else {
  358. this.tableData.rearGateOpen = "关闭";
  359. }
  360. this.fan1State = result.readData.Fan1StartStatus
  361. this.fan2State = result.readData.Fan2StartStatus
  362. this.nwindownum =
  363. result.nwindownum;
  364. this.ndoorcount =
  365. result.ndoorcount;
  366. this.deviceType =
  367. result.deviceType;
  368. this.state =
  369. result.readData.sign;
  370. this.frontGateStatus = this.tableData.frontGateOpen;
  371. this.rearGateStatus = this.tableData.rearGateOpen;
  372. var maxarea = result.maxarea;
  373. this.windowAngle =
  374. (this.tableData.forntArea / maxarea) * 100 * 0.9;
  375. this.windowAngle1 =
  376. (this.tableData.rearArea / maxarea) * 100 * 0.9;
  377. } else {
  378. resolve(response);
  379. }
  380. })
  381. .catch((error) => {
  382. reject(error);
  383. });
  384. });
  385. },
  386. //获取监控URL 通过ID获取
  387. getVideoUrlById(ID) {
  388. let IDString = String(ID); // 将 ID 转换为字符串
  389. new Promise((resolve, reject) => {
  390. api
  391. .getCameraById({ deviceid: IDString })
  392. .then((response) => {
  393. if (response.data.code == 200) {
  394. if(response.data.result.records.length>0){
  395. this.viedeoUrl = response.data.result.records[0].addr;
  396. console.log(
  397. response.data.result.records[0].addr,
  398. "csssssssssssssss"
  399. );
  400. }
  401. } else {
  402. resolve(response);
  403. }
  404. })
  405. .catch((error) => {
  406. reject(error);
  407. });
  408. });
  409. },
  410. //设备控制
  411. ctrlDevice(pass) {
  412. let IDString = String(this.itemId); // 将 ID 转换为字符串
  413. const params = {
  414. deviceid: IDString,
  415. devicetype: this.deviceType,
  416. paramcode: this.paramcode,
  417. password: pass,
  418. value: this.windowArea,
  419. };
  420. new Promise((resolve, reject) => {
  421. api
  422. .controlDevice(params)
  423. .then((response) => {
  424. if (response.data.code == 200) {
  425. this.getDeviceInfo(IDString);
  426. // console.log("操作成功");
  427. } else {
  428. resolve(response);
  429. }
  430. })
  431. .catch((error) => {
  432. reject(error);
  433. });
  434. });
  435. },
  436. // 显示密码输入弹窗
  437. showPasswordDialog(controlCode) {
  438. this.paramcode = controlCode;
  439. this.show = true;
  440. },
  441. // 取消密码输入
  442. cancelPassword() {
  443. this.show = false;
  444. },
  445. confirmPassword() {
  446. this.ctrlDevice(this.password);
  447. // 发起请求后关闭密码输入弹窗
  448. this.show = false;
  449. }
  450. },
  451. destroyed() {
  452. // 停止定时器
  453. this.stopTimer();
  454. },
  455. };
  456. </script>
  457. <style>
  458. passwordPopup {
  459. height: 300rpx;
  460. background-color: #fff;
  461. }
  462. .top-nav {
  463. background-image: url(../../../../static/topnavbar.png);
  464. background-size: cover; /* 背景图片大小适应 */
  465. height: 100%;
  466. }
  467. .top-nav2 {
  468. background-color: #ffffff;
  469. }
  470. .main {
  471. margin-top: 100rpx;
  472. }
  473. .container {
  474. display: flex;
  475. flex-direction: column;
  476. }
  477. .button-grid {
  478. display: grid;
  479. grid-template-columns: repeat(4, 1fr);
  480. gap: 5px; /* 可以根据需要调整行列之间的间距 */
  481. }
  482. .flcard {
  483. padding: 20rpx;
  484. background-color: #ffffff;
  485. margin-bottom: 5rpx;
  486. }
  487. .additional-div {
  488. grid-column: span 2; /* 让附加内容跨越三列 */
  489. display: flex;
  490. align-items: center;
  491. }
  492. .checkbox-group {
  493. margin-left: 10px; /* 可以根据需要调整间距 */
  494. }
  495. .card {
  496. background-color: #ffffff;
  497. margin: auto;
  498. margin-top: 20rpx;
  499. width: 90%;
  500. height: 280rpx;
  501. border: 1rpx solid #000000;
  502. border-radius: 20rpx;
  503. }
  504. .flex-containe {
  505. display: flex;
  506. flex-direction: row;
  507. flex-wrap: wrap;
  508. }
  509. .itemback {
  510. flex: 0 0 calc(33.33% - 10px); /* 使用calc函数计算每个项目的宽度,减去间距 */
  511. margin: 5px; /* 间距设置为5px */
  512. }
  513. .datacardtime {
  514. display: flex;
  515. width: 100%;
  516. flex: 1;
  517. margin: 1%;
  518. float: left;
  519. height: 50rpx;
  520. text-align: center;
  521. background: linear-gradient(
  522. to right,
  523. rgba(55, 135, 254, 0.08),
  524. rgba(4, 184, 255, 0.08),
  525. rgba(60, 161, 237, 0.08)
  526. );
  527. }
  528. .datacard {
  529. display: flex;
  530. width: 48%;
  531. flex: 1;
  532. margin: 1%;
  533. float: left;
  534. height: 100rpx;
  535. text-align: center;
  536. background: linear-gradient(
  537. to right,
  538. rgba(55, 135, 254, 0.08),
  539. rgba(4, 184, 255, 0.08),
  540. rgba(60, 161, 237, 0.08)
  541. );
  542. }
  543. .left-content {
  544. width: 50%;
  545. display: flex;
  546. flex-direction: column;
  547. }
  548. .spacer {
  549. height: 10rpx;
  550. }
  551. .right-content {
  552. width: 50%; /* 右侧内容占据50%宽度 */
  553. background-image: url(../../../../static/model/Pa.png);
  554. background-size: 100% 125%;
  555. }
  556. /*风窗样式*/
  557. div.autowindow_new {
  558. width: 200px;
  559. height: 200px;
  560. background-image: url(../../../../static/window/window-bk.png);
  561. background-size: 100% 100%;
  562. perspective: 800px;
  563. }
  564. /*风窗1 2 3 4*/
  565. div.window_new_1 {
  566. margin-top: 12px;
  567. margin-left: 15px;
  568. width: 170px;
  569. height: 30px;
  570. background-color: crimson;
  571. box-sizing: border-box;
  572. float: left;
  573. z-index: 1;
  574. /* transition: all 2s; */
  575. background-image: url(../../../../static/window/window_new1.png);
  576. background-size: 100% 100%;
  577. }
  578. div.window_new_2 {
  579. margin-top: 2px;
  580. margin-left: 15px;
  581. width: 170px;
  582. height: 29px;
  583. background-color: crimson;
  584. box-sizing: border-box;
  585. float: left;
  586. z-index: 1;
  587. /* transition: all 2s; */
  588. background-image: url(../../../../static/window/window_new1.png);
  589. background-size: 100% 100%;
  590. }
  591. div.window_new_3 {
  592. margin-top: 2px;
  593. margin-left: 15px;
  594. width: 170px;
  595. height: 29px;
  596. background-color: crimson;
  597. box-sizing: border-box;
  598. float: left;
  599. z-index: 1;
  600. /* transition: all 2s; */
  601. background-image: url(../../../../static/window/window_new1.png);
  602. background-size: 100% 100%;
  603. }
  604. div.window_new_4 {
  605. margin-top: 2px;
  606. margin-left: 15px;
  607. width: 170px;
  608. height: 29px;
  609. background-color: crimson;
  610. box-sizing: border-box;
  611. float: left;
  612. z-index: 1;
  613. /* transition: all 2s; */
  614. background-image: url(../../../../static/window/window_new1.png);
  615. background-size: 100% 100%;
  616. }
  617. div.window_new_5 {
  618. margin-top: 2px;
  619. margin-left: 15px;
  620. width: 170px;
  621. height: 29px;
  622. background-color: crimson;
  623. box-sizing: border-box;
  624. float: left;
  625. z-index: 1;
  626. /* transition: all 2s; */
  627. background-image: url(../../../../static/window/window_new1.png);
  628. background-size: 100% 100%;
  629. }
  630. div.window_new_1 {
  631. transition: all 2s ease;
  632. transform-origin: center center;
  633. }
  634. div.window_new_2 {
  635. transition: all 2s ease;
  636. transform-origin: center center;
  637. }
  638. div.window_new_3 {
  639. transition: all 2s ease;
  640. transform-origin: center center;
  641. }
  642. div.window_new_4 {
  643. transition: all 2s ease;
  644. transform-origin: center center;
  645. }
  646. div.window_new_5 {
  647. transition: all 2s ease;
  648. transform-origin: center center;
  649. }
  650. .btns {
  651. display: flex;
  652. margin-top: 15px;
  653. }
  654. </style>