autodoor.vue 19 KB

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