index.vue 16 KB

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