autodoor.vue 18 KB

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