index.vue 18 KB

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