index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  1. <template>
  2. <view class="">
  3. <view class="status_bar"></view>
  4. <view class="" style="position: relative;top: 44px;">
  5. <view style="position: fixed;z-index: 100;">
  6. <uni-nav-bar @clickRight="clickRight" @clickLeft="clickLeft" left-icon="back" left-text="返回" right-icon="search"
  7. title="测报系统"></uni-nav-bar>
  8. <view class="inputs" :style="{'width':width+'rpx'}">
  9. <input type="text" value="" placeholder="请输入设备ID或设备名称" v-model="imports" @input="searchinp"
  10. class="inputbox" :clearable="false" />
  11. <u-icon name="search" size="40" class="icon" @click="search"></u-icon>
  12. </view>
  13. <view>
  14. <image :src="'http://www.hnyfwlw.com:8006/bigdata_app'+'/image/cb/banner.jpg'" mode="widthFix"></image>
  15. </view>
  16. <view class="tab-box">
  17. <view v-for="(item,index) in equipArr" :key="item.type" v-if="item.tf" @click="tabClick(index)" :class="['tab-item',active==index?'active':'']">
  18. <text>{{item.name}}</text>
  19. <text class="bottom-line"></text>
  20. </view>
  21. </view>
  22. </view>
  23. <view class="loading" v-if="loadingtf">
  24. <image src="../../../static/images/ajax-loader.gif" mode="" class="img"></image>
  25. </view>
  26. <view class="" style="position: absolute;top: 180px;width: 100%;">
  27. <view class="content">
  28. <template v-for="(item,index) in equipArr[active].list">
  29. <equipItem @click.native="itemClick(item)" v-bind:item="item" :key="index">
  30. <view class="date">
  31. <p>设备ID:{{item.imei || item.device_id}}</p>
  32. <p>最新上报时间:{{item.addtime|timeFormat}}</p>
  33. <view class="" style="display: flex;justify-content: space-between;" v-if="device_type == 3 || device_type==7">
  34. <p>设备到期情况:<span
  35. :class="'prevents_item_bot_sapn'+item.device_expire">{{item.device_expiretext}}</span>
  36. </p>
  37. <p style="color: #3C84FE;" v-if="item.device_expire!=0" @click.stop="examine(item)">查看详情</p>
  38. </view>
  39. </view>
  40. </equipItem>
  41. </template>
  42. </view>
  43. </view>
  44. </view>
  45. <u-modal v-model="show" :title="title" :showConfirmButton="false" :title-style="{'text-align':'left','padding-left':'10px','font-weight':700}" :mask-close-able="true">
  46. <view class="slot-content">
  47. <rich-text :nodes="content"></rich-text>
  48. </view>
  49. </u-modal>
  50. <view class="top">
  51. <view class="backtop" @click="top" v-if="isTop">
  52. <image src="../../../static/images/1.png" mode="" class="img0"></image>
  53. </view>
  54. <view class="more">
  55. <view class="box" @click="online" v-show="filtrateTF">
  56. <p>在线</p>
  57. </view>
  58. <view class="box" @click="offline" v-show="filtrateTF">
  59. <p>离线</p>
  60. </view>
  61. <view class="box" @click="complete" v-show="filtrateTF">
  62. <p>全部</p>
  63. </view>
  64. <view @click="filtrate">
  65. <image src="../../../static/images/b0bcdb0e3fe8690520f743aa8303bf2.png" mode="" class="img1"></image>
  66. </view>
  67. </view>
  68. </view>
  69. </view>
  70. </template>
  71. <script>
  72. import {Debounce} from "../../../util/anitthro.js"
  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. type: 3, //3虫情测报灯 7孢子仪 4智能性诱
  82. list: [],
  83. pageIndex: 1,
  84. tf:false,
  85. }, {
  86. name: '孢子仪',
  87. type: 7, //3虫情测报灯 7孢子仪 4智能性诱
  88. list: [],
  89. pageIndex: 1,
  90. tf:false,
  91. }, {
  92. name: '性诱测报',
  93. type: 4, //3虫情测报灯 7孢子仪 4智能性诱
  94. list: [],
  95. pageIndex: 1,
  96. tf:false,
  97. },
  98. {
  99. name: '性诱2.0',
  100. type: 10, //3虫情测报灯 7孢子仪 4智能性诱 性诱2.0
  101. list: [],
  102. pageIndex: 1,
  103. tf:false
  104. }
  105. ],
  106. device_type: '3', //筛选的设备id
  107. isTop: false,
  108. filtrateTF:false,
  109. device_status:"",
  110. width:0,//顶部搜索栏宽度
  111. imports:"",//搜索id
  112. loadingtf:false,//loading
  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.pur_id == 36
  124. })
  125. var arr = items[0].children
  126. for(var i =0;i<arr.length;i++){
  127. switch (arr[i].pur_id){
  128. case 37:
  129. this.equipArr[0].tf = true//"虫情测报灯"
  130. this.getEquipList(0)
  131. break
  132. case 38:
  133. this.equipArr[2].tf = true//"性诱测报"
  134. this.getEquipList(2)
  135. break
  136. case 39:
  137. this.equipArr[1].tf = true//"孢子仪"
  138. this.getEquipList(1)
  139. break
  140. case 159:
  141. this.equipArr[3].tf = true//"性诱2.0"
  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. device_id: this.imports,
  204. }
  205. })
  206. this.loadingtf =false
  207. console.log(res)
  208. this.equipArr[act].list = [...this.equipArr[act].list, ...res.data]
  209. for (var i = 0; i < this.equipArr[act].list.length; i++) {
  210. if (this.equipArr[act].list[i].device_expire == 0) {
  211. this.equipArr[act].list[i]['device_expiretext'] = "未到期"
  212. } else if (this.equipArr[act].list[i].device_expire == 1) {
  213. this.equipArr[act].list[i]['device_expiretext'] = "已到期"
  214. } else if (this.equipArr[act].list[i].device_expire == 2) {
  215. this.equipArr[act].list[i]['device_expiretext'] = "即将到期"
  216. }
  217. }
  218. console.log(this.equipArr[act].list)
  219. },
  220. async getxyEquipList(act) {
  221. this.loadingtf =true
  222. const res = await this.$myRequest({
  223. url: '/api/api_gateway?method=sex_lure_nl.sex_lure.nl_device_list',
  224. data: {
  225. device_type_id: this.equipArr[act].type,
  226. page: this.equipArr[act].pageIndex,
  227. page_size: 10,
  228. device_status:this.device_status,
  229. device_id: this.imports,
  230. }
  231. })
  232. this.loadingtf =false
  233. console.log(res)
  234. this.equipArr[act].list = [...this.equipArr[act].list, ...res.data]
  235. console.log(this.equipArr[act].list)
  236. },
  237. tabClick(index) {
  238. this.width = 0
  239. this.imports = ""
  240. this.active = index;
  241. this.device_type = this.equipArr[index].type
  242. },
  243. clickRight() {
  244. this.width=600
  245. },
  246. itemClick(item) {
  247. item.type = this.equipArr[this.active].type
  248. let data = JSON.stringify(item)
  249. if (item.type == 10) {
  250. uni.navigateTo({
  251. url: '/pages/cb/xy2.0/particulars?info=' + data
  252. });
  253. } else {
  254. uni.navigateTo({
  255. url: '/pages/cb/equip-detail/equip-detail?info=' + data
  256. });
  257. }
  258. },
  259. clickLeft() {
  260. uni.switchTab({
  261. url: "../../index/index"
  262. })
  263. },
  264. filtrate(){
  265. this.filtrateTF = !this.filtrateTF
  266. },
  267. top() {
  268. uni.pageScrollTo({
  269. scrollTop: 0,
  270. duration: 500
  271. })
  272. },
  273. online(){
  274. this.equipArr[this.active].pageIndex=1
  275. this.equipArr[this.active].list =[]
  276. this.device_status = 1
  277. if(this.active==3){
  278. this.getxyEquipList(3)
  279. }else{
  280. this.getEquipList(this.active)
  281. }
  282. this.filtrateTF = !this.filtrateTF
  283. },
  284. offline(){
  285. this.equipArr[this.active].pageIndex=1
  286. this.equipArr[this.active].list =[]
  287. this.device_status = 0
  288. if(this.active==3){
  289. this.getxyEquipList(3)
  290. }else{
  291. this.getEquipList(this.active)
  292. }
  293. this.filtrateTF = !this.filtrateTF
  294. },
  295. complete(){
  296. this.equipArr[this.active].pageIndex=1
  297. this.equipArr[this.active].list =[]
  298. this.device_status = ""
  299. if(this.active==3){
  300. this.getxyEquipList(3)
  301. }else{
  302. this.getEquipList(this.active)
  303. }
  304. this.filtrateTF = !this.filtrateTF
  305. },
  306. search() {//搜索按钮搜索
  307. this.searchinp()
  308. },
  309. searchinp() {//自动搜索
  310. Debounce(() => {
  311. this.equipArr[this.active].pageIndex = 1
  312. if(this.active==3){
  313. this.equipArr[this.active].list=[]
  314. this.getxyEquipList(3)
  315. }else{
  316. this.equipArr[this.active].list=[]
  317. this.getEquipList(this.active)
  318. }
  319. }, 1000)()
  320. },
  321. examine(e) {
  322. // console.log(this)
  323. this.show = true
  324. this.title = e.device_expiretext
  325. this.content = `<p style="padding-left:10px;margin:10px 0;font-size:14px;">到期时间 ${this.timezhuan(e.device_expire_time)}
  326. </p><p style="font-size:14px;text-align:right;color:#3C84FE;margin-bottom:10px;padding-right:10px">注:请前往PC端进行充值</p>`
  327. },
  328. timezhuan(time) {
  329. function fun(a) {
  330. return String(a).length == 1 ? '0' + a : a
  331. }
  332. let date = new Date(time * 1000)
  333. let y = date.getFullYear()
  334. let m = date.getMonth() + 1
  335. let d = date.getDate()
  336. let h = date.getHours()
  337. let min = date.getMinutes()
  338. let sec = date.getSeconds()
  339. return `${y}-${fun(m)}-${fun(d)} ${fun(h)}:${fun(min)}:${fun(sec)}`
  340. },
  341. },
  342. components: {
  343. equipItem,
  344. uniNavBar
  345. }
  346. }
  347. </script>
  348. <style lang="scss">
  349. page {
  350. background: $uni-bg-color-grey;
  351. .content {
  352. padding: 0 20rpx 20rpx 20rpx;
  353. box-sizing: border-box;
  354. .prevents_item_bot_sapn0 {
  355. color: #00B075;
  356. }
  357. .prevents_item_bot_sapn1 {
  358. color: #FF4747;
  359. }
  360. .prevents_item_bot_sapn2 {
  361. color: #FFAB00;
  362. }
  363. }
  364. }
  365. image {
  366. width: 100%;
  367. }
  368. .inputs{
  369. height: 54rpx;
  370. background-color: #E4E4E4;
  371. border-radius: 27rpx;
  372. position: absolute;
  373. right: 20rpx;
  374. top: 20rpx;
  375. transition: width 0.5s;
  376. overflow: hidden;
  377. padding-top: 8rpx;
  378. box-sizing: border-box;
  379. .inputbox {
  380. width: 85%;
  381. text-indent: 1rem;
  382. font-size: 26rpx;
  383. }
  384. .icon {
  385. position: absolute;
  386. top: 8rpx;
  387. right: 26rpx;
  388. }
  389. }
  390. .loading{
  391. position: fixed;
  392. top: 440px;
  393. width: 95%;
  394. left: 2.5%;
  395. text-align: center;
  396. .img{
  397. width: 300rpx;
  398. height: 40rpx;
  399. }
  400. }
  401. .tab-box {
  402. display: flex;
  403. justify-content: space-around;
  404. font-size: 30rpx;
  405. line-height: 80rpx;
  406. background-color: #FFFFFF;
  407. margin-top: -10rpx;
  408. .tab-item {
  409. cursor: pointer;
  410. position: relative;
  411. }
  412. ;
  413. .tab-item.active {
  414. .bottom-line {
  415. bottom: 0;
  416. position: absolute;
  417. display: inline-block;
  418. width: 90rpx;
  419. height: 6rpx;
  420. left: 0;
  421. right: 0;
  422. margin: auto;
  423. background: $uni-color-success;
  424. }
  425. }
  426. }
  427. .top {
  428. position: fixed;
  429. right: 10px;
  430. bottom: 40px;
  431. z-index: 100;
  432. image {
  433. width: 100rpx;
  434. height: 100rpx;
  435. }
  436. .backtop{
  437. display: flex;
  438. justify-content: flex-end;
  439. margin-bottom: 10rpx;
  440. }
  441. .more{
  442. display: flex;
  443. }
  444. .box{
  445. width: 80rpx;
  446. height: 80rpx;
  447. background-color: rgba(161,161,161,0.45);
  448. border-radius: 50%;
  449. text-align: center;
  450. line-height: 80rpx;
  451. box-sizing: border-box;
  452. margin: 14rpx 10rpx 0 0;
  453. color: #fff;
  454. }
  455. }
  456. </style>