index.vue 14 KB

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