index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
  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="$imageURL+'/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="index" @click="tabClick(index,item)" :class="['tab-item',active==index?'active':'']">
  19. <text>{{item.type_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="findSearch(1)" v-show="filtrateTF">
  57. <p>在线</p>
  58. </view>
  59. <view class="box" @click="findSearch(0)" v-show="filtrateTF">
  60. <p>离线</p>
  61. </view>
  62. <view class="box" @click="findSearch('')" 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. }],
  82. isTop: false,
  83. filtrateTF:false,
  84. device_status:"",
  85. loadingtf:false,//设备列表加载中
  86. device_type:3,
  87. show: false,
  88. title: "",
  89. content: "",
  90. searchinput:'',
  91. data:{search:''}
  92. }
  93. },
  94. computed:{
  95. tabActiveStyle(){
  96. return {
  97. color: '#303133',
  98. fontWeight: 'bold'
  99. }
  100. }
  101. },
  102. onLoad() {
  103. this.equipArr = [{
  104. name: ''
  105. }]
  106. this.usertype()
  107. },
  108. onShow() {
  109. },
  110. onHide() {
  111. },
  112. onUnload() {
  113. },
  114. onPullDownRefresh() {
  115. this.equipArr[this.active].pageIndex = 1
  116. this.equipArr[this.active].list = []
  117. if (this.active == 4) {
  118. this.getthxyEquipList(4)
  119. } else if (this.active == 5) {
  120. this.getxctEquipList(5)
  121. } else if (this.active == 3) {
  122. this.getxyEquipList(3)
  123. } else {
  124. this.getEquipList(this.active)
  125. }
  126. setTimeout(() => {
  127. uni.stopPullDownRefresh()
  128. }, 1000)
  129. },
  130. onReachBottom() {
  131. let act = this.active
  132. if (this.equipArr[act].list.length < this.equipArr[act].pageIndex * 10) { //判断是否数据请求完
  133. return false
  134. }
  135. this.equipArr[act].pageIndex++;
  136. if (this.active == 4) {
  137. this.getthxyEquipList(4)
  138. } else if (this.active == 5) {
  139. this.getxctEquipList(5)
  140. } else if (this.active == 3) {
  141. this.getxyEquipList(3)
  142. } else {
  143. this.getEquipList(this.active)
  144. }
  145. },
  146. onPageScroll(e) { //nvue暂不支持滚动监听,可用bindingx代替
  147. if (e.scrollTop > 200) { //距离大于200时显示
  148. this.isTop = true
  149. } else { //距离小于200时隐藏
  150. this.isTop = false
  151. }
  152. },
  153. onBackPress(options) {
  154. if (options.from === 'navigateBack') {
  155. return false;
  156. }
  157. this.clickLeft();
  158. return true;
  159. },
  160. methods: {
  161. search(){
  162. },
  163. //获取用户测报设备列表
  164. async usertype() {
  165. const res = await this.$myRequest({
  166. url: '/api/api_gateway?method=home.homes.user_device_type',
  167. data:{
  168. model:'测报'
  169. }
  170. })
  171. console.log('设备列表',res)
  172. // this.equipArr = res
  173. this.equipArr.shift()
  174. res.forEach(item=>{
  175. item.name=item.type_name
  176. item.list = []
  177. item.pageIndex = 1
  178. this.equipArr.push(item)
  179. })
  180. if (res.length) {
  181. this.device_type =this.equipArr[0].id
  182. this.choosePOST()
  183. }
  184. },
  185. async getEquipList(act) {
  186. this.loadingtf = true
  187. const res = await this.$myRequest({
  188. url: '/api/api_gateway?method=forecast.worm_lamp.lamp_list',
  189. data: {
  190. device_type_id: this.equipArr[act].id,
  191. page: this.equipArr[act].pageIndex,
  192. page_size: 10,
  193. device_status:this.device_status,
  194. device_model: this.equipArr[act].device_model ? this.equipArr[act].device_model:0
  195. }
  196. })
  197. this.loadingtf =false
  198. console.log(res)
  199. this.equipArr[act].list = [...this.equipArr[act].list, ...res.data]
  200. this.equipArr[act].list.forEach(item => {
  201. item.uptime = item.addtime;
  202. })
  203. for (var i = 0; i < this.equipArr[act].list.length; i++) {
  204. if (this.equipArr[act].list[i].device_expire == 0) {
  205. this.equipArr[act].list[i]['device_expiretext'] = "未到期"
  206. } else if (this.equipArr[act].list[i].device_expire == 1) {
  207. this.equipArr[act].list[i]['device_expiretext'] = "已到期"
  208. } else if (this.equipArr[act].list[i].device_expire == 2) {
  209. this.equipArr[act].list[i]['device_expiretext'] = "即将到期"
  210. }
  211. }
  212. console.log('处理后的结果',this.equipArr[act].list)
  213. },
  214. // 性诱2.0
  215. async getxyEquipList(act) {
  216. this.loadingtf = true
  217. const res = await this.$myRequest({
  218. url: '/api/api_gateway?method=sex_lure_nl.sex_lure.nl_device_list',
  219. data: {
  220. device_type_id: this.equipArr[act].id,
  221. page: this.equipArr[act].pageIndex,
  222. page_size: 10,
  223. device_status:this.device_status
  224. }
  225. })
  226. this.loadingtf =false
  227. console.log(res)
  228. this.equipArr[act].list = [...this.equipArr[act].list, ...res.data]
  229. console.log(this.equipArr[act].list)
  230. },
  231. // 性诱3.0
  232. async getthxyEquipList(act) {
  233. this.loadingtf = true
  234. const res = await this.$myRequest({
  235. url: '/api/api_gateway?method=forecast.worm_lamp.xy_three_list',
  236. data: {
  237. device_type_id: this.equipArr[act].id,
  238. page: this.equipArr[act].pageIndex,
  239. page_size: 10,
  240. device_status: this.device_status,
  241. }
  242. })
  243. this.loadingtf = false
  244. console.log(res)
  245. this.equipArr[act].list = [...this.equipArr[act].list, ...res.data]
  246. console.log(this.equipArr[act].list)
  247. },
  248. // 吸虫塔
  249. async getxctEquipList(act) {
  250. this.loadingtf = true
  251. const res = await this.$myRequest({
  252. url: '/api/api_gateway?method=forecast.worm_lamp.xct_list',
  253. data: {
  254. device_type_id: this.equipArr[act].id,
  255. page: this.equipArr[act].pageIndex,
  256. page_size: 10,
  257. device_status: this.device_status,
  258. }
  259. })
  260. this.loadingtf = false
  261. console.log(res)
  262. this.equipArr[act].list = [...this.equipArr[act].list, ...res.data]
  263. console.log(this.equipArr[act].list)
  264. },
  265. tabClick(index) {
  266. this.active = index;
  267. this.device_type = this.equipArr[index].id
  268. this.equipArr[this.active].list = []
  269. this.equipArr[this.active].pageIndex=1
  270. this.choosePOST()
  271. },
  272. choosePOST(){
  273. let index = this.active
  274. let typeId = this.device_type
  275. if(typeId == 10){
  276. // 性诱2.0
  277. this.getxyEquipList(index)
  278. }else if(typeId == 8){
  279. // 性诱3.0
  280. this.getthxyEquipList(index)
  281. }else if(typeId == 12){
  282. // 吸虫塔
  283. this.getxctEquipList(index)
  284. }
  285. else{
  286. // 测报接口
  287. this.getEquipList(index)
  288. }
  289. },
  290. clickRight() {
  291. uni.navigateTo({
  292. url: "./search?device_id=" + this.device_type+'&pur_id=' + this.equipArr[this.active].pur_id
  293. })
  294. },
  295. itemClick(itemOld) {
  296. let item = JSON.parse(JSON.stringify(itemOld))
  297. item.type= this.equipArr[this.active].id
  298. item.pur_id = this.equipArr[this.active].pur_id||0
  299. let data = JSON.stringify(item)
  300. console.log('item',item)
  301. if (item.type == 10) {
  302. uni.navigateTo({
  303. url: '/pages/cb/xy2.0/particulars?info=' + data
  304. });
  305. } else if (item.type == 8) {
  306. console.log(data)
  307. uni.navigateTo({
  308. url: '/pages/cb/thxydetail/thxydetail?imei=' + item.imei
  309. });
  310. } else if (item.type == 12) {
  311. uni.navigateTo({
  312. url: '/pages/cb/xctdetail/xctdetail?info=' + data
  313. });
  314. } else if (item.type == 14) {
  315. uni.navigateTo({
  316. url: '/pages/cb/sy/detail?detail=' + data
  317. });
  318. }else if (item.type == 24) {
  319. uni.navigateTo({
  320. url: '/pages/cb/zjxydetail/thxydetail?imei=' + item.imei
  321. });
  322. }else if (item.type == 25) {
  323. uni.navigateTo({
  324. url: '/pages/cb/xylps/detail?detail=' + data
  325. });
  326. }else if (item.type == 28) {
  327. uni.navigateTo({
  328. url: '/pages/cb/smallPest/smallPest?info=' + data
  329. });
  330. }else if (item.type == 29) {
  331. uni.navigateTo({
  332. url: `/pages/cb/nlNewXy/nlNewXy?imei=${item.imei}&showId=${item.only_for_show}`
  333. });
  334. }else if (item.type == 32||item.type == 33||item.type == 34||item.type == 35) {
  335. uni.navigateTo({
  336. url: '/pages/cb/equip-detail/equip-detail-new?info=' + data
  337. });
  338. } else{
  339. uni.navigateTo({
  340. url: '/pages/cb/equip-detail/equip-detail?info=' + data
  341. });
  342. }
  343. },
  344. clickLeft() {
  345. uni.switchTab({
  346. url: "../../index/index"
  347. })
  348. },
  349. filtrate(){
  350. this.filtrateTF = !this.filtrateTF
  351. },
  352. top() {
  353. uni.pageScrollTo({
  354. scrollTop: 0,
  355. duration: 500
  356. })
  357. },
  358. findSearch(device_status){
  359. this.device_status = device_status
  360. this.equipArr[this.active].pageIndex=1
  361. this.equipArr[this.active].list =[]
  362. this.choosePOST()
  363. this.filtrateTF = !this.filtrateTF
  364. },
  365. examine(e) {
  366. // console.log(this)
  367. this.show = true
  368. this.title = e.device_expiretext
  369. this.content = `<p style="padding-left:10px;margin:10px 0;font-size:14px;">到期时间 ${this.timezhuan(e.device_expire_time)}
  370. </p><p style="font-size:14px;text-align:right;color:#3C84FE;margin-bottom:10px;padding-right:10px">注:请前往PC端进行充值</p>`
  371. },
  372. timezhuan(time) {
  373. function fun(a) {
  374. return String(a).length == 1 ? '0' + a : a
  375. }
  376. let date = new Date(time * 1000)
  377. let y = date.getFullYear()
  378. let m = date.getMonth() + 1
  379. let d = date.getDate()
  380. let h = date.getHours()
  381. let min = date.getMinutes()
  382. let sec = date.getSeconds()
  383. return `${y}-${fun(m)}-${fun(d)} ${fun(h)}:${fun(min)}:${fun(sec)}`
  384. },
  385. },
  386. components: {
  387. equipItem,
  388. uniNavBar
  389. }
  390. }
  391. </script>
  392. <style lang="scss">
  393. page {
  394. background: $uni-bg-color-grey;
  395. .content {
  396. padding: 0 20rpx 20rpx 20rpx;
  397. box-sizing: border-box;
  398. }
  399. }
  400. image {
  401. width: 100%;
  402. }
  403. .loading{
  404. position: fixed;
  405. top: 440px;
  406. width: 95%;
  407. left: 2.5%;
  408. text-align: center;
  409. z-index: 100;
  410. .img{
  411. width: 300rpx;
  412. height: 40rpx;
  413. }
  414. }
  415. .bases_search {
  416. width: 80%;
  417. background-color: #FFFFFF;
  418. position: absolute;
  419. top: 10rpx;
  420. left: 50%;
  421. margin-left: -33%;
  422. .bases_search_text {
  423. width: 90%;
  424. margin: 0 auto;
  425. background-color: #F8F8F8;
  426. height: 60rpx;
  427. border-radius: 30rpx;
  428. display: flex;
  429. line-height: 60rpx;
  430. .search {
  431. padding: 0 20rpx;
  432. font-size: 34rpx;
  433. }
  434. input {
  435. width: 80%;
  436. margin-top: 10rpx;
  437. font-size: 28rpx;
  438. }
  439. }
  440. }
  441. .tab-box {
  442. font-size: 30rpx;
  443. line-height: 80rpx;
  444. background-color: #ffffff;
  445. width: 100vw;
  446. z-index: 2;
  447. overflow-y: hidden;
  448. overflow-x: auto;
  449. white-space: nowrap;
  450. margin-top: -10rpx;
  451. .tab-item {
  452. cursor: pointer;
  453. position: relative;
  454. padding: 10rpx 20rpx;
  455. text-align: center;
  456. display: inline-block;
  457. span{
  458. display: inline-block;
  459. }
  460. }
  461. .tab-item.active {
  462. .bottom-line {
  463. bottom: 0;
  464. position: absolute;
  465. display: inline-block;
  466. width: 90rpx;
  467. height: 6rpx;
  468. left: 0;
  469. right: 0;
  470. margin: auto;
  471. background: $uni-color-success;
  472. }
  473. }
  474. }
  475. .top {
  476. position: fixed;
  477. right: 10px;
  478. bottom: 40px;
  479. z-index: 100;
  480. image {
  481. width: 100rpx;
  482. height: 100rpx;
  483. }
  484. .backtop{
  485. display: flex;
  486. justify-content: flex-end;
  487. margin-bottom: 10rpx;
  488. }
  489. .more{
  490. display: flex;
  491. }
  492. .box{
  493. width: 80rpx;
  494. height: 80rpx;
  495. background-color: rgba(161,161,161,0.45);
  496. border-radius: 50%;
  497. text-align: center;
  498. line-height: 80rpx;
  499. box-sizing: border-box;
  500. margin: 14rpx 10rpx 0 0;
  501. color: #fff;
  502. }
  503. }
  504. </style>