index.vue 15 KB

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