autodoor.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  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.ndoorcount = 2;
  283. },
  284. components: { doorAnimate, windowAnimate,windrectAnimate,fanlocalAnimate },
  285. created() {
  286. this.getShowList(this.TabCur);
  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(type) {
  313. const params = {
  314. devicekind: type,
  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. console.log(this.typeList,'ssssssssssssssssc sa a ')
  326. } else {
  327. resolve(response);
  328. }
  329. })
  330. .catch((error) => {
  331. reject(error);
  332. });
  333. });
  334. },
  335. //获取详情数据
  336. getDeviceInfo(ID) {
  337. let IDString = String(ID); // 将 ID 转换为字符串
  338. new Promise((resolve, reject) => {
  339. api
  340. .getDeviceMonitor({ devicetype: this.TabCur, ids: IDString })
  341. .then((response) => {
  342. if (response.data.code == 200 && response.data.result.msgTxt[0].datalist.length>0) {
  343. var result = response.data.result.msgTxt[0].datalist[0];
  344. this.tableData =
  345. result.readData;
  346. if (this.tableData.frontGateOpen == "1") {
  347. this.tableData.frontGateOpen = "打开";
  348. } else {
  349. this.tableData.frontGateOpen = "关闭";
  350. }
  351. if (this.tableData.midGateOpen == "1") {
  352. this.tableData.midGateOpen = "打开";
  353. } else {
  354. this.tableData.midGateOpen = "关闭";
  355. }
  356. if (this.tableData.rearGateOpen == "1") {
  357. this.tableData.rearGateOpen = "打开";
  358. } else {
  359. this.tableData.rearGateOpen = "关闭";
  360. }
  361. this.fan1State = result.readData.Fan1StartStatus
  362. this.fan2State = result.readData.Fan2StartStatus
  363. this.nwindownum =
  364. result.nwindownum;
  365. this.ndoorcount =
  366. result.ndoorcount;
  367. this.deviceType =
  368. result.deviceType;
  369. this.state =
  370. result.readData.sign;
  371. this.frontGateStatus = this.tableData.frontGateOpen;
  372. this.rearGateStatus = this.tableData.rearGateOpen;
  373. var maxarea = result.maxarea;
  374. this.windowAngle =
  375. (this.tableData.forntArea / maxarea) * 100 * 0.9;
  376. this.windowAngle1 =
  377. (this.tableData.rearArea / maxarea) * 100 * 0.9;
  378. this.$forceUpdate()
  379. } else {
  380. resolve(response);
  381. }
  382. })
  383. .catch((error) => {
  384. reject(error);
  385. });
  386. });
  387. },
  388. //获取监控URL 通过ID获取
  389. getVideoUrlById(ID) {
  390. let IDString = String(ID); // 将 ID 转换为字符串
  391. new Promise((resolve, reject) => {
  392. api
  393. .getCameraById({ deviceid: IDString })
  394. .then((response) => {
  395. if (response.data.code == 200) {
  396. if(response.data.result.records.length>0){
  397. this.viedeoUrl = response.data.result.records[0].addr;
  398. }
  399. } else {
  400. resolve(response);
  401. }
  402. })
  403. .catch((error) => {
  404. reject(error);
  405. });
  406. });
  407. },
  408. //设备控制
  409. ctrlDevice(pass) {
  410. let IDString = String(this.itemId); // 将 ID 转换为字符串
  411. const params = {
  412. deviceid: IDString,
  413. devicetype: this.deviceType,
  414. paramcode: this.paramcode,
  415. password: pass,
  416. value: this.windowArea,
  417. };
  418. new Promise((resolve, reject) => {
  419. api
  420. .controlDevice(params)
  421. .then((response) => {
  422. if (response.data.code == 200) {
  423. this.getDeviceInfo(IDString);
  424. // console.log("操作成功");
  425. } else {
  426. resolve(response);
  427. }
  428. })
  429. .catch((error) => {
  430. reject(error);
  431. });
  432. });
  433. },
  434. // 显示密码输入弹窗
  435. showPasswordDialog(controlCode) {
  436. this.paramcode = controlCode;
  437. this.show = true;
  438. },
  439. // 取消密码输入
  440. cancelPassword() {
  441. this.show = false;
  442. },
  443. confirmPassword() {
  444. this.ctrlDevice(this.password);
  445. // 发起请求后关闭密码输入弹窗
  446. this.show = false;
  447. }
  448. },
  449. destroyed() {
  450. // 停止定时器
  451. this.stopTimer();
  452. },
  453. };
  454. </script>
  455. <style>
  456. passwordPopup {
  457. height: 300rpx;
  458. background-color: #fff;
  459. }
  460. .top-nav {
  461. background-image: url(../../../../static/topnavbar.png);
  462. background-size: cover; /* 背景图片大小适应 */
  463. height: 100%;
  464. }
  465. .top-nav2 {
  466. background-color: #ffffff;
  467. }
  468. .main {
  469. margin-top: 100rpx;
  470. }
  471. .container {
  472. display: flex;
  473. flex-direction: column;
  474. }
  475. .button-grid {
  476. display: grid;
  477. grid-template-columns: repeat(4, 1fr);
  478. gap: 5px; /* 可以根据需要调整行列之间的间距 */
  479. }
  480. .flcard {
  481. padding: 20rpx;
  482. background-color: #ffffff;
  483. margin-bottom: 5rpx;
  484. }
  485. .additional-div {
  486. grid-column: span 2; /* 让附加内容跨越三列 */
  487. display: flex;
  488. align-items: center;
  489. }
  490. .checkbox-group {
  491. margin-left: 10px; /* 可以根据需要调整间距 */
  492. }
  493. .card {
  494. background-color: #ffffff;
  495. margin: auto;
  496. margin-top: 20rpx;
  497. width: 90%;
  498. height: 280rpx;
  499. border: 1rpx solid #000000;
  500. border-radius: 20rpx;
  501. }
  502. .flex-containe {
  503. display: flex;
  504. flex-direction: row;
  505. flex-wrap: wrap;
  506. }
  507. .itemback {
  508. flex: 0 0 calc(33.33% - 10px); /* 使用calc函数计算每个项目的宽度,减去间距 */
  509. margin: 5px; /* 间距设置为5px */
  510. }
  511. .datacardtime {
  512. display: flex;
  513. width: 100%;
  514. flex: 1;
  515. margin: 1%;
  516. float: left;
  517. height: 50rpx;
  518. text-align: center;
  519. background: linear-gradient(
  520. to right,
  521. rgba(55, 135, 254, 0.08),
  522. rgba(4, 184, 255, 0.08),
  523. rgba(60, 161, 237, 0.08)
  524. );
  525. }
  526. .datacard {
  527. display: flex;
  528. width: 48%;
  529. flex: 1;
  530. margin: 1%;
  531. float: left;
  532. height: 100rpx;
  533. text-align: center;
  534. background: linear-gradient(
  535. to right,
  536. rgba(55, 135, 254, 0.08),
  537. rgba(4, 184, 255, 0.08),
  538. rgba(60, 161, 237, 0.08)
  539. );
  540. }
  541. .left-content {
  542. width: 50%;
  543. display: flex;
  544. flex-direction: column;
  545. }
  546. .spacer {
  547. height: 10rpx;
  548. }
  549. .right-content {
  550. width: 50%; /* 右侧内容占据50%宽度 */
  551. background-image: url(../../../../static/model/Pa.png);
  552. background-size: 100% 125%;
  553. }
  554. /*风窗样式*/
  555. div.autowindow_new {
  556. width: 200px;
  557. height: 200px;
  558. background-image: url(../../../../static/window/window-bk.png);
  559. background-size: 100% 100%;
  560. perspective: 800px;
  561. }
  562. /*风窗1 2 3 4*/
  563. div.window_new_1 {
  564. margin-top: 12px;
  565. margin-left: 15px;
  566. width: 170px;
  567. height: 30px;
  568. background-color: crimson;
  569. box-sizing: border-box;
  570. float: left;
  571. z-index: 1;
  572. /* transition: all 2s; */
  573. background-image: url(../../../../static/window/window_new1.png);
  574. background-size: 100% 100%;
  575. }
  576. div.window_new_2 {
  577. margin-top: 2px;
  578. margin-left: 15px;
  579. width: 170px;
  580. height: 29px;
  581. background-color: crimson;
  582. box-sizing: border-box;
  583. float: left;
  584. z-index: 1;
  585. /* transition: all 2s; */
  586. background-image: url(../../../../static/window/window_new1.png);
  587. background-size: 100% 100%;
  588. }
  589. div.window_new_3 {
  590. margin-top: 2px;
  591. margin-left: 15px;
  592. width: 170px;
  593. height: 29px;
  594. background-color: crimson;
  595. box-sizing: border-box;
  596. float: left;
  597. z-index: 1;
  598. /* transition: all 2s; */
  599. background-image: url(../../../../static/window/window_new1.png);
  600. background-size: 100% 100%;
  601. }
  602. div.window_new_4 {
  603. margin-top: 2px;
  604. margin-left: 15px;
  605. width: 170px;
  606. height: 29px;
  607. background-color: crimson;
  608. box-sizing: border-box;
  609. float: left;
  610. z-index: 1;
  611. /* transition: all 2s; */
  612. background-image: url(../../../../static/window/window_new1.png);
  613. background-size: 100% 100%;
  614. }
  615. div.window_new_5 {
  616. margin-top: 2px;
  617. margin-left: 15px;
  618. width: 170px;
  619. height: 29px;
  620. background-color: crimson;
  621. box-sizing: border-box;
  622. float: left;
  623. z-index: 1;
  624. /* transition: all 2s; */
  625. background-image: url(../../../../static/window/window_new1.png);
  626. background-size: 100% 100%;
  627. }
  628. div.window_new_1 {
  629. transition: all 2s ease;
  630. transform-origin: center center;
  631. }
  632. div.window_new_2 {
  633. transition: all 2s ease;
  634. transform-origin: center center;
  635. }
  636. div.window_new_3 {
  637. transition: all 2s ease;
  638. transform-origin: center center;
  639. }
  640. div.window_new_4 {
  641. transition: all 2s ease;
  642. transform-origin: center center;
  643. }
  644. div.window_new_5 {
  645. transition: all 2s ease;
  646. transform-origin: center center;
  647. }
  648. .btns {
  649. display: flex;
  650. margin-top: 15px;
  651. }
  652. </style>