index.vue 16 KB

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