index.vue 15 KB

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