index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  1. <template>
  2. <view>
  3. <view class="status_bar"></view>
  4. <view class="" style="position: relative; top: 44px">
  5. <view style="position: fixed; z-index: 100">
  6. <uni-nav-bar
  7. @clickLeft="clickLeft"
  8. left-icon="back"
  9. left-text="返回"
  10. title="环境监测系统"
  11. right-icon="search"
  12. @clickRight="clickRight"
  13. size="16"
  14. ></uni-nav-bar>
  15. <view class="inputs" :style="{ width: width + 'rpx' }">
  16. <input
  17. type="text"
  18. value=""
  19. placeholder="请输入设备ID或设备名称"
  20. v-model="imports"
  21. @input="searchinp"
  22. class="inputbox"
  23. :clearable="false"
  24. />
  25. <u-icon name="search" size="40" class="icon" @click="search"></u-icon>
  26. </view>
  27. </view>
  28. <image
  29. :src="
  30. 'http://www.hnyfwlw.com:8006/bigdata_app' + '/image/environment/1.png'
  31. "
  32. mode=""
  33. class="image"
  34. >
  35. </image>
  36. <view class="loading" v-if="loadingtf">
  37. <image
  38. src="../../static/images/ajax-loader.gif"
  39. mode=""
  40. class="img"
  41. ></image>
  42. </view>
  43. <view class="tab-box">
  44. <view
  45. v-for="(item, index) in equipArr"
  46. :key="item.type"
  47. v-if="item.tf"
  48. @click="tabClick(index, item.type)"
  49. :class="['tab-item', active == index ? 'active' : '']"
  50. >
  51. <text>{{ item.name }}</text>
  52. <text class="bottom-line"></text>
  53. </view>
  54. </view>
  55. <view class="prevents">
  56. <view
  57. class="prevents_item"
  58. v-for="(item, index) in eqlistdata"
  59. :key="index"
  60. @click="eqdetails(item)"
  61. >
  62. <view class="" v-if="side_type == 5">
  63. <image
  64. :src="
  65. item.is_online == 1
  66. ? 'http://www.hnyfwlw.com:8006/bigdata_app/image/prevention/6.png'
  67. : 'http://www.hnyfwlw.com:8006/bigdata_app/image/prevention/7.png'
  68. "
  69. mode=""
  70. class="prevents_item_img"
  71. ></image>
  72. <view class="prevents_item_top">
  73. <p>
  74. 设备名称:{{
  75. item.equip_name == "" ? "环境监测" : item.equip_name
  76. }}
  77. </p>
  78. <p
  79. :class="item.is_online == 1 ? 'green' : 'red'"
  80. v-text="item.is_online == 1 ? '在线' : '离线'"
  81. ></p>
  82. </view>
  83. <view class="prevents_item_bot">
  84. <p>设备 ID:{{ item.equip_id || item.device_id }}</p>
  85. <p>最新上报时间:{{ item.uptime | timeFormat() }}</p>
  86. <view
  87. class=""
  88. style="display: flex; justify-content: space-between"
  89. >
  90. <p>
  91. 设备到期情况:<span
  92. :class="'prevents_item_bot_sapn' + item.device_expire"
  93. >{{ item.device_expiretext }}</span
  94. >
  95. </p>
  96. <p
  97. style="color: #3c84fe"
  98. v-if="item.device_expire != 0"
  99. @click.stop="examine(item)"
  100. >
  101. 查看详情
  102. </p>
  103. </view>
  104. </view>
  105. </view>
  106. <view class="" v-if="side_type == 15">
  107. <image
  108. src="http://www.hnyfwlw.com:8006/bigdata_app/image/prevention/6.png"
  109. mode=""
  110. class="prevents_item_img"
  111. ></image>
  112. <view class="prevents_item_top">
  113. <p>
  114. 设备名称:{{
  115. item.device_name == "" ? "管式墒情" : item.device_name
  116. }}
  117. </p>
  118. </view>
  119. <view class="prevents_item_bot">
  120. <p>设备 ID:{{ item.device_id }}</p>
  121. <p>最新上报时间:{{ item.uptime | timeFormat() }}</p>
  122. </view>
  123. </view>
  124. <view
  125. class=""
  126. v-if="side_type == 11 || side_type == 19 || side_type == 20"
  127. >
  128. <image
  129. src="http://www.hnyfwlw.com:8006/bigdata_app/image/prevention/6.png"
  130. mode=""
  131. class="prevents_item_img"
  132. ></image>
  133. <view class="prevents_item_top">
  134. <p>
  135. 设备名称:{{
  136. item.device_name == "" ? "暂无" : item.device_name
  137. }}
  138. </p>
  139. </view>
  140. <view class="prevents_item_bot">
  141. <p>设备 ID:{{ item.device_id }}</p>
  142. <p>最新上报时间:{{ item.uptime | timeFormat() }}</p>
  143. </view>
  144. </view>
  145. </view>
  146. </view>
  147. </view>
  148. <u-modal
  149. v-model="show"
  150. :title="title"
  151. :showConfirmButton="false"
  152. :title-style="{
  153. 'text-align': 'left',
  154. 'padding-left': '10px',
  155. 'font-weight': 700,
  156. }"
  157. :mask-close-able="true"
  158. >
  159. <view class="slot-content">
  160. <rich-text :nodes="content"></rich-text>
  161. </view>
  162. </u-modal>
  163. <view class="top" v-if="side_type == 5">
  164. <view class="backtop" @click="top" v-if="isTop">
  165. <image src="../../static/images/1.png" mode="" class="img0"></image>
  166. </view>
  167. <view class="more">
  168. <view class="box" @click="online" v-show="filtrateTF">
  169. <p>在线</p>
  170. </view>
  171. <view class="box" @click="offline" v-show="filtrateTF">
  172. <p>离线</p>
  173. </view>
  174. <view class="box" @click="complete" v-show="filtrateTF">
  175. <p>全部</p>
  176. </view>
  177. <view @click="filtrate">
  178. <image
  179. src="../../static/images/b0bcdb0e3fe8690520f743aa8303bf2.png"
  180. mode=""
  181. class="img1"
  182. ></image>
  183. </view>
  184. </view>
  185. </view>
  186. </view>
  187. </template>
  188. <script>
  189. import { Debounce } from "../../util/anitthro.js";
  190. export default {
  191. data() {
  192. return {
  193. diseaseId: 11,
  194. page: 1,
  195. size: 10,
  196. eqlistdata: [],
  197. isTop: false,
  198. filtrateTF: false,
  199. device_status: "",
  200. width: 0, //顶部搜索栏宽度
  201. imports: "", //搜索设备id
  202. loadingtf: false,
  203. equipArr: [
  204. {
  205. name: "环境监测",
  206. type: 5, //5 环境监测 15 管式墒情
  207. list: [],
  208. pageIndex: 1,
  209. tf: false,
  210. },
  211. {
  212. name: "管式墒情",
  213. type: 15, //5 环境监测 15 管式墒情
  214. list: [],
  215. pageIndex: 1,
  216. tf: false,
  217. },
  218. {
  219. name: "小麦赤霉病",
  220. type: 11, //5 环境监测 15 管式墒情 11小麦赤霉病 19玉米大斑病
  221. list: [],
  222. pageIndex: 1,
  223. tf: false,
  224. },
  225. {
  226. name: "玉米大斑病",
  227. type: 19, //5 环境监测 15 管式墒情 11小麦赤霉病 19玉米大斑病
  228. list: [],
  229. pageIndex: 1,
  230. tf: false,
  231. },
  232. {
  233. name: "小麦条锈病",
  234. type: 20, //5 环境监测 15 管式墒情 11小麦赤霉病 19玉米大斑病 20小麦条锈病
  235. list: [],
  236. pageIndex: 1,
  237. tf: false,
  238. },
  239. ],
  240. active: 0, //tab选中的下标
  241. side_type: 5, //当前选中的设备类型
  242. show: false,
  243. title: "",
  244. content: "",
  245. };
  246. },
  247. methods: {
  248. async eqlist() {
  249. //设备列表 环境监测
  250. this.loadingtf = true;
  251. const res = await this.$myRequest({
  252. url: "/api/api_gateway?method=weather.weather.qxz_page",
  253. data: {
  254. page: this.page,
  255. device_status: this.device_status,
  256. page_size: 10,
  257. device_id: this.imports,
  258. },
  259. });
  260. this.loadingtf = false;
  261. this.eqlistdata = this.eqlistdata.concat(res.ids);
  262. for (var i = 0; i < this.eqlistdata.length; i++) {
  263. if (this.eqlistdata[i].device_expire == 0) {
  264. this.eqlistdata[i]["device_expiretext"] = "未到期";
  265. } else if (this.eqlistdata[i].device_expire == 1) {
  266. this.eqlistdata[i]["device_expiretext"] = "已到期";
  267. } else if (this.eqlistdata[i].device_expire == 2) {
  268. this.eqlistdata[i]["device_expiretext"] = "即将到期";
  269. }
  270. }
  271. console.log(res.ids);
  272. },
  273. // weather.weather.nd_qxz_page 管式墒情
  274. async tubulareqlist() {
  275. //设备列表 环境监测
  276. this.loadingtf = true;
  277. const res = await this.$myRequest({
  278. url: "/api/api_gateway?method=weather.weather.nd_qxz_page",
  279. data: {
  280. page: this.page,
  281. device_status: this.device_status,
  282. page_size: 10,
  283. device_id: this.imports,
  284. },
  285. });
  286. this.loadingtf = false;
  287. this.eqlistdata = this.eqlistdata.concat(res.ids);
  288. },
  289. //设备列表 病害
  290. async getEquipList() {
  291. this.loadingtf = true;
  292. const res = await this.$myRequest({
  293. method: "POST",
  294. url: "/api/api_gateway?method=wheat.wheat.wheat_list",
  295. data: {
  296. device_id: "",
  297. device_name: "",
  298. page: this.page,
  299. device_type: this.diseaseId,
  300. },
  301. });
  302. this.loadingtf = false;
  303. this.eqlistdata = this.eqlistdata.concat(res.ids);
  304. },
  305. clickRight() {
  306. this.width = 600;
  307. },
  308. clickLeft() {
  309. uni.switchTab({
  310. url: "../index/index",
  311. });
  312. },
  313. eqdetails(data) {
  314. console.log(data, this.side_type);
  315. if (this.side_type == 5) {
  316. uni.navigateTo({
  317. url: "./equipment?shebei=" + JSON.stringify(data),
  318. });
  319. } else if (this.side_type == 15) {
  320. uni.navigateTo({
  321. url: "./gsequipment?shebei=" + JSON.stringify(data),
  322. });
  323. } else if (this.side_type == 11) {
  324. uni.navigateTo({
  325. url: "../disease/cmb?shebei=" + JSON.stringify(data),
  326. });
  327. } else if (this.side_type == 19) {
  328. uni.navigateTo({
  329. url: "../disease/cmb?shebei=" + JSON.stringify(data),
  330. });
  331. } else if (this.side_type == 20) {
  332. uni.navigateTo({
  333. url: "../disease/cmb?shebei=" + JSON.stringify(data),
  334. });
  335. }
  336. },
  337. filtrate() {
  338. this.filtrateTF = !this.filtrateTF;
  339. },
  340. top() {
  341. uni.pageScrollTo({
  342. scrollTop: 0,
  343. duration: 500,
  344. });
  345. },
  346. online() {
  347. this.eqlistdata = [];
  348. this.page = 1;
  349. this.device_status = 1;
  350. this.eqlist();
  351. this.filtrateTF = !this.filtrateTF;
  352. },
  353. offline() {
  354. this.eqlistdata = [];
  355. this.page = 1;
  356. this.device_status = 0;
  357. this.eqlist();
  358. this.filtrateTF = !this.filtrateTF;
  359. },
  360. complete() {
  361. this.eqlistdata = [];
  362. this.page = 1;
  363. this.device_status = "";
  364. this.eqlist();
  365. this.filtrateTF = !this.filtrateTF;
  366. },
  367. search() {
  368. //搜索按钮搜索
  369. this.searchinp();
  370. },
  371. searchinp() {
  372. //自动搜索
  373. Debounce(() => {
  374. this.page = 1;
  375. if (this.side_type == 5) {
  376. this.eqlistdata = [];
  377. this.eqlist();
  378. } else if (this.side_type == 15) {
  379. this.eqlistdata = [];
  380. this.tubulareqlist();
  381. }
  382. }, 1000)();
  383. },
  384. tabClick(index, type) {
  385. this.active = index;
  386. this.side_type = type;
  387. this.page = 1;
  388. if (type == 5) {
  389. this.eqlistdata = [];
  390. this.eqlist();
  391. } else if (type == 15) {
  392. this.eqlistdata = [];
  393. this.tubulareqlist();
  394. } else if (type == 11) {
  395. this.eqlistdata = [];
  396. this.getEquipList();
  397. } else if (type == 19) {
  398. this.diseaseId = type;
  399. this.eqlistdata = [];
  400. this.getEquipList();
  401. } else if (type == 20) {
  402. this.diseaseId = type;
  403. this.eqlistdata = [];
  404. this.getEquipList();
  405. }
  406. },
  407. examine(e) {
  408. // console.log(this)
  409. this.show = true;
  410. this.title = e.device_expiretext;
  411. this.content = `<p style="padding-left:10px;margin:10px 0;font-size:14px;">到期时间 ${this.timezhuan(
  412. e.device_expire_time
  413. )}
  414. </p><p style="font-size:14px;text-align:right;color:#3C84FE;margin-bottom:10px;padding-right:10px">注:请前往PC端进行充值</p>`;
  415. },
  416. timezhuan(time) {
  417. function fun(a) {
  418. return String(a).length == 1 ? "0" + a : a;
  419. }
  420. let date = new Date(time * 1000);
  421. let y = date.getFullYear();
  422. let m = date.getMonth() + 1;
  423. let d = date.getDate();
  424. let h = date.getHours();
  425. let min = date.getMinutes();
  426. let sec = date.getSeconds();
  427. return `${y}-${fun(m)}-${fun(d)} ${fun(h)}:${fun(min)}:${fun(sec)}`;
  428. },
  429. },
  430. onLoad() {
  431. this.eqlist();
  432. uni.getStorage({
  433. key: "jurisdiction",
  434. success: (res) => {
  435. let items = JSON.parse(res.data).filter((item) => {
  436. return item.purview_name == "环境监测系统";
  437. });
  438. var itemarr = items[0].children;
  439. console.log(itemarr);
  440. for (var i = 0; i < itemarr.length; i++) {
  441. switch (itemarr[i].purview_name) {
  442. case "环境监测":
  443. this.equipArr[0].tf = true;
  444. break;
  445. case "管式墒情":
  446. this.equipArr[1].tf = true;
  447. break;
  448. case "小麦赤霉病":
  449. this.equipArr[2].tf = true;
  450. break;
  451. case "玉米大斑病":
  452. this.equipArr[3].tf = true;
  453. break;
  454. case "小麦条锈病":
  455. this.equipArr[4].tf = true;
  456. break;
  457. }
  458. }
  459. },
  460. });
  461. },
  462. onReachBottom() {
  463. this.page++;
  464. this.eqlist();
  465. },
  466. onPageScroll(e) {
  467. //nvue暂不支持滚动监听,可用bindingx代替
  468. if (e.scrollTop > 200) {
  469. //距离大于200时显示
  470. this.isTop = true;
  471. } else {
  472. //距离小于200时隐藏
  473. this.isTop = false;
  474. }
  475. },
  476. };
  477. </script>
  478. <style lang="scss">
  479. page {
  480. background: $uni-bg-color-grey;
  481. }
  482. .inputs {
  483. height: 54rpx;
  484. background-color: #e4e4e4;
  485. border-radius: 27rpx;
  486. position: absolute;
  487. right: 20rpx;
  488. top: 20rpx;
  489. transition: width 0.5s;
  490. overflow: hidden;
  491. padding-top: 8rpx;
  492. box-sizing: border-box;
  493. .inputbox {
  494. width: 85%;
  495. text-indent: 1rem;
  496. font-size: 26rpx;
  497. }
  498. .icon {
  499. position: absolute;
  500. top: 8rpx;
  501. right: 26rpx;
  502. }
  503. }
  504. /deep/.uni-icons {
  505. font-size: 40rpx !important;
  506. }
  507. .image {
  508. position: fixed;
  509. top: 84px;
  510. width: 100%;
  511. height: 160rpx;
  512. z-index: 555;
  513. }
  514. .loading {
  515. position: fixed;
  516. top: 440px;
  517. width: 95%;
  518. left: 2.5%;
  519. text-align: center;
  520. z-index: 9;
  521. .img {
  522. width: 300rpx;
  523. height: 40rpx;
  524. }
  525. }
  526. .tab-box {
  527. position: fixed;
  528. top: 170px;
  529. display: flex;
  530. justify-content: space-around;
  531. font-size: 30rpx;
  532. line-height: 80rpx;
  533. background-color: #ffffff;
  534. width: 100%;
  535. z-index: 2;
  536. .tab-item {
  537. cursor: pointer;
  538. position: relative;
  539. }
  540. .tab-item.active {
  541. .bottom-line {
  542. bottom: 0;
  543. position: absolute;
  544. display: inline-block;
  545. width: 90rpx;
  546. height: 6rpx;
  547. left: 0;
  548. right: 0;
  549. margin: auto;
  550. background: $uni-color-success;
  551. }
  552. }
  553. }
  554. .prevents {
  555. width: 100%;
  556. position: absolute;
  557. top: 180px;
  558. .prevents_item {
  559. width: 95%;
  560. margin: 0 auto 30rpx;
  561. border-radius: 10rpx;
  562. box-shadow: 0 0 10rpx #bcb9ca;
  563. padding: 20rpx 40rpx 20rpx 80rpx;
  564. box-sizing: border-box;
  565. position: relative;
  566. background-color: #fff;
  567. .prevents_item_img {
  568. width: 30rpx;
  569. height: 50rpx;
  570. position: absolute;
  571. top: -4rpx;
  572. left: 30rpx;
  573. }
  574. .prevents_item_top {
  575. display: flex;
  576. justify-content: space-between;
  577. height: 60rpx;
  578. border-bottom: 2rpx solid #f4f4f4;
  579. line-height: 60rpx;
  580. font-size: 26rpx;
  581. .red {
  582. color: #ff0000;
  583. }
  584. .green {
  585. color: #7dbb91;
  586. }
  587. }
  588. .prevents_item_bot {
  589. margin-top: 20rpx;
  590. font-size: 26rpx;
  591. color: #bdbdbd;
  592. .prevents_item_bot_sapn0 {
  593. color: #00b075;
  594. }
  595. .prevents_item_bot_sapn1 {
  596. color: #ff4747;
  597. }
  598. .prevents_item_bot_sapn2 {
  599. color: #ffab00;
  600. }
  601. }
  602. }
  603. }
  604. .top {
  605. position: fixed;
  606. right: 10px;
  607. bottom: 40px;
  608. z-index: 100;
  609. image {
  610. width: 100rpx;
  611. height: 100rpx;
  612. }
  613. .backtop {
  614. display: flex;
  615. justify-content: flex-end;
  616. margin-bottom: 10rpx;
  617. }
  618. .more {
  619. display: flex;
  620. }
  621. .box {
  622. width: 80rpx;
  623. height: 80rpx;
  624. background-color: rgba(161, 161, 161, 0.45);
  625. border-radius: 50%;
  626. text-align: center;
  627. line-height: 80rpx;
  628. box-sizing: border-box;
  629. margin: 14rpx 10rpx 0 0;
  630. color: #fff;
  631. }
  632. }
  633. </style>