autodoor.vue 17 KB

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