index.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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/prevention/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="prevents">
  21. <view class="prevents_item" v-for="item,index in eqlistdata" :key="index" @click="eqdetails(item)">
  22. <image :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'"
  23. mode="" class="prevents_item_img"></image>
  24. <view class="prevents_item_top">
  25. <p>设备名称:{{item.device_name==""?"无":item.device_name}}</p>
  26. <p :class="item.is_online==1?'green':'red'" v-text="item.is_online==1?'在线':'离线'"></p>
  27. </view>
  28. <view class="prevents_item_bot">
  29. <p>设备 ID:{{item.imei}}</p>
  30. <p>最新上报时间:{{item.addtime|timeFormat()}}</p>
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. <view class="top">
  36. <view class="backtop" @click="top" v-if="isTop">
  37. <image src="../../static/images/1.png" mode="" class="img0"></image>
  38. </view>
  39. <view class="more">
  40. <view class="box" @click="online" v-show="filtrateTF">
  41. <p>在线</p>
  42. </view>
  43. <view class="box" @click="offline" v-show="filtrateTF">
  44. <p>离线</p>
  45. </view>
  46. <view class="box" @click="complete" v-show="filtrateTF">
  47. <p>全部</p>
  48. </view>
  49. <view @click="filtrate">
  50. <image src="../../static/images/b0bcdb0e3fe8690520f743aa8303bf2.png" mode="" class="img1"></image>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. </template>
  56. <script>
  57. export default {
  58. data() {
  59. return {
  60. page: 1,
  61. size: 10,
  62. eqlistdata: [],
  63. isTop:false,
  64. filtrateTF:false,
  65. device_status:"",
  66. loadingtf:false,//loading
  67. }
  68. },
  69. methods: {
  70. async eqlist() { //设备列表
  71. this.loadingtf = true
  72. const res = await this.$myRequest({
  73. url: '/api/api_gateway?method=forecast.worm_lamp.lamp_list',
  74. data: {
  75. device_type_id: 2,
  76. page: this.page,
  77. page_size: 10,
  78. device_status:this.device_status
  79. }
  80. })
  81. this.loadingtf = false
  82. this.eqlistdata = this.eqlistdata.concat(res.data)
  83. console.log(this.eqlistdata)
  84. },
  85. clickLeft() {
  86. uni.switchTab({
  87. url: "../index/index"
  88. })
  89. },
  90. clickRight() {
  91. uni.navigateTo({
  92. url: "./search"
  93. })
  94. },
  95. eqdetails(data) {
  96. uni.navigateTo({
  97. url: "./equipmentdetails?shebei=" + JSON.stringify(data)
  98. })
  99. },
  100. filtrate(){
  101. this.filtrateTF = !this.filtrateTF
  102. },
  103. top() {
  104. uni.pageScrollTo({
  105. scrollTop: 0,
  106. duration: 500
  107. })
  108. },
  109. online(){
  110. this.eqlistdata=[]
  111. this.page = 1
  112. this.device_status = 1
  113. this.eqlist()
  114. this.filtrateTF = !this.filtrateTF
  115. },
  116. offline(){
  117. this.eqlistdata=[]
  118. this.page = 1
  119. this.device_status = 0
  120. this.eqlist()
  121. this.filtrateTF = !this.filtrateTF
  122. },
  123. complete(){
  124. this.eqlistdata=[]
  125. this.page = 1
  126. this.device_status = ""
  127. this.eqlist()
  128. this.filtrateTF = !this.filtrateTF
  129. }
  130. },
  131. onLoad() {
  132. this.eqlist()
  133. },
  134. onReachBottom() {
  135. this.page++
  136. this.eqlist()
  137. },
  138. onPageScroll(e) { //nvue暂不支持滚动监听,可用bindingx代替
  139. if (e.scrollTop > 200) { //距离大于200时显示
  140. this.isTop = true
  141. } else { //距离小于200时隐藏
  142. this.isTop = false
  143. }
  144. }
  145. }
  146. </script>
  147. <style lang="scss">
  148. /deep/.uni-icons {
  149. font-size: 40rpx !important;
  150. }
  151. .image {
  152. position: fixed;
  153. top: 83px;
  154. width: 100%;
  155. height: 160rpx;
  156. z-index: 555;
  157. }
  158. .loading{
  159. position: fixed;
  160. top: 440px;
  161. width: 95%;
  162. left: 2.5%;
  163. text-align: center;
  164. .img{
  165. width: 300rpx;
  166. height: 40rpx;
  167. }
  168. }
  169. .bases_search {
  170. width: 60%;
  171. background-color: #FFFFFF;
  172. position: absolute;
  173. top: 10rpx;
  174. left: 50%;
  175. margin-left: -33%;
  176. .bases_search_text {
  177. width: 90%;
  178. margin: 0 auto;
  179. background-color: #F8F8F8;
  180. height: 60rpx;
  181. border-radius: 30rpx;
  182. display: flex;
  183. line-height: 60rpx;
  184. .search {
  185. padding: 0 20rpx;
  186. font-size: 34rpx;
  187. }
  188. input {
  189. width: 80%;
  190. margin-top: 10rpx;
  191. font-size: 28rpx;
  192. }
  193. }
  194. }
  195. .prevents {
  196. width: 100%;
  197. position: absolute;
  198. top: 140px;
  199. .prevents_item {
  200. width: 95%;
  201. margin: 0 auto 30rpx;
  202. border-radius: 10rpx;
  203. box-shadow: 0 0 10rpx #bcb9ca;
  204. padding: 20rpx 40rpx 20rpx 80rpx;
  205. position: relative;
  206. box-sizing: border-box;
  207. .prevents_item_img {
  208. width: 30rpx;
  209. height: 50rpx;
  210. position: absolute;
  211. top: -4rpx;
  212. left: 30rpx;
  213. }
  214. .prevents_item_top {
  215. display: flex;
  216. justify-content: space-between;
  217. height: 60rpx;
  218. border-bottom: 2rpx solid #F4F4F4;
  219. line-height: 60rpx;
  220. font-size: 26rpx;
  221. .red {
  222. color: #ff0000;
  223. }
  224. .green {
  225. color: #7DBB91;
  226. }
  227. }
  228. .prevents_item_bot {
  229. margin-top: 20rpx;
  230. font-size: 26rpx;
  231. color: #BDBDBD;
  232. }
  233. }
  234. }
  235. .top {
  236. position: fixed;
  237. right: 10px;
  238. bottom: 40px;
  239. z-index: 100;
  240. image {
  241. width: 100rpx;
  242. height: 100rpx;
  243. }
  244. .backtop{
  245. display: flex;
  246. justify-content: flex-end;
  247. margin-bottom: 10rpx;
  248. }
  249. .more{
  250. display: flex;
  251. }
  252. .box{
  253. width: 80rpx;
  254. height: 80rpx;
  255. background-color: rgba(161,161,161,0.45);
  256. border-radius: 50%;
  257. text-align: center;
  258. line-height: 80rpx;
  259. box-sizing: border-box;
  260. margin: 14rpx 10rpx 0 0;
  261. color: #fff;
  262. }
  263. }
  264. </style>