index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  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" @clickRight="clickRight"
  7. 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" class="inputbox" :clearable="false"/>
  10. <u-icon name="search" size="40" class="icon" @click="search"></u-icon>
  11. </view>
  12. </view>
  13. <image :src="'http://www.hnyfwlw.com:8006/bigdata_app'+'/image/prevention/1.png'" mode="" class="image"></image>
  14. <view class="loading" v-if="loadingtf">
  15. <image src="../../static/images/ajax-loader.gif" mode="" class="img"></image>
  16. </view>
  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. import {Debounce} from "../../util/anitthro.js"
  55. export default {
  56. data() {
  57. return {
  58. page: 1,
  59. size: 10,
  60. eqlistdata: [],
  61. isTop:false,
  62. filtrateTF:false,
  63. device_status:"",
  64. width:0,
  65. imports:"",//搜索内容
  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. device_id: this.imports
  80. }
  81. })
  82. this.loadingtf = false
  83. this.eqlistdata = this.eqlistdata.concat(res.data)
  84. console.log(this.eqlistdata)
  85. },
  86. clickLeft() {
  87. uni.switchTab({
  88. url: "../index/index"
  89. })
  90. },
  91. clickRight() {
  92. // uni.navigateTo({
  93. // url: "./search"
  94. // })
  95. this.width = 600
  96. },
  97. eqdetails(data) {
  98. uni.navigateTo({
  99. url: "./equipmentdetails?shebei=" + JSON.stringify(data)
  100. })
  101. },
  102. filtrate(){
  103. this.filtrateTF = !this.filtrateTF
  104. },
  105. top() {
  106. uni.pageScrollTo({
  107. scrollTop: 0,
  108. duration: 500
  109. })
  110. },
  111. online(){
  112. this.eqlistdata=[]
  113. this.page = 1
  114. this.device_status = 1
  115. this.eqlist()
  116. this.filtrateTF = !this.filtrateTF
  117. },
  118. offline(){
  119. this.eqlistdata=[]
  120. this.page = 1
  121. this.device_status = 0
  122. this.eqlist()
  123. this.filtrateTF = !this.filtrateTF
  124. },
  125. complete(){
  126. this.eqlistdata=[]
  127. this.page = 1
  128. this.device_status = ""
  129. this.eqlist()
  130. this.filtrateTF = !this.filtrateTF
  131. },
  132. search() {//搜索按钮搜索
  133. this.eqlistdata = []
  134. this.eqlist()
  135. },
  136. searchinp() {//自动搜索
  137. Debounce(() => {
  138. this.eqlistdata = []
  139. this.eqlist()
  140. }, 1000)()
  141. },
  142. },
  143. onLoad() {
  144. this.eqlist()
  145. },
  146. onReachBottom() {
  147. this.page++
  148. this.eqlist()
  149. },
  150. onPageScroll(e) { //nvue暂不支持滚动监听,可用bindingx代替
  151. if (e.scrollTop > 200) { //距离大于200时显示
  152. this.isTop = true
  153. } else { //距离小于200时隐藏
  154. this.isTop = false
  155. }
  156. }
  157. }
  158. </script>
  159. <style lang="scss">
  160. .inputs{
  161. height: 54rpx;
  162. background-color: #E4E4E4;
  163. border-radius: 27rpx;
  164. position: absolute;
  165. right: 20rpx;
  166. top: 24rpx;
  167. transition: width 0.5s;
  168. overflow: hidden;
  169. padding-top: 8rpx;
  170. box-sizing: border-box;
  171. .inputbox {
  172. width: 85%;
  173. text-indent: 1rem;
  174. font-size: 26rpx;
  175. }
  176. .icon {
  177. position: absolute;
  178. top: 8rpx;
  179. right: 26rpx;
  180. }
  181. }
  182. /deep/.uni-icons {
  183. font-size: 40rpx !important;
  184. }
  185. .image {
  186. position: fixed;
  187. top: 88px;
  188. width: 100%;
  189. height: 160rpx;
  190. z-index: 555;
  191. }
  192. .loading{
  193. position: fixed;
  194. top: 440px;
  195. width: 95%;
  196. left: 2.5%;
  197. text-align: center;
  198. .img{
  199. width: 300rpx;
  200. height: 40rpx;
  201. }
  202. }
  203. .prevents {
  204. width: 100%;
  205. position: absolute;
  206. top: 140px;
  207. .prevents_item {
  208. width: 95%;
  209. margin: 0 auto 30rpx;
  210. border-radius: 10rpx;
  211. box-shadow: 0 0 10rpx #bcb9ca;
  212. padding: 20rpx 40rpx 20rpx 80rpx;
  213. position: relative;
  214. box-sizing: border-box;
  215. .prevents_item_img {
  216. width: 30rpx;
  217. height: 50rpx;
  218. position: absolute;
  219. top: -4rpx;
  220. left: 30rpx;
  221. }
  222. .prevents_item_top {
  223. display: flex;
  224. justify-content: space-between;
  225. height: 60rpx;
  226. border-bottom: 2rpx solid #F4F4F4;
  227. line-height: 60rpx;
  228. font-size: 26rpx;
  229. .red {
  230. color: #ff0000;
  231. }
  232. .green {
  233. color: #7DBB91;
  234. }
  235. }
  236. .prevents_item_bot {
  237. margin-top: 20rpx;
  238. font-size: 26rpx;
  239. color: #BDBDBD;
  240. }
  241. }
  242. }
  243. .top {
  244. position: fixed;
  245. right: 10px;
  246. bottom: 40px;
  247. z-index: 100;
  248. image {
  249. width: 100rpx;
  250. height: 100rpx;
  251. }
  252. .backtop{
  253. display: flex;
  254. justify-content: flex-end;
  255. margin-bottom: 10rpx;
  256. }
  257. .more{
  258. display: flex;
  259. }
  260. .box{
  261. width: 80rpx;
  262. height: 80rpx;
  263. background-color: rgba(161,161,161,0.45);
  264. border-radius: 50%;
  265. text-align: center;
  266. line-height: 80rpx;
  267. box-sizing: border-box;
  268. margin: 14rpx 10rpx 0 0;
  269. color: #fff;
  270. }
  271. }
  272. </style>