index.vue 9.0 KB

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