index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  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.uptime|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. this.equipArr[act].list.forEach(item => {
  256. item.uptime = item.addtime;
  257. })
  258. for (var i = 0; i < this.equipArr[act].list.length; i++) {
  259. if (this.equipArr[act].list[i].device_expire == 0) {
  260. this.equipArr[act].list[i]['device_expiretext'] = "未到期"
  261. } else if (this.equipArr[act].list[i].device_expire == 1) {
  262. this.equipArr[act].list[i]['device_expiretext'] = "已到期"
  263. } else if (this.equipArr[act].list[i].device_expire == 2) {
  264. this.equipArr[act].list[i]['device_expiretext'] = "即将到期"
  265. }
  266. }
  267. console.log(this.equipArr[act].list)
  268. },
  269. async getxyEquipList(act) {
  270. this.loadingtf = true
  271. const res = await this.$myRequest({
  272. url: '/api/api_gateway?method=sex_lure_nl.sex_lure.nl_device_list',
  273. data: {
  274. device_type_id: this.equipArr[act].type,
  275. page: this.equipArr[act].pageIndex,
  276. page_size: 10,
  277. device_status:this.device_status
  278. }
  279. })
  280. this.loadingtf =false
  281. console.log(res)
  282. this.equipArr[act].list = [...this.equipArr[act].list, ...res.data]
  283. console.log(this.equipArr[act].list)
  284. },
  285. async getthxyEquipList(act) {
  286. this.loadingtf = true
  287. const res = await this.$myRequest({
  288. url: '/api/api_gateway?method=forecast.worm_lamp.xy_three_list',
  289. data: {
  290. device_type_id: this.equipArr[act].type,
  291. page: this.equipArr[act].pageIndex,
  292. page_size: 10,
  293. device_status: this.device_status,
  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. }
  311. })
  312. this.loadingtf = false
  313. console.log(res)
  314. this.equipArr[act].list = [...this.equipArr[act].list, ...res.data]
  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(itemOld) {
  328. let item = JSON.parse(JSON.stringify(itemOld))
  329. item.type = this.equipArr[this.active].type
  330. let data = JSON.stringify(item)
  331. if (item.type == 10) {
  332. uni.navigateTo({
  333. url: '/pages/cb/xy2.0/particulars?info=' + data
  334. });
  335. } else if (item.type == 8) {
  336. console.log(data)
  337. uni.navigateTo({
  338. url: '/pages/cb/thxydetail/thxydetail?imei=' + item.imei
  339. });
  340. } else if (item.type == 12) {
  341. uni.navigateTo({
  342. url: '/pages/cb/xctdetail/xctdetail?info=' + data
  343. });
  344. } else if (item.type == 14) {
  345. uni.navigateTo({
  346. url: '/pages/cb/sy/detail?detail=' + data
  347. });
  348. } else{
  349. uni.navigateTo({
  350. url: '/pages/cb/equip-detail/equip-detail?info=' + data
  351. });
  352. }
  353. },
  354. clickLeft() {
  355. uni.switchTab({
  356. url: "../../index/index"
  357. })
  358. },
  359. filtrate(){
  360. this.filtrateTF = !this.filtrateTF
  361. },
  362. top() {
  363. uni.pageScrollTo({
  364. scrollTop: 0,
  365. duration: 500
  366. })
  367. },
  368. online(){
  369. this.equipArr[this.active].pageIndex=1
  370. this.equipArr[this.active].list =[]
  371. this.device_status = 1
  372. if (this.active == 4) {
  373. this.getthxyEquipList(4)
  374. } else if (this.active == 5) {
  375. this.getxctEquipList(5)
  376. } else if (this.active == 3) {
  377. this.getxyEquipList(3)
  378. } else {
  379. this.getEquipList(this.active)
  380. }
  381. this.filtrateTF = !this.filtrateTF
  382. },
  383. offline(){
  384. this.equipArr[this.active].pageIndex=1
  385. this.equipArr[this.active].list =[]
  386. this.device_status = 0
  387. if (this.active == 4) {
  388. this.getthxyEquipList(4)
  389. } else if (this.active == 5) {
  390. this.getxctEquipList(5)
  391. } else if (this.active == 3) {
  392. this.getxyEquipList(3)
  393. } else {
  394. this.getEquipList(this.active)
  395. }
  396. this.filtrateTF = !this.filtrateTF
  397. },
  398. complete(){
  399. this.equipArr[this.active].pageIndex=1
  400. this.equipArr[this.active].list =[]
  401. this.device_status = ""
  402. if (this.active == 4) {
  403. this.getthxyEquipList(4)
  404. } else if (this.active == 5) {
  405. this.getxctEquipList(5)
  406. } else if (this.active == 3) {
  407. this.getxyEquipList(3)
  408. } else {
  409. this.getEquipList(this.active)
  410. }
  411. this.filtrateTF = !this.filtrateTF
  412. },
  413. examine(e) {
  414. // console.log(this)
  415. this.show = true
  416. this.title = e.device_expiretext
  417. this.content = `<p style="padding-left:10px;margin:10px 0;font-size:14px;">到期时间 ${this.timezhuan(e.device_expire_time)}
  418. </p><p style="font-size:14px;text-align:right;color:#3C84FE;margin-bottom:10px;padding-right:10px">注:请前往PC端进行充值</p>`
  419. },
  420. timezhuan(time) {
  421. function fun(a) {
  422. return String(a).length == 1 ? '0' + a : a
  423. }
  424. let date = new Date(time * 1000)
  425. let y = date.getFullYear()
  426. let m = date.getMonth() + 1
  427. let d = date.getDate()
  428. let h = date.getHours()
  429. let min = date.getMinutes()
  430. let sec = date.getSeconds()
  431. return `${y}-${fun(m)}-${fun(d)} ${fun(h)}:${fun(min)}:${fun(sec)}`
  432. },
  433. },
  434. components: {
  435. equipItem,
  436. uniNavBar
  437. }
  438. }
  439. </script>
  440. <style lang="scss">
  441. page {
  442. background: $uni-bg-color-grey;
  443. .content {
  444. padding: 0 20rpx 20rpx 20rpx;
  445. box-sizing: border-box;
  446. }
  447. }
  448. image {
  449. width: 100%;
  450. }
  451. .loading{
  452. position: fixed;
  453. top: 440px;
  454. width: 95%;
  455. left: 2.5%;
  456. text-align: center;
  457. z-index: 100;
  458. .img{
  459. width: 300rpx;
  460. height: 40rpx;
  461. }
  462. }
  463. .bases_search {
  464. width: 60%;
  465. background-color: #FFFFFF;
  466. position: absolute;
  467. top: 10rpx;
  468. left: 50%;
  469. margin-left: -33%;
  470. .bases_search_text {
  471. width: 90%;
  472. margin: 0 auto;
  473. background-color: #F8F8F8;
  474. height: 60rpx;
  475. border-radius: 30rpx;
  476. display: flex;
  477. line-height: 60rpx;
  478. .search {
  479. padding: 0 20rpx;
  480. font-size: 34rpx;
  481. }
  482. input {
  483. width: 80%;
  484. margin-top: 10rpx;
  485. font-size: 28rpx;
  486. }
  487. }
  488. }
  489. .tab-box {
  490. // position: fixed;
  491. // top: 170px;
  492. font-size: 30rpx;
  493. line-height: 80rpx;
  494. background-color: #ffffff;
  495. width: 100vw;
  496. z-index: 2;
  497. overflow-y: hidden;
  498. overflow-x: auto;
  499. white-space: nowrap;
  500. margin-top: -10rpx;
  501. .tab-item {
  502. cursor: pointer;
  503. position: relative;
  504. padding: 10rpx 20rpx;
  505. text-align: center;
  506. display: inline-block;
  507. span{
  508. display: inline-block;
  509. }
  510. }
  511. .tab-item.active {
  512. .bottom-line {
  513. bottom: 0;
  514. position: absolute;
  515. display: inline-block;
  516. width: 90rpx;
  517. height: 6rpx;
  518. left: 0;
  519. right: 0;
  520. margin: auto;
  521. background: $uni-color-success;
  522. }
  523. }
  524. }
  525. .top {
  526. position: fixed;
  527. right: 10px;
  528. bottom: 40px;
  529. z-index: 100;
  530. image {
  531. width: 100rpx;
  532. height: 100rpx;
  533. }
  534. .backtop{
  535. display: flex;
  536. justify-content: flex-end;
  537. margin-bottom: 10rpx;
  538. }
  539. .more{
  540. display: flex;
  541. }
  542. .box{
  543. width: 80rpx;
  544. height: 80rpx;
  545. background-color: rgba(161,161,161,0.45);
  546. border-radius: 50%;
  547. text-align: center;
  548. line-height: 80rpx;
  549. box-sizing: border-box;
  550. margin: 14rpx 10rpx 0 0;
  551. color: #fff;
  552. }
  553. }
  554. </style>