index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  1. <template>
  2. <view>
  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 @clickLeft="clickLeft" left-icon="back" left-text="返回" title="环境监测系统" right-icon="search"
  7. @clickRight="clickRight" size="16"></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/environment/1.png'" mode="" class="image">
  15. </image>
  16. <view class="loading" v-if="loadingtf">
  17. <image src="../../static/images/ajax-loader.gif" mode="" class="img"></image>
  18. </view>
  19. <view class="tab-box">
  20. <view v-for="(item,index) in equipArr" :key="item.type" v-if="item.tf" @click="tabClick(index,item.type)" :class="['tab-item',active==index?'active':'']">
  21. <text>{{item.name}}</text>
  22. <text class="bottom-line"></text>
  23. </view>
  24. </view>
  25. <view class="prevents">
  26. <view class="prevents_item" v-for="item,index in eqlistdata" :key="index" @click="eqdetails(item)">
  27. <view class="" v-if="side_type == 5">
  28. <image
  29. :src="item.is_online==1?'http://www.hnyfwlw.com:8006/bigdata_app/image/prevention/6.png':'http://www.hnyfwlw.com:8006/bigdata_app/image/prevention/7.png'"
  30. mode="" class="prevents_item_img"></image>
  31. <view class="prevents_item_top">
  32. <p>设备名称:{{item.equip_name==""?"环境监测":item.equip_name}}</p>
  33. <p :class="item.is_online==1?'green':'red'" v-text="item.is_online==1?'在线':'离线'"></p>
  34. </view>
  35. <view class="prevents_item_bot">
  36. <p>设备 ID:{{item.equip_id || item.device_id}}</p>
  37. <p>最新上报时间:{{item.uptime|timeFormat()}}</p>
  38. <view class="" style="display: flex;justify-content: space-between;">
  39. <p>设备到期情况:<span
  40. :class="'prevents_item_bot_sapn'+item.device_expire">{{item.device_expiretext}}</span>
  41. </p>
  42. <p style="color: #3C84FE;" v-if="item.device_expire!=0" @click.stop="examine(item)">查看详情</p>
  43. </view>
  44. </view>
  45. </view>
  46. <view class="" v-if="side_type == 15">
  47. <image
  48. src="http://www.hnyfwlw.com:8006/bigdata_app/image/prevention/6.png"
  49. mode="" class="prevents_item_img"></image>
  50. <view class="prevents_item_top">
  51. <p>设备名称:{{item.device_name==""?"管式墒情":item.device_name}}</p>
  52. </view>
  53. <view class="prevents_item_bot">
  54. <p>设备 ID:{{item.device_id}}</p>
  55. <p>最新上报时间:{{item.uptime|timeFormat()}}</p>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. <u-modal v-model="show" :title="title" :showConfirmButton="false" :title-style="{'text-align':'left','padding-left':'10px','font-weight':700}" :mask-close-able="true">
  62. <view class="slot-content">
  63. <rich-text :nodes="content"></rich-text>
  64. </view>
  65. </u-modal>
  66. <view class="top" v-if="side_type==5">
  67. <view class="backtop" @click="top" v-if="isTop">
  68. <image src="../../static/images/1.png" mode="" class="img0"></image>
  69. </view>
  70. <view class="more">
  71. <view class="box" @click="online" v-show="filtrateTF">
  72. <p>在线</p>
  73. </view>
  74. <view class="box" @click="offline" v-show="filtrateTF">
  75. <p>离线</p>
  76. </view>
  77. <view class="box" @click="complete" v-show="filtrateTF">
  78. <p>全部</p>
  79. </view>
  80. <view @click="filtrate">
  81. <image src="../../static/images/b0bcdb0e3fe8690520f743aa8303bf2.png" mode="" class="img1"></image>
  82. </view>
  83. </view>
  84. </view>
  85. </view>
  86. </template>
  87. <script>
  88. import {
  89. Debounce
  90. } from "../../util/anitthro.js"
  91. export default {
  92. data() {
  93. return {
  94. page: 1,
  95. size: 10,
  96. eqlistdata: [],
  97. isTop: false,
  98. filtrateTF: false,
  99. device_status: "",
  100. width: 0, //顶部搜索栏宽度
  101. imports: "", //搜索设备id
  102. loadingtf: false,
  103. equipArr: [{
  104. name: '环境监测',
  105. type: 5, //5 环境监测 15 管式墒情
  106. list: [],
  107. pageIndex: 1,
  108. tf:false,
  109. }, {
  110. name: '管式墒情',
  111. type: 15, //5 环境监测 15 管式墒情
  112. list: [],
  113. pageIndex: 1,
  114. tf:false,
  115. }
  116. ],
  117. active:0,//tab选中的下标
  118. side_type:5,//当前选中的设备类型
  119. show: false,
  120. title: "",
  121. content: ""
  122. }
  123. },
  124. methods: {
  125. async eqlist() { //设备列表 环境监测
  126. this.loadingtf = true
  127. const res = await this.$myRequest({
  128. url: '/api/api_gateway?method=weather.weather.qxz_page',
  129. data: {
  130. page: this.page,
  131. device_status: this.device_status,
  132. page_size: 10,
  133. device_id: this.imports
  134. }
  135. })
  136. this.loadingtf = false
  137. this.eqlistdata = this.eqlistdata.concat(res.ids)
  138. for (var i = 0; i < this.eqlistdata.length; i++) {
  139. if (this.eqlistdata[i].device_expire == 0) {
  140. this.eqlistdata[i]['device_expiretext'] = "未到期"
  141. } else if (this.eqlistdata[i].device_expire == 1) {
  142. this.eqlistdata[i]['device_expiretext'] = "已到期"
  143. } else if (this.eqlistdata[i].device_expire == 2) {
  144. this.eqlistdata[i]['device_expiretext'] = "即将到期"
  145. }
  146. }
  147. console.log(res.ids)
  148. },
  149. // weather.weather.nd_qxz_page 管式墒情
  150. async tubulareqlist() { //设备列表 环境监测
  151. this.loadingtf = true
  152. const res = await this.$myRequest({
  153. url: '/api/api_gateway?method=weather.weather.nd_qxz_page',
  154. data: {
  155. page: this.page,
  156. device_status: this.device_status,
  157. page_size: 10,
  158. device_id: this.imports
  159. }
  160. })
  161. this.loadingtf = false
  162. this.eqlistdata = this.eqlistdata.concat(res.ids)
  163. console.log(res.ids)
  164. },
  165. clickRight() {
  166. this.width = 600
  167. },
  168. clickLeft() {
  169. uni.switchTab({
  170. url: "../index/index"
  171. })
  172. },
  173. eqdetails(data) {
  174. if(this.side_type == 5){
  175. uni.navigateTo({
  176. url: "./equipment?shebei=" + JSON.stringify(data)
  177. })
  178. }else if(this.side_type == 15){
  179. uni.navigateTo({
  180. url: "./gsequipment?shebei=" + JSON.stringify(data)
  181. })
  182. }
  183. },
  184. filtrate() {
  185. this.filtrateTF = !this.filtrateTF
  186. },
  187. top() {
  188. uni.pageScrollTo({
  189. scrollTop: 0,
  190. duration: 500
  191. })
  192. },
  193. online() {
  194. this.eqlistdata = []
  195. this.page = 1
  196. this.device_status = 1
  197. this.eqlist()
  198. this.filtrateTF = !this.filtrateTF
  199. },
  200. offline() {
  201. this.eqlistdata = []
  202. this.page = 1
  203. this.device_status = 0
  204. this.eqlist()
  205. this.filtrateTF = !this.filtrateTF
  206. },
  207. complete() {
  208. this.eqlistdata = []
  209. this.page = 1
  210. this.device_status = ""
  211. this.eqlist()
  212. this.filtrateTF = !this.filtrateTF
  213. },
  214. search() { //搜索按钮搜索
  215. this.searchinp()
  216. },
  217. searchinp() { //自动搜索
  218. Debounce(() => {
  219. this.page = 1
  220. if(this.side_type == 5){
  221. this.eqlistdata = []
  222. this.eqlist()
  223. }else if(this.side_type == 15){
  224. this.eqlistdata = []
  225. this.tubulareqlist()
  226. }
  227. }, 1000)()
  228. },
  229. tabClick(index,type){
  230. this.active = index
  231. this.side_type = type
  232. this.page = 1
  233. if(type == 5){
  234. this.eqlistdata = []
  235. this.eqlist()
  236. }else if(type == 15){
  237. this.eqlistdata = []
  238. this.tubulareqlist()
  239. }
  240. },
  241. examine(e) {
  242. // console.log(this)
  243. this.show = true
  244. this.title = e.device_expiretext
  245. this.content = `<p style="padding-left:10px;margin:10px 0;font-size:14px;">到期时间 ${this.timezhuan(e.device_expire_time)}
  246. </p><p style="font-size:14px;text-align:right;color:#3C84FE;margin-bottom:10px;padding-right:10px">注:请前往PC端进行充值</p>`
  247. },
  248. timezhuan(time) {
  249. function fun(a) {
  250. return String(a).length == 1 ? '0' + a : a
  251. }
  252. let date = new Date(time * 1000)
  253. let y = date.getFullYear()
  254. let m = date.getMonth() + 1
  255. let d = date.getDate()
  256. let h = date.getHours()
  257. let min = date.getMinutes()
  258. let sec = date.getSeconds()
  259. return `${y}-${fun(m)}-${fun(d)} ${fun(h)}:${fun(min)}:${fun(sec)}`
  260. },
  261. },
  262. onLoad() {
  263. this.eqlist()
  264. uni.getStorage({
  265. key:"jurisdiction",
  266. success:(res)=>{
  267. let items = JSON.parse(res.data).filter((item)=>{
  268. return item.purview_name == "环境监测系统"
  269. })
  270. var itemarr = items[0].children
  271. console.log(itemarr)
  272. for(var i =0;i<itemarr.length;i++){
  273. switch (itemarr[i].purview_name){
  274. case "环境监测":
  275. this.equipArr[0].tf = true
  276. break
  277. case "管式墒情":
  278. this.equipArr[1].tf = true
  279. break
  280. }
  281. }
  282. }
  283. })
  284. },
  285. onReachBottom() {
  286. this.page++
  287. this.eqlist()
  288. },
  289. onPageScroll(e) { //nvue暂不支持滚动监听,可用bindingx代替
  290. if (e.scrollTop > 200) { //距离大于200时显示
  291. this.isTop = true
  292. } else { //距离小于200时隐藏
  293. this.isTop = false
  294. }
  295. },
  296. }
  297. </script>
  298. <style lang="scss">
  299. page{
  300. background: $uni-bg-color-grey;
  301. }
  302. .inputs {
  303. height: 54rpx;
  304. background-color: #E4E4E4;
  305. border-radius: 27rpx;
  306. position: absolute;
  307. right: 20rpx;
  308. top: 20rpx;
  309. transition: width 0.5s;
  310. overflow: hidden;
  311. padding-top: 8rpx;
  312. box-sizing: border-box;
  313. .inputbox {
  314. width: 85%;
  315. text-indent: 1rem;
  316. font-size: 26rpx;
  317. }
  318. .icon {
  319. position: absolute;
  320. top: 8rpx;
  321. right: 26rpx;
  322. }
  323. }
  324. /deep/.uni-icons {
  325. font-size: 40rpx !important;
  326. }
  327. .image {
  328. position: fixed;
  329. top: 84px;
  330. width: 100%;
  331. height: 160rpx;
  332. z-index: 555;
  333. }
  334. .loading {
  335. position: fixed;
  336. top: 440px;
  337. width: 95%;
  338. left: 2.5%;
  339. text-align: center;
  340. z-index:9;
  341. .img {
  342. width: 300rpx;
  343. height: 40rpx;
  344. }
  345. }
  346. .tab-box {
  347. position: fixed;
  348. top: 170px;
  349. display: flex;
  350. justify-content: space-around;
  351. font-size: 30rpx;
  352. line-height: 80rpx;
  353. background-color: #FFFFFF;
  354. width: 100%;
  355. z-index: 2;
  356. .tab-item {
  357. cursor: pointer;
  358. position: relative;
  359. };
  360. .tab-item.active {
  361. .bottom-line {
  362. bottom: 0;
  363. position: absolute;
  364. display: inline-block;
  365. width: 90rpx;
  366. height: 6rpx;
  367. left: 0;
  368. right: 0;
  369. margin: auto;
  370. background: $uni-color-success;
  371. }
  372. }
  373. }
  374. .prevents {
  375. width: 100%;
  376. position: absolute;
  377. top: 180px;
  378. .prevents_item {
  379. width: 95%;
  380. margin: 0 auto 30rpx;
  381. border-radius: 10rpx;
  382. box-shadow: 0 0 10rpx #bcb9ca;
  383. padding: 20rpx 40rpx 20rpx 80rpx;
  384. box-sizing: border-box;
  385. position: relative;
  386. background-color: #fff;
  387. .prevents_item_img {
  388. width: 30rpx;
  389. height: 50rpx;
  390. position: absolute;
  391. top: -4rpx;
  392. left: 30rpx;
  393. }
  394. .prevents_item_top {
  395. display: flex;
  396. justify-content: space-between;
  397. height: 60rpx;
  398. border-bottom: 2rpx solid #F4F4F4;
  399. line-height: 60rpx;
  400. font-size: 26rpx;
  401. .red {
  402. color: #ff0000;
  403. }
  404. .green {
  405. color: #7DBB91;
  406. }
  407. }
  408. .prevents_item_bot {
  409. margin-top: 20rpx;
  410. font-size: 26rpx;
  411. color: #BDBDBD;
  412. .prevents_item_bot_sapn0 {
  413. color: #00B075;
  414. }
  415. .prevents_item_bot_sapn1 {
  416. color: #FF4747;
  417. }
  418. .prevents_item_bot_sapn2 {
  419. color: #FFAB00;
  420. }
  421. }
  422. }
  423. }
  424. .top {
  425. position: fixed;
  426. right: 10px;
  427. bottom: 40px;
  428. z-index: 100;
  429. image {
  430. width: 100rpx;
  431. height: 100rpx;
  432. }
  433. .backtop {
  434. display: flex;
  435. justify-content: flex-end;
  436. margin-bottom: 10rpx;
  437. }
  438. .more {
  439. display: flex;
  440. }
  441. .box {
  442. width: 80rpx;
  443. height: 80rpx;
  444. background-color: rgba(161, 161, 161, 0.45);
  445. border-radius: 50%;
  446. text-align: center;
  447. line-height: 80rpx;
  448. box-sizing: border-box;
  449. margin: 14rpx 10rpx 0 0;
  450. color: #fff;
  451. }
  452. }
  453. </style>