autodoor.vue 20 KB

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