index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  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. console.log("搜素字段s", this.imports);
  250. //设备列表 环境监测
  251. this.loadingtf = true;
  252. const res = await this.$myRequest({
  253. url: "/api/api_gateway?method=weather.weather.qxz_page",
  254. data: {
  255. page: this.page,
  256. device_status: this.device_status,
  257. page_size: 10,
  258. device_id: this.imports,
  259. },
  260. });
  261. this.loadingtf = false;
  262. this.eqlistdata = this.eqlistdata.concat(res.ids);
  263. for (var i = 0; i < this.eqlistdata.length; i++) {
  264. if (this.eqlistdata[i].device_expire == 0) {
  265. this.eqlistdata[i]["device_expiretext"] = "未到期";
  266. } else if (this.eqlistdata[i].device_expire == 1) {
  267. this.eqlistdata[i]["device_expiretext"] = "已到期";
  268. } else if (this.eqlistdata[i].device_expire == 2) {
  269. this.eqlistdata[i]["device_expiretext"] = "即将到期";
  270. }
  271. }
  272. console.log(res.ids);
  273. },
  274. // weather.weather.nd_qxz_page 管式墒情
  275. async tubulareqlist() {
  276. //设备列表 环境监测
  277. this.loadingtf = true;
  278. const res = await this.$myRequest({
  279. url: "/api/api_gateway?method=weather.weather.nd_qxz_page",
  280. data: {
  281. page: this.page,
  282. device_status: this.device_status,
  283. page_size: 10,
  284. device_id: this.imports,
  285. },
  286. });
  287. this.loadingtf = false;
  288. this.eqlistdata = this.eqlistdata.concat(res.ids);
  289. },
  290. //设备列表 病害
  291. async getEquipList() {
  292. this.loadingtf = true;
  293. const res = await this.$myRequest({
  294. method: "POST",
  295. url: "/api/api_gateway?method=wheat.wheat.wheat_list",
  296. data: {
  297. device_id: this.imports,
  298. device_name: "",
  299. page: this.page,
  300. device_type: this.diseaseId,
  301. },
  302. });
  303. this.loadingtf = false;
  304. this.eqlistdata = this.eqlistdata.concat(res.ids);
  305. },
  306. clickRight() {
  307. this.width = 600;
  308. },
  309. clickLeft() {
  310. uni.switchTab({
  311. url: "../index/index",
  312. });
  313. },
  314. eqdetails(data) {
  315. console.log(data, this.side_type);
  316. if (this.side_type == 5) {
  317. uni.navigateTo({
  318. url: "./equipment?shebei=" + JSON.stringify(data),
  319. });
  320. } else if (this.side_type == 15) {
  321. uni.navigateTo({
  322. url: "./gsequipment?shebei=" + JSON.stringify(data),
  323. });
  324. } else if (this.side_type == 11) {
  325. uni.navigateTo({
  326. url: "../disease/cmb?shebei=" + JSON.stringify(data),
  327. });
  328. } else if (this.side_type == 19) {
  329. uni.navigateTo({
  330. url: "../disease/cmb?shebei=" + JSON.stringify(data),
  331. });
  332. } else if (this.side_type == 20) {
  333. uni.navigateTo({
  334. url: "../disease/cmb?shebei=" + JSON.stringify(data),
  335. });
  336. }
  337. },
  338. filtrate() {
  339. this.filtrateTF = !this.filtrateTF;
  340. },
  341. top() {
  342. uni.pageScrollTo({
  343. scrollTop: 0,
  344. duration: 500,
  345. });
  346. },
  347. online() {
  348. this.eqlistdata = [];
  349. this.page = 1;
  350. this.device_status = 1;
  351. this.eqlist();
  352. this.filtrateTF = !this.filtrateTF;
  353. },
  354. offline() {
  355. this.eqlistdata = [];
  356. this.page = 1;
  357. this.device_status = 0;
  358. this.eqlist();
  359. this.filtrateTF = !this.filtrateTF;
  360. },
  361. complete() {
  362. this.eqlistdata = [];
  363. this.page = 1;
  364. this.device_status = "";
  365. this.eqlist();
  366. this.filtrateTF = !this.filtrateTF;
  367. },
  368. search() {
  369. //搜索按钮搜索
  370. this.searchinp();
  371. },
  372. searchinp() {
  373. //自动搜索
  374. Debounce(() => {
  375. this.page = 1;
  376. if (this.side_type == 5) {
  377. this.eqlistdata = [];
  378. this.eqlist();
  379. } else if (this.side_type == 15) {
  380. this.eqlistdata = [];
  381. this.tubulareqlist();
  382. } else if (
  383. this.side_type == 11 ||
  384. this.side_type == 19 ||
  385. this.side_type == 20
  386. ) {
  387. this.eqlistdata = [];
  388. this.getEquipList();
  389. }
  390. }, 1000)();
  391. },
  392. tabClick(index, type) {
  393. this.active = index;
  394. this.side_type = type;
  395. this.page = 1;
  396. if (type == 5) {
  397. this.eqlistdata = [];
  398. this.eqlist();
  399. } else if (type == 15) {
  400. this.eqlistdata = [];
  401. this.tubulareqlist();
  402. } else if (type == 11) {
  403. this.eqlistdata = [];
  404. this.getEquipList();
  405. } else if (type == 19) {
  406. this.diseaseId = type;
  407. this.eqlistdata = [];
  408. this.getEquipList();
  409. } else if (type == 20) {
  410. this.diseaseId = type;
  411. this.eqlistdata = [];
  412. this.getEquipList();
  413. }
  414. },
  415. examine(e) {
  416. // console.log(this)
  417. this.show = true;
  418. this.title = e.device_expiretext;
  419. this.content = `<p style="padding-left:10px;margin:10px 0;font-size:14px;">到期时间 ${this.timezhuan(
  420. e.device_expire_time
  421. )}
  422. </p><p style="font-size:14px;text-align:right;color:#3C84FE;margin-bottom:10px;padding-right:10px">注:请前往PC端进行充值</p>`;
  423. },
  424. timezhuan(time) {
  425. function fun(a) {
  426. return String(a).length == 1 ? "0" + a : a;
  427. }
  428. let date = new Date(time * 1000);
  429. let y = date.getFullYear();
  430. let m = date.getMonth() + 1;
  431. let d = date.getDate();
  432. let h = date.getHours();
  433. let min = date.getMinutes();
  434. let sec = date.getSeconds();
  435. return `${y}-${fun(m)}-${fun(d)} ${fun(h)}:${fun(min)}:${fun(sec)}`;
  436. },
  437. },
  438. onLoad() {
  439. this.eqlist();
  440. uni.getStorage({
  441. key: "jurisdiction",
  442. success: (res) => {
  443. let items = JSON.parse(res.data).filter((item) => {
  444. return item.purview_name == "环境监测系统";
  445. });
  446. var itemarr = items[0].children;
  447. console.log(itemarr);
  448. for (var i = 0; i < itemarr.length; i++) {
  449. switch (itemarr[i].purview_name) {
  450. case "环境监测":
  451. this.equipArr[0].tf = true;
  452. break;
  453. case "管式墒情":
  454. this.equipArr[1].tf = true;
  455. break;
  456. case "小麦赤霉病":
  457. this.equipArr[2].tf = true;
  458. break;
  459. case "玉米大斑病":
  460. this.equipArr[3].tf = true;
  461. break;
  462. case "小麦条锈病":
  463. this.equipArr[4].tf = true;
  464. break;
  465. }
  466. }
  467. },
  468. });
  469. },
  470. onReachBottom() {
  471. this.page++;
  472. this.eqlist();
  473. },
  474. onPageScroll(e) {
  475. //nvue暂不支持滚动监听,可用bindingx代替
  476. if (e.scrollTop > 200) {
  477. //距离大于200时显示
  478. this.isTop = true;
  479. } else {
  480. //距离小于200时隐藏
  481. this.isTop = false;
  482. }
  483. },
  484. };
  485. </script>
  486. <style lang="scss">
  487. page {
  488. background: $uni-bg-color-grey;
  489. }
  490. .inputs {
  491. height: 54rpx;
  492. background-color: #e4e4e4;
  493. border-radius: 27rpx;
  494. position: absolute;
  495. right: 20rpx;
  496. top: 20rpx;
  497. transition: width 0.5s;
  498. overflow: hidden;
  499. padding-top: 8rpx;
  500. box-sizing: border-box;
  501. .inputbox {
  502. width: 85%;
  503. text-indent: 1rem;
  504. font-size: 26rpx;
  505. }
  506. .icon {
  507. position: absolute;
  508. top: 8rpx;
  509. right: 26rpx;
  510. }
  511. }
  512. /deep/.uni-icons {
  513. font-size: 40rpx !important;
  514. }
  515. .image {
  516. position: fixed;
  517. top: 84px;
  518. width: 100%;
  519. height: 160rpx;
  520. z-index: 555;
  521. }
  522. .loading {
  523. position: fixed;
  524. top: 440px;
  525. width: 95%;
  526. left: 2.5%;
  527. text-align: center;
  528. z-index: 9;
  529. .img {
  530. width: 300rpx;
  531. height: 40rpx;
  532. }
  533. }
  534. .tab-box::-webkit-scrollbar {
  535. display: none;
  536. }
  537. .tab-box {
  538. position: fixed;
  539. top: 170px;
  540. // display: flex;
  541. // justify-content: space-around;
  542. font-size: 30rpx;
  543. line-height: 80rpx;
  544. background-color: #ffffff;
  545. width: 100%;
  546. z-index: 2;
  547. overflow: hidden;
  548. overflow-x: scroll;
  549. white-space: nowrap;
  550. .tab-item {
  551. cursor: pointer;
  552. position: relative;
  553. width: 25%;
  554. text-align: center;
  555. display: inline-block;
  556. }
  557. .tab-item.active {
  558. .bottom-line {
  559. bottom: 0;
  560. position: absolute;
  561. display: inline-block;
  562. width: 90rpx;
  563. height: 6rpx;
  564. left: 0;
  565. right: 0;
  566. margin: auto;
  567. background: $uni-color-success;
  568. }
  569. }
  570. }
  571. .prevents {
  572. width: 100%;
  573. position: absolute;
  574. top: 180px;
  575. .prevents_item {
  576. width: 95%;
  577. margin: 0 auto 30rpx;
  578. border-radius: 10rpx;
  579. box-shadow: 0 0 10rpx #bcb9ca;
  580. padding: 20rpx 40rpx 20rpx 80rpx;
  581. box-sizing: border-box;
  582. position: relative;
  583. background-color: #fff;
  584. .prevents_item_img {
  585. width: 30rpx;
  586. height: 50rpx;
  587. position: absolute;
  588. top: -4rpx;
  589. left: 30rpx;
  590. }
  591. .prevents_item_top {
  592. display: flex;
  593. justify-content: space-between;
  594. height: 60rpx;
  595. border-bottom: 2rpx solid #f4f4f4;
  596. line-height: 60rpx;
  597. font-size: 26rpx;
  598. .red {
  599. color: #ff0000;
  600. }
  601. .green {
  602. color: #7dbb91;
  603. }
  604. }
  605. .prevents_item_bot {
  606. margin-top: 20rpx;
  607. font-size: 26rpx;
  608. color: #bdbdbd;
  609. .prevents_item_bot_sapn0 {
  610. color: #00b075;
  611. }
  612. .prevents_item_bot_sapn1 {
  613. color: #ff4747;
  614. }
  615. .prevents_item_bot_sapn2 {
  616. color: #ffab00;
  617. }
  618. }
  619. }
  620. }
  621. .top {
  622. position: fixed;
  623. right: 10px;
  624. bottom: 40px;
  625. z-index: 100;
  626. image {
  627. width: 100rpx;
  628. height: 100rpx;
  629. }
  630. .backtop {
  631. display: flex;
  632. justify-content: flex-end;
  633. margin-bottom: 10rpx;
  634. }
  635. .more {
  636. display: flex;
  637. }
  638. .box {
  639. width: 80rpx;
  640. height: 80rpx;
  641. background-color: rgba(161, 161, 161, 0.45);
  642. border-radius: 50%;
  643. text-align: center;
  644. line-height: 80rpx;
  645. box-sizing: border-box;
  646. margin: 14rpx 10rpx 0 0;
  647. color: #fff;
  648. }
  649. }
  650. </style>