index.vue 11 KB

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