search.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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;padding-top: 20rpx;background-color: #FFFFFF;">
  6. <uni-nav-bar @clickLeft="clickLeft" left-icon="back" left-text="返回"></uni-nav-bar>
  7. <view class="search_top_input">
  8. <input type="text" value="" placeholder="请输入设备ID" v-model="imports" @input="searchinp" />
  9. <u-icon name="search" size="40" class="icon" @click="search"></u-icon>
  10. </view>
  11. </view>
  12. <view class="nonetishi" v-if="none">
  13. 暂无此设备
  14. </view>
  15. <view class="prevents" v-else>
  16. <view class="prevents_item" v-for="item,index in eqlistdata" :key="index" @click="eqdetails(item)">
  17. <image :src="item.is_online==1?'http://static.yfpyx.com/bigdata_app/image/prevention/6.png':'http://static.yfpyx.com/bigdata_app/image/prevention/7.png'" mode=""
  18. class="prevents_item_img"></image>
  19. <view class="prevents_item_top">
  20. <p>设备 ID:{{item.imei}}</p>
  21. <p :class="item.is_online==1?'green':'red'" v-text="item.is_online==1?'在线':'离线'"></p>
  22. </view>
  23. <view class="prevents_item_bot">
  24. 最新上报时间:{{item.addtime|timeFormat()}}
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. <view class="top" v-if="isTop" @click="top">
  30. <image :src="$appimghost+'/image/6209a98f0cb3b5086f2ca36152c9269.png'" mode=""></image>
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. import {
  36. Debounce,
  37. Throttle
  38. } from "../../../util/anitthro.js"
  39. export default {
  40. data() {
  41. return {
  42. imports:"",
  43. device_id:'',
  44. page:1,
  45. eqlistdata:[],
  46. isTop:false,
  47. none:false
  48. }
  49. },
  50. methods: {
  51. async searchEquip() {
  52. const res = await this.$myRequest({
  53. url: '/api/api_gateway?method=forecast.worm_lamp.lamp_list',
  54. data: {
  55. device_type_id: this.device_id,
  56. device_id: this.imports,
  57. page:this.page
  58. }
  59. })
  60. this.eqlistdata = this.eqlistdata.concat(res.data)
  61. console.log(res)
  62. if(this.eqlistdata.length==0){
  63. this.none = true
  64. }else{
  65. this.none = false
  66. }
  67. },
  68. searchinp(){
  69. Debounce(() => {
  70. this.eqlistdata = []
  71. this.page = 1
  72. this.searchEquip()
  73. }, 1000)()
  74. },
  75. search(){
  76. this.eqlistdata = []
  77. this.page = 1
  78. this.searchEquip()
  79. },
  80. clickLeft(){
  81. uni.navigateTo({
  82. url:"./index"
  83. })
  84. },
  85. top() {
  86. uni.pageScrollTo({
  87. scrollTop: 0,
  88. duration: 500
  89. })
  90. },
  91. eqdetails(item){
  92. item.type = Number(this.device_id)
  93. console.log(item)
  94. let data = JSON.stringify(item)
  95. uni.navigateTo({
  96. url: '/pages/cb/equip-detail/equip-detail?info=' + data
  97. });
  98. }
  99. },
  100. onLoad(option){
  101. this.device_id = option.device_id
  102. console.log(this.device_id)
  103. },
  104. onReachBottom() {
  105. this.page++
  106. console.log(1)
  107. this.searchEquip()
  108. },
  109. onBackPress(options) {
  110. if (options.from === 'navigateBack') {
  111. return false;
  112. }
  113. this.clickLeft();
  114. return true;
  115. },
  116. onPageScroll(e) { //nvue暂不支持滚动监听,可用bindingx代替
  117. if (e.scrollTop > 200) { //距离大于200时显示
  118. this.isTop = true
  119. } else { //距离小于200时隐藏
  120. this.isTop = false
  121. }
  122. },
  123. }
  124. </script>
  125. <style lang="scss">
  126. .search_top_input {
  127. width: 80%;
  128. height: 54rpx;
  129. background-color: #E4E4E4;
  130. border-radius: 27rpx;
  131. position: absolute;
  132. top: 33rpx;
  133. right: 18rpx;
  134. padding-top: 8rpx;
  135. box-sizing: border-box;
  136. input {
  137. width: 85%;
  138. text-indent: 1rem;
  139. font-size: 26rpx;
  140. }
  141. .icon {
  142. position: absolute;
  143. top: 8rpx;
  144. right: 26rpx;
  145. }
  146. }
  147. .nonetishi{
  148. width: 100%;
  149. position: absolute;
  150. top: 60px;
  151. height: 200rpx;
  152. text-align: center;
  153. line-height: 200rpx;
  154. font-size: 22px;
  155. }
  156. .prevents {
  157. width: 100%;
  158. position: absolute;
  159. top: 60px;
  160. .prevents_item {
  161. width: 95%;
  162. margin: 0 auto 30rpx;
  163. border-radius: 10rpx;
  164. box-shadow: 0 0 10rpx #bcb9ca;
  165. padding: 20rpx 40rpx 20rpx 80rpx;
  166. box-sizing: border-box;
  167. position: relative;
  168. .prevents_item_img {
  169. width: 30rpx;
  170. height: 50rpx;
  171. position: absolute;
  172. top: -4rpx;
  173. left: 30rpx;
  174. }
  175. .prevents_item_top {
  176. display: flex;
  177. justify-content: space-between;
  178. height: 60rpx;
  179. border-bottom: 2rpx solid #F4F4F4;
  180. line-height: 60rpx;
  181. font-size: 26rpx;
  182. .red {
  183. color: #ff0000;
  184. }
  185. .green {
  186. color: #7DBB91;
  187. }
  188. }
  189. .prevents_item_bot {
  190. margin-top: 20rpx;
  191. font-size: 26rpx;
  192. color: #BDBDBD;
  193. }
  194. }
  195. }
  196. .top {
  197. position: fixed;
  198. right: 30px;
  199. bottom: 100px;
  200. z-index: 100;
  201. image{
  202. width: 100rpx;
  203. height: 100rpx;
  204. }
  205. }
  206. </style>