index.vue 5.6 KB

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