search.vue 5.4 KB

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