index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640
  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) + "&type=11",
  262. });
  263. } else if (this.side_type == 19) {
  264. uni.navigateTo({
  265. url: "../disease/cmb?shebei=" + JSON.stringify(data) + "&type=19",
  266. });
  267. } else if (this.side_type == 20) {
  268. uni.navigateTo({
  269. url: "../disease/cmb?shebei=" + JSON.stringify(data) + "&type=20",
  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. console.log("ress")
  329. this.active = index;
  330. this.side_type = type;
  331. this.page = 1;
  332. if (type == 5) {
  333. this.eqlistdata = [];
  334. this.eqlist();
  335. } else if (type == 15) {
  336. this.eqlistdata = [];
  337. this.tubulareqlist();
  338. } else if (type == 11) {
  339. this.diseaseId = type;
  340. this.eqlistdata = [];
  341. this.getEquipList();
  342. } else if (type == 19) {
  343. this.diseaseId = type;
  344. this.eqlistdata = [];
  345. this.getEquipList();
  346. } else if (type == 20) {
  347. this.diseaseId = type;
  348. this.eqlistdata = [];
  349. this.getEquipList();
  350. }
  351. },
  352. examine(e) {
  353. // console.log(this)
  354. this.show = true;
  355. this.title = e.device_expiretext;
  356. this.content =
  357. `<p style="padding-left:10px;margin:10px 0;font-size:14px;">到期时间 ${this.timezhuan(
  358. e.device_expire_time
  359. )}
  360. </p><p style="font-size:14px;text-align:right;color:#3C84FE;margin-bottom:10px;padding-right:10px">注:请前往PC端进行充值</p>`;
  361. },
  362. timezhuan(time) {
  363. function fun(a) {
  364. return String(a).length == 1 ? "0" + a : a;
  365. }
  366. let date = new Date(time * 1000);
  367. let y = date.getFullYear();
  368. let m = date.getMonth() + 1;
  369. let d = date.getDate();
  370. let h = date.getHours();
  371. let min = date.getMinutes();
  372. let sec = date.getSeconds();
  373. return `${y}-${fun(m)}-${fun(d)} ${fun(h)}:${fun(min)}:${fun(sec)}`;
  374. },
  375. },
  376. onLoad() {
  377. // this.eqlist();
  378. uni.getStorage({
  379. key: "jurisdiction",
  380. success: (res) => {
  381. let items = JSON.parse(res.data).filter((item) => {
  382. return item.pur_id == 40;
  383. });
  384. var itemarr = items[0].children;
  385. console.log(itemarr);
  386. for (var i = 0; i < itemarr.length; i++) {
  387. switch (itemarr[i].pur_id) {
  388. case 41:
  389. this.equipArr[0].tf = true;
  390. break;
  391. case 170:
  392. this.equipArr[1].tf = true;
  393. break;
  394. case 218:
  395. this.equipArr[2].tf = true;
  396. break;
  397. case 219:
  398. this.equipArr[3].tf = true;
  399. break;
  400. case 220:
  401. this.equipArr[4].tf = true;
  402. break;
  403. }
  404. }
  405. for (var i = 0; i < this.equipArr.length; i++) {
  406. if (this.equipArr[i].tf) {
  407. if (i == 0) {
  408. this.eqlist();
  409. } else if (i == 1) {
  410. this.tubulareqlist();
  411. } else {
  412. this.getEquipList();
  413. }
  414. this.active = i
  415. this.side_type = this.equipArr[i].type
  416. break
  417. }
  418. }
  419. },
  420. });
  421. },
  422. onReachBottom() {
  423. this.page++;
  424. if (this.side_type == 5) {
  425. this.eqlist();
  426. } else if (this.side_type == 15) {
  427. this.tubulareqlist();
  428. } else if (
  429. this.side_type == 11 ||
  430. this.side_type == 19 ||
  431. this.side_type == 20
  432. ) {
  433. this.getEquipList();
  434. }
  435. },
  436. onPageScroll(e) {
  437. //nvue暂不支持滚动监听,可用bindingx代替
  438. if (e.scrollTop > 200) {
  439. //距离大于200时显示
  440. this.isTop = true;
  441. } else {
  442. //距离小于200时隐藏
  443. this.isTop = false;
  444. }
  445. },
  446. };
  447. </script>
  448. <style lang="scss">
  449. page {
  450. background: $uni-bg-color-grey;
  451. }
  452. .inputs {
  453. height: 54rpx;
  454. background-color: #e4e4e4;
  455. border-radius: 27rpx;
  456. position: absolute;
  457. right: 20rpx;
  458. top: 20rpx;
  459. transition: width 0.5s;
  460. overflow: hidden;
  461. padding-top: 8rpx;
  462. box-sizing: border-box;
  463. .inputbox {
  464. width: 85%;
  465. text-indent: 1rem;
  466. font-size: 26rpx;
  467. }
  468. .icon {
  469. position: absolute;
  470. top: 8rpx;
  471. right: 26rpx;
  472. }
  473. }
  474. /deep/.uni-icons {
  475. font-size: 40rpx !important;
  476. }
  477. .image {
  478. position: fixed;
  479. top: 84px;
  480. width: 100%;
  481. height: 160rpx;
  482. z-index: 555;
  483. }
  484. .loading {
  485. position: fixed;
  486. top: 440px;
  487. width: 95%;
  488. left: 2.5%;
  489. text-align: center;
  490. z-index: 9;
  491. .img {
  492. width: 300rpx;
  493. height: 40rpx;
  494. }
  495. }
  496. .tab-box::-webkit-scrollbar {
  497. display: none;
  498. }
  499. .tab-box {
  500. position: fixed;
  501. top: 170px;
  502. // display: flex;
  503. // justify-content: space-around;
  504. font-size: 30rpx;
  505. line-height: 80rpx;
  506. background-color: #ffffff;
  507. width: 100%;
  508. z-index: 2;
  509. overflow: hidden;
  510. overflow-x: scroll;
  511. white-space: nowrap;
  512. .tab-item {
  513. cursor: pointer;
  514. position: relative;
  515. width: 25%;
  516. text-align: center;
  517. display: inline-block;
  518. }
  519. .tab-item.active {
  520. .bottom-line {
  521. bottom: 0;
  522. position: absolute;
  523. display: inline-block;
  524. width: 90rpx;
  525. height: 6rpx;
  526. left: 0;
  527. right: 0;
  528. margin: auto;
  529. background: $uni-color-success;
  530. }
  531. }
  532. }
  533. .prevents {
  534. width: 100%;
  535. position: absolute;
  536. top: 180px;
  537. .prevents_item {
  538. width: 95%;
  539. margin: 0 auto 30rpx;
  540. border-radius: 10rpx;
  541. box-shadow: 0 0 10rpx #bcb9ca;
  542. padding: 20rpx 40rpx 20rpx 80rpx;
  543. box-sizing: border-box;
  544. position: relative;
  545. background-color: #fff;
  546. .prevents_item_img {
  547. width: 30rpx;
  548. height: 50rpx;
  549. position: absolute;
  550. top: -4rpx;
  551. left: 30rpx;
  552. }
  553. .prevents_item_top {
  554. display: flex;
  555. justify-content: space-between;
  556. height: 60rpx;
  557. border-bottom: 2rpx solid #f4f4f4;
  558. line-height: 60rpx;
  559. font-size: 26rpx;
  560. .red {
  561. color: #ff0000;
  562. }
  563. .green {
  564. color: #7dbb91;
  565. }
  566. }
  567. .prevents_item_bot {
  568. margin-top: 20rpx;
  569. font-size: 26rpx;
  570. color: #bdbdbd;
  571. .prevents_item_bot_sapn0 {
  572. color: #00b075;
  573. }
  574. .prevents_item_bot_sapn1 {
  575. color: #ff4747;
  576. }
  577. .prevents_item_bot_sapn2 {
  578. color: #ffab00;
  579. }
  580. }
  581. }
  582. }
  583. .top {
  584. position: fixed;
  585. right: 10px;
  586. bottom: 40px;
  587. z-index: 100;
  588. image {
  589. width: 100rpx;
  590. height: 100rpx;
  591. }
  592. .backtop {
  593. display: flex;
  594. justify-content: flex-end;
  595. margin-bottom: 10rpx;
  596. }
  597. .more {
  598. display: flex;
  599. }
  600. .box {
  601. width: 80rpx;
  602. height: 80rpx;
  603. background-color: rgba(161, 161, 161, 0.45);
  604. border-radius: 50%;
  605. text-align: center;
  606. line-height: 80rpx;
  607. box-sizing: border-box;
  608. margin: 14rpx 10rpx 0 0;
  609. color: #fff;
  610. }
  611. }
  612. </style>