autodoor.vue 18 KB

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