index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561
  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="'http://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. console.log(this.equipArr[act].list)
  313. },
  314. tabClick(index) {
  315. this.active = index;
  316. this.device_id = this.equipArr[index].type
  317. this.device_type = this.equipArr[index].type
  318. },
  319. clickRight() {
  320. uni.navigateTo({
  321. url: "./search?device_id=" + this.device_id
  322. })
  323. },
  324. itemClick(item) {
  325. item.type = this.equipArr[this.active].type
  326. let data = JSON.stringify(item)
  327. if (item.type == 10) {
  328. uni.navigateTo({
  329. url: '/pages/cb/xy2.0/particulars?info=' + data
  330. });
  331. } else if (item.type == 8) {
  332. console.log(data)
  333. uni.navigateTo({
  334. url: '/pages/cb/thxydetail/thxydetail?imei=' + item.imei
  335. });
  336. } else if (item.type == 12) {
  337. uni.navigateTo({
  338. url: '/pages/cb/xctdetail/xctdetail?info=' + data
  339. });
  340. } else if (item.type == 14) {
  341. uni.navigateTo({
  342. url: '/pages/cb/sy/detail?detail=' + data
  343. });
  344. } else{
  345. uni.navigateTo({
  346. url: '/pages/cb/equip-detail/equip-detail?info=' + data
  347. });
  348. }
  349. },
  350. clickLeft() {
  351. uni.switchTab({
  352. url: "../../index/index"
  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.equipArr[this.active].pageIndex=1
  366. this.equipArr[this.active].list =[]
  367. this.device_status = 1
  368. if (this.active == 4) {
  369. this.getthxyEquipList(4)
  370. } else if (this.active == 5) {
  371. this.getxctEquipList(5)
  372. } else if (this.active == 3) {
  373. this.getxyEquipList(3)
  374. } else {
  375. this.getEquipList(this.active)
  376. }
  377. this.filtrateTF = !this.filtrateTF
  378. },
  379. offline(){
  380. this.equipArr[this.active].pageIndex=1
  381. this.equipArr[this.active].list =[]
  382. this.device_status = 0
  383. if (this.active == 4) {
  384. this.getthxyEquipList(4)
  385. } else if (this.active == 5) {
  386. this.getxctEquipList(5)
  387. } else if (this.active == 3) {
  388. this.getxyEquipList(3)
  389. } else {
  390. this.getEquipList(this.active)
  391. }
  392. this.filtrateTF = !this.filtrateTF
  393. },
  394. complete(){
  395. this.equipArr[this.active].pageIndex=1
  396. this.equipArr[this.active].list =[]
  397. this.device_status = ""
  398. if (this.active == 4) {
  399. this.getthxyEquipList(4)
  400. } else if (this.active == 5) {
  401. this.getxctEquipList(5)
  402. } else if (this.active == 3) {
  403. this.getxyEquipList(3)
  404. } else {
  405. this.getEquipList(this.active)
  406. }
  407. this.filtrateTF = !this.filtrateTF
  408. },
  409. examine(e) {
  410. // console.log(this)
  411. this.show = true
  412. this.title = e.device_expiretext
  413. this.content = `<p style="padding-left:10px;margin:10px 0;font-size:14px;">到期时间 ${this.timezhuan(e.device_expire_time)}
  414. </p><p style="font-size:14px;text-align:right;color:#3C84FE;margin-bottom:10px;padding-right:10px">注:请前往PC端进行充值</p>`
  415. },
  416. timezhuan(time) {
  417. function fun(a) {
  418. return String(a).length == 1 ? '0' + a : a
  419. }
  420. let date = new Date(time * 1000)
  421. let y = date.getFullYear()
  422. let m = date.getMonth() + 1
  423. let d = date.getDate()
  424. let h = date.getHours()
  425. let min = date.getMinutes()
  426. let sec = date.getSeconds()
  427. return `${y}-${fun(m)}-${fun(d)} ${fun(h)}:${fun(min)}:${fun(sec)}`
  428. },
  429. },
  430. components: {
  431. equipItem,
  432. uniNavBar
  433. }
  434. }
  435. </script>
  436. <style lang="scss">
  437. page {
  438. background: $uni-bg-color-grey;
  439. .content {
  440. padding: 0 20rpx 20rpx 20rpx;
  441. box-sizing: border-box;
  442. }
  443. }
  444. image {
  445. width: 100%;
  446. }
  447. .loading{
  448. position: fixed;
  449. top: 440px;
  450. width: 95%;
  451. left: 2.5%;
  452. text-align: center;
  453. z-index: 100;
  454. .img{
  455. width: 300rpx;
  456. height: 40rpx;
  457. }
  458. }
  459. .bases_search {
  460. width: 60%;
  461. background-color: #FFFFFF;
  462. position: absolute;
  463. top: 10rpx;
  464. left: 50%;
  465. margin-left: -33%;
  466. .bases_search_text {
  467. width: 90%;
  468. margin: 0 auto;
  469. background-color: #F8F8F8;
  470. height: 60rpx;
  471. border-radius: 30rpx;
  472. display: flex;
  473. line-height: 60rpx;
  474. .search {
  475. padding: 0 20rpx;
  476. font-size: 34rpx;
  477. }
  478. input {
  479. width: 80%;
  480. margin-top: 10rpx;
  481. font-size: 28rpx;
  482. }
  483. }
  484. }
  485. .tab-box {
  486. // position: fixed;
  487. // top: 170px;
  488. font-size: 30rpx;
  489. line-height: 80rpx;
  490. background-color: #ffffff;
  491. width: 100vw;
  492. z-index: 2;
  493. overflow-y: hidden;
  494. overflow-x: auto;
  495. white-space: nowrap;
  496. margin-top: -10rpx;
  497. .tab-item {
  498. cursor: pointer;
  499. position: relative;
  500. padding: 10rpx 20rpx;
  501. text-align: center;
  502. display: inline-block;
  503. span{
  504. display: inline-block;
  505. }
  506. }
  507. .tab-item.active {
  508. .bottom-line {
  509. bottom: 0;
  510. position: absolute;
  511. display: inline-block;
  512. width: 90rpx;
  513. height: 6rpx;
  514. left: 0;
  515. right: 0;
  516. margin: auto;
  517. background: $uni-color-success;
  518. }
  519. }
  520. }
  521. .top {
  522. position: fixed;
  523. right: 10px;
  524. bottom: 40px;
  525. z-index: 100;
  526. image {
  527. width: 100rpx;
  528. height: 100rpx;
  529. }
  530. .backtop{
  531. display: flex;
  532. justify-content: flex-end;
  533. margin-bottom: 10rpx;
  534. }
  535. .more{
  536. display: flex;
  537. }
  538. .box{
  539. width: 80rpx;
  540. height: 80rpx;
  541. background-color: rgba(161,161,161,0.45);
  542. border-radius: 50%;
  543. text-align: center;
  544. line-height: 80rpx;
  545. box-sizing: border-box;
  546. margin: 14rpx 10rpx 0 0;
  547. color: #fff;
  548. }
  549. }
  550. </style>