index.vue 14 KB

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