index.vue 14 KB

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