index.vue 9.5 KB

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