index.vue 15 KB

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