index.vue 11 KB

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