index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  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="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.choosePOST()
  270. },
  271. choosePOST(){
  272. let index = this.active
  273. let typeId = this.device_type
  274. if(typeId == 10){
  275. // 性诱2.0
  276. this.getxyEquipList(index)
  277. }else if(typeId == 8){
  278. // 性诱3.0
  279. this.getthxyEquipList(index)
  280. }else if(typeId == 12){
  281. // 吸虫塔
  282. this.getxctEquipList(index)
  283. }
  284. else{
  285. // 测报接口
  286. this.getEquipList(index)
  287. }
  288. },
  289. clickRight() {
  290. uni.navigateTo({
  291. url: "./search?device_id=" + this.device_type
  292. })
  293. },
  294. itemClick(itemOld) {
  295. let item = JSON.parse(JSON.stringify(itemOld))
  296. item.type= this.equipArr[this.active].id
  297. item.pur_id = this.equipArr[this.active].pur_id||0
  298. let data = JSON.stringify(item)
  299. if (item.type == 10) {
  300. uni.navigateTo({
  301. url: '/pages/cb/xy2.0/particulars?info=' + data
  302. });
  303. } else if (item.type == 8) {
  304. console.log(data)
  305. uni.navigateTo({
  306. url: '/pages/cb/thxydetail/thxydetail?imei=' + item.imei
  307. });
  308. } else if (item.type == 12) {
  309. uni.navigateTo({
  310. url: '/pages/cb/xctdetail/xctdetail?info=' + data
  311. });
  312. } else if (item.type == 14) {
  313. uni.navigateTo({
  314. url: '/pages/cb/sy/detail?detail=' + data
  315. });
  316. }else if (item.type == 32||item.type == 33||item.type == 34||item.type == 35) {
  317. uni.navigateTo({
  318. url: '/pages/cb/equip-detail/equip-detail-new?info=' + data
  319. });
  320. } else{
  321. uni.navigateTo({
  322. url: '/pages/cb/equip-detail/equip-detail?info=' + data
  323. });
  324. }
  325. },
  326. clickLeft() {
  327. uni.switchTab({
  328. url: "../../index/index"
  329. })
  330. },
  331. filtrate(){
  332. this.filtrateTF = !this.filtrateTF
  333. },
  334. top() {
  335. uni.pageScrollTo({
  336. scrollTop: 0,
  337. duration: 500
  338. })
  339. },
  340. findSearch(device_status){
  341. this.device_status = device_status
  342. this.equipArr[this.active].pageIndex=1
  343. this.equipArr[this.active].list =[]
  344. this.choosePOST()
  345. this.filtrateTF = !this.filtrateTF
  346. },
  347. examine(e) {
  348. // console.log(this)
  349. this.show = true
  350. this.title = e.device_expiretext
  351. this.content = `<p style="padding-left:10px;margin:10px 0;font-size:14px;">到期时间 ${this.timezhuan(e.device_expire_time)}
  352. </p><p style="font-size:14px;text-align:right;color:#3C84FE;margin-bottom:10px;padding-right:10px">注:请前往PC端进行充值</p>`
  353. },
  354. timezhuan(time) {
  355. function fun(a) {
  356. return String(a).length == 1 ? '0' + a : a
  357. }
  358. let date = new Date(time * 1000)
  359. let y = date.getFullYear()
  360. let m = date.getMonth() + 1
  361. let d = date.getDate()
  362. let h = date.getHours()
  363. let min = date.getMinutes()
  364. let sec = date.getSeconds()
  365. return `${y}-${fun(m)}-${fun(d)} ${fun(h)}:${fun(min)}:${fun(sec)}`
  366. },
  367. },
  368. components: {
  369. equipItem,
  370. uniNavBar
  371. }
  372. }
  373. </script>
  374. <style lang="scss">
  375. page {
  376. background: $uni-bg-color-grey;
  377. .content {
  378. padding: 0 20rpx 20rpx 20rpx;
  379. box-sizing: border-box;
  380. }
  381. }
  382. image {
  383. width: 100%;
  384. }
  385. .loading{
  386. position: fixed;
  387. top: 440px;
  388. width: 95%;
  389. left: 2.5%;
  390. text-align: center;
  391. z-index: 100;
  392. .img{
  393. width: 300rpx;
  394. height: 40rpx;
  395. }
  396. }
  397. .bases_search {
  398. width: 80%;
  399. background-color: #FFFFFF;
  400. position: absolute;
  401. top: 10rpx;
  402. left: 50%;
  403. margin-left: -33%;
  404. .bases_search_text {
  405. width: 90%;
  406. margin: 0 auto;
  407. background-color: #F8F8F8;
  408. height: 60rpx;
  409. border-radius: 30rpx;
  410. display: flex;
  411. line-height: 60rpx;
  412. .search {
  413. padding: 0 20rpx;
  414. font-size: 34rpx;
  415. }
  416. input {
  417. width: 80%;
  418. margin-top: 10rpx;
  419. font-size: 28rpx;
  420. }
  421. }
  422. }
  423. // .tab-box {
  424. // font-size: 30rpx;
  425. // line-height: 80rpx;
  426. // background-color: #ffffff;
  427. // width: 100vw;
  428. // z-index: 2;
  429. // margin-top: -10rpx;
  430. // }
  431. .tab-box {
  432. // position: fixed;
  433. // top: 170px;
  434. font-size: 30rpx;
  435. line-height: 80rpx;
  436. background-color: #ffffff;
  437. width: 100vw;
  438. z-index: 2;
  439. overflow-y: hidden;
  440. overflow-x: auto;
  441. white-space: nowrap;
  442. margin-top: -10rpx;
  443. .tab-item {
  444. cursor: pointer;
  445. position: relative;
  446. padding: 10rpx 20rpx;
  447. text-align: center;
  448. display: inline-block;
  449. span{
  450. display: inline-block;
  451. }
  452. }
  453. .tab-item.active {
  454. .bottom-line {
  455. bottom: 0;
  456. position: absolute;
  457. display: inline-block;
  458. width: 90rpx;
  459. height: 6rpx;
  460. left: 0;
  461. right: 0;
  462. margin: auto;
  463. background: $uni-color-success;
  464. }
  465. }
  466. }
  467. .top {
  468. position: fixed;
  469. right: 10px;
  470. bottom: 40px;
  471. z-index: 100;
  472. image {
  473. width: 100rpx;
  474. height: 100rpx;
  475. }
  476. .backtop{
  477. display: flex;
  478. justify-content: flex-end;
  479. margin-bottom: 10rpx;
  480. }
  481. .more{
  482. display: flex;
  483. }
  484. .box{
  485. width: 80rpx;
  486. height: 80rpx;
  487. background-color: rgba(161,161,161,0.45);
  488. border-radius: 50%;
  489. text-align: center;
  490. line-height: 80rpx;
  491. box-sizing: border-box;
  492. margin: 14rpx 10rpx 0 0;
  493. color: #fff;
  494. }
  495. }
  496. </style>