index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  1. <template>
  2. <view class="">
  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="返回"
  7. ></uni-nav-bar>
  8. <view class="bases_search">
  9. <view class="bases_search_text" @click="clickRight">
  10. <u-icon name="search" class="search" @click="search"></u-icon>
  11. <input type="text" v-model="data.search" placeholder="设备ID搜索" @input="searchinput" disabled/>
  12. </view>
  13. </view>
  14. <view>
  15. <image :src="'https://www.hnyfwlw.com:8006/bigdata_app'+'/image/cb/banner.jpg'" mode="widthFix"></image>
  16. </view>
  17. <view class="tab-box">
  18. <view v-for="(item,index) in equipArr" :key="item.type" v-if="item.tf" @click="tabClick(index)" :class="['tab-item',active==index?'active':'']">
  19. <text>{{item.name}}</text>
  20. <text class="bottom-line"></text>
  21. </view>
  22. </view>
  23. </view>
  24. <view class="loading" v-if="loadingtf">
  25. <image src="../../../static/images/ajax-loader.gif" mode="" class="img"></image>
  26. </view>
  27. <view class="" style="position: absolute;top: 190px;width: 100%;">
  28. <view class="content">
  29. <template v-for="(item,index) in equipArr[active].list">
  30. <equipItem @click.native="itemClick(item)" v-bind:item="item" :key="index">
  31. <view class="date">
  32. <p>设备ID:{{item.imei||item.device_id}}</p>
  33. <p>最新上报时间:{{item.addtime|timeFormat}}</p>
  34. <view class="" style="display: flex;justify-content: space-between;" v-if="(device_type == 3 || device_type==7) && $QueryPermission(325)">
  35. <p>设备到期情况:<span
  36. :class="'prevents_item_bot_sapn'+item.device_expire">{{item.device_expiretext}}</span>
  37. </p>
  38. <p style="color: #3C84FE;" v-if="item.device_expire!=0" @click.stop="examine(item)">查看详情</p>
  39. </view>
  40. </view>
  41. </equipItem>
  42. </template>
  43. </view>
  44. </view>
  45. </view>
  46. <u-modal v-model="show" :title="title" :showConfirmButton="false" :title-style="{'text-align':'left','padding-left':'10px','font-weight':700}" :mask-close-able="true">
  47. <view class="slot-content">
  48. <rich-text :nodes="content"></rich-text>
  49. </view>
  50. </u-modal>
  51. <view class="top">
  52. <view class="backtop" @click="top" v-if="isTop">
  53. <image src="../../../static/images/1.png" mode="" class="img0"></image>
  54. </view>
  55. <view class="more">
  56. <view class="box" @click="online" v-show="filtrateTF">
  57. <p>在线</p>
  58. </view>
  59. <view class="box" @click="offline" v-show="filtrateTF">
  60. <p>离线</p>
  61. </view>
  62. <view class="box" @click="complete" v-show="filtrateTF">
  63. <p>全部</p>
  64. </view>
  65. <view @click="filtrate">
  66. <image src="../../../static/images/b0bcdb0e3fe8690520f743aa8303bf2.png" mode="" class="img1"></image>
  67. </view>
  68. </view>
  69. </view>
  70. </view>
  71. </template>
  72. <script>
  73. import equipItem from "../../../components/equip-item/equip-item"
  74. import uniNavBar from "@/components/uni-nav-bar/uni-nav-bar.vue"
  75. export default {
  76. data() {
  77. return {
  78. active: 0, //默认选中虫情测报
  79. equipArr: [{
  80. name: '虫情测报',
  81. type: 3, //3虫情测报灯 7孢子仪 4智能性诱
  82. list: [],
  83. pageIndex: 1,
  84. tf:false,
  85. }, {
  86. name: '孢子仪',
  87. type: 7, //3虫情测报灯 7孢子仪 4智能性诱
  88. list: [],
  89. pageIndex: 1,
  90. tf:false,
  91. }, {
  92. name: '性诱测报',
  93. type: 4, //3虫情测报灯 7孢子仪 4智能性诱
  94. list: [],
  95. pageIndex: 1,
  96. tf:false,
  97. device_model: 1
  98. },
  99. {
  100. name: '性诱2.0',
  101. type: 10, //3虫情测报灯 7孢子仪 4智能性诱 性诱2.0
  102. list: [],
  103. pageIndex: 1,
  104. tf:false
  105. },
  106. {
  107. name: '性诱3.0',
  108. type: 8, //3虫情测报灯 7孢子仪 4智能性诱 性诱2.0
  109. list: [],
  110. pageIndex: 1,
  111. tf: false
  112. }, {
  113. name: '吸虫塔',
  114. type: 12, //3虫情测报灯 7孢子仪 4智能性诱 性诱2.0
  115. list: [],
  116. pageIndex: 1,
  117. tf: false
  118. }, {
  119. name: '病虫害可视监测',
  120. type: 14, //3虫情测报灯 7孢子仪 4智能性诱 性诱2.0
  121. list: [],
  122. pageIndex: 1,
  123. tf: false
  124. }
  125. ],
  126. device_id: '3', //筛选的设备id
  127. isTop: false,
  128. filtrateTF:false,
  129. device_status:"",
  130. loadingtf:false,//设备列表加载中
  131. device_type:"3",
  132. show: false,
  133. title: "",
  134. content: "",
  135. }
  136. },
  137. onLoad() {
  138. uni.getStorage({
  139. key:"jurisdiction",
  140. success:(res)=>{
  141. let items = JSON.parse(res.data).filter((item) => {
  142. return item.pur_id == 36
  143. })
  144. var arr = items[0].children
  145. for (var i = 0; i < arr.length; i++) {
  146. switch (arr[i].pur_id) {
  147. case 37:
  148. this.equipArr[0].tf = true //"虫情测报灯"
  149. this.getEquipList(0)
  150. break
  151. case 38:
  152. this.equipArr[2].tf = true //"性诱测报"
  153. this.getEquipList(2)
  154. break
  155. case 39:
  156. this.equipArr[1].tf = true //"孢子仪"
  157. this.getEquipList(1)
  158. break
  159. case 161:
  160. this.equipArr[3].tf = true //"性诱2.0"
  161. this.getxyEquipList(3)
  162. break
  163. case 198:
  164. this.equipArr[4].tf = true //"性诱2.0"
  165. this.getthxyEquipList(4)
  166. break
  167. case 171:
  168. this.equipArr[5].tf = true //"性诱3.0"
  169. this.getxctEquipList(5)
  170. break
  171. case 167:
  172. this.equipArr[6].tf = true //"性诱3.0"
  173. this.getEquipList(6)
  174. break
  175. }
  176. }
  177. for(var i=0;i<this.equipArr.length;i++){
  178. if(this.equipArr[i].tf){
  179. this.active = i
  180. this.device_type = this.equipArr[i].type
  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(this.active)
  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_model: this.equipArr[act].device_model ? this.equipArr[act].device_model:0
  250. }
  251. })
  252. this.loadingtf =false
  253. console.log(res)
  254. this.equipArr[act].list = [...this.equipArr[act].list, ...res.data]
  255. for (var i = 0; i < this.equipArr[act].list.length; i++) {
  256. if (this.equipArr[act].list[i].device_expire == 0) {
  257. this.equipArr[act].list[i]['device_expiretext'] = "未到期"
  258. } else if (this.equipArr[act].list[i].device_expire == 1) {
  259. this.equipArr[act].list[i]['device_expiretext'] = "已到期"
  260. } else if (this.equipArr[act].list[i].device_expire == 2) {
  261. this.equipArr[act].list[i]['device_expiretext'] = "即将到期"
  262. }
  263. }
  264. console.log(this.equipArr[act].list)
  265. },
  266. async getxyEquipList(act) {
  267. this.loadingtf = true
  268. const res = await this.$myRequest({
  269. url: '/api/api_gateway?method=sex_lure_nl.sex_lure.nl_device_list',
  270. data: {
  271. device_type_id: this.equipArr[act].type,
  272. page: this.equipArr[act].pageIndex,
  273. page_size: 10,
  274. device_status:this.device_status
  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. }
  292. })
  293. this.loadingtf = false
  294. console.log(res)
  295. this.equipArr[act].list = [...this.equipArr[act].list, ...res.data]
  296. console.log(this.equipArr[act].list)
  297. },
  298. async getxctEquipList(act) {
  299. this.loadingtf = true
  300. const res = await this.$myRequest({
  301. url: '/api/api_gateway?method=forecast.worm_lamp.xct_list',
  302. data: {
  303. device_type_id: this.equipArr[act].type,
  304. page: this.equipArr[act].pageIndex,
  305. page_size: 10,
  306. device_status: this.device_status,
  307. }
  308. })
  309. this.loadingtf = false
  310. console.log(res)
  311. this.equipArr[act].list = [...this.equipArr[act].list, ...res.data]
  312. this.equipArr[act].list.forEach(item => {
  313. item.addtime = item.uptime;
  314. })
  315. console.log(this.equipArr[act].list)
  316. },
  317. tabClick(index) {
  318. this.active = index;
  319. this.device_id = this.equipArr[index].type
  320. this.device_type = this.equipArr[index].type
  321. },
  322. clickRight() {
  323. uni.navigateTo({
  324. url: "./search?device_id=" + this.device_id
  325. })
  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 if (item.type == 14) {
  344. uni.navigateTo({
  345. url: '/pages/cb/sy/detail?detail=' + data
  346. });
  347. } else{
  348. uni.navigateTo({
  349. url: '/pages/cb/equip-detail/equip-detail?info=' + data
  350. });
  351. }
  352. },
  353. clickLeft() {
  354. uni.switchTab({
  355. url: "../../index/index"
  356. })
  357. },
  358. filtrate(){
  359. this.filtrateTF = !this.filtrateTF
  360. },
  361. top() {
  362. uni.pageScrollTo({
  363. scrollTop: 0,
  364. duration: 500
  365. })
  366. },
  367. online(){
  368. this.equipArr[this.active].pageIndex=1
  369. this.equipArr[this.active].list =[]
  370. this.device_status = 1
  371. if (this.active == 4) {
  372. this.getthxyEquipList(4)
  373. } else if (this.active == 5) {
  374. this.getxctEquipList(5)
  375. } else if (this.active == 3) {
  376. this.getxyEquipList(3)
  377. } else {
  378. this.getEquipList(this.active)
  379. }
  380. this.filtrateTF = !this.filtrateTF
  381. },
  382. offline(){
  383. this.equipArr[this.active].pageIndex=1
  384. this.equipArr[this.active].list =[]
  385. this.device_status = 0
  386. if (this.active == 4) {
  387. this.getthxyEquipList(4)
  388. } else if (this.active == 5) {
  389. this.getxctEquipList(5)
  390. } else if (this.active == 3) {
  391. this.getxyEquipList(3)
  392. } else {
  393. this.getEquipList(this.active)
  394. }
  395. this.filtrateTF = !this.filtrateTF
  396. },
  397. complete(){
  398. this.equipArr[this.active].pageIndex=1
  399. this.equipArr[this.active].list =[]
  400. this.device_status = ""
  401. if (this.active == 4) {
  402. this.getthxyEquipList(4)
  403. } else if (this.active == 5) {
  404. this.getxctEquipList(5)
  405. } else if (this.active == 3) {
  406. this.getxyEquipList(3)
  407. } else {
  408. this.getEquipList(this.active)
  409. }
  410. this.filtrateTF = !this.filtrateTF
  411. },
  412. examine(e) {
  413. // console.log(this)
  414. this.show = true
  415. this.title = e.device_expiretext
  416. this.content = `<p style="padding-left:10px;margin:10px 0;font-size:14px;">到期时间 ${this.timezhuan(e.device_expire_time)}
  417. </p><p style="font-size:14px;text-align:right;color:#3C84FE;margin-bottom:10px;padding-right:10px">注:请前往PC端进行充值</p>`
  418. },
  419. timezhuan(time) {
  420. function fun(a) {
  421. return String(a).length == 1 ? '0' + a : a
  422. }
  423. let date = new Date(time * 1000)
  424. let y = date.getFullYear()
  425. let m = date.getMonth() + 1
  426. let d = date.getDate()
  427. let h = date.getHours()
  428. let min = date.getMinutes()
  429. let sec = date.getSeconds()
  430. return `${y}-${fun(m)}-${fun(d)} ${fun(h)}:${fun(min)}:${fun(sec)}`
  431. },
  432. },
  433. components: {
  434. equipItem,
  435. uniNavBar
  436. }
  437. }
  438. </script>
  439. <style lang="scss">
  440. page {
  441. background: $uni-bg-color-grey;
  442. .content {
  443. padding: 0 20rpx 20rpx 20rpx;
  444. box-sizing: border-box;
  445. }
  446. }
  447. image {
  448. width: 100%;
  449. }
  450. .loading{
  451. position: fixed;
  452. top: 440px;
  453. width: 95%;
  454. left: 2.5%;
  455. text-align: center;
  456. z-index: 100;
  457. .img{
  458. width: 300rpx;
  459. height: 40rpx;
  460. }
  461. }
  462. .bases_search {
  463. width: 60%;
  464. background-color: #FFFFFF;
  465. position: absolute;
  466. top: 10rpx;
  467. left: 50%;
  468. margin-left: -33%;
  469. .bases_search_text {
  470. width: 90%;
  471. margin: 0 auto;
  472. background-color: #F8F8F8;
  473. height: 60rpx;
  474. border-radius: 30rpx;
  475. display: flex;
  476. line-height: 60rpx;
  477. .search {
  478. padding: 0 20rpx;
  479. font-size: 34rpx;
  480. }
  481. input {
  482. width: 80%;
  483. margin-top: 10rpx;
  484. font-size: 28rpx;
  485. }
  486. }
  487. }
  488. .tab-box {
  489. // position: fixed;
  490. // top: 170px;
  491. font-size: 30rpx;
  492. line-height: 80rpx;
  493. background-color: #ffffff;
  494. width: 100vw;
  495. z-index: 2;
  496. overflow-y: hidden;
  497. overflow-x: auto;
  498. white-space: nowrap;
  499. margin-top: -10rpx;
  500. .tab-item {
  501. cursor: pointer;
  502. position: relative;
  503. padding: 10rpx 20rpx;
  504. text-align: center;
  505. display: inline-block;
  506. span{
  507. display: inline-block;
  508. }
  509. }
  510. .tab-item.active {
  511. .bottom-line {
  512. bottom: 0;
  513. position: absolute;
  514. display: inline-block;
  515. width: 90rpx;
  516. height: 6rpx;
  517. left: 0;
  518. right: 0;
  519. margin: auto;
  520. background: $uni-color-success;
  521. }
  522. }
  523. }
  524. .top {
  525. position: fixed;
  526. right: 10px;
  527. bottom: 40px;
  528. z-index: 100;
  529. image {
  530. width: 100rpx;
  531. height: 100rpx;
  532. }
  533. .backtop{
  534. display: flex;
  535. justify-content: flex-end;
  536. margin-bottom: 10rpx;
  537. }
  538. .more{
  539. display: flex;
  540. }
  541. .box{
  542. width: 80rpx;
  543. height: 80rpx;
  544. background-color: rgba(161,161,161,0.45);
  545. border-radius: 50%;
  546. text-align: center;
  547. line-height: 80rpx;
  548. box-sizing: border-box;
  549. margin: 14rpx 10rpx 0 0;
  550. color: #fff;
  551. }
  552. }
  553. </style>