search.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  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 || item.device_id}}</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>设备名称:{{item.device_name}}</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://static.yfpyx.com/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. page: this.page,
  75. page_size: 10,
  76. }
  77. })
  78. this.eqlistdata = this.eqlistdata.concat(res.data)
  79. console.log(res)
  80. if(this.eqlistdata.length==0){
  81. this.none = true
  82. }else{
  83. this.none = false
  84. }
  85. },
  86. searchinp(){
  87. Debounce(() => {
  88. this.eqlistdata = []
  89. this.page = 1
  90. if(this.device_id==10){
  91. this.getxyEquipList()
  92. }else{
  93. this.searchEquip()
  94. }
  95. }, 1000)()
  96. },
  97. search(){
  98. this.eqlistdata = []
  99. this.page = 1
  100. if(this.device_id==10){
  101. this.getxyEquipList()
  102. }else{
  103. this.searchEquip()
  104. }
  105. },
  106. clickLeft(){
  107. uni.navigateTo({
  108. url:"./index"
  109. })
  110. },
  111. top() {
  112. uni.pageScrollTo({
  113. scrollTop: 0,
  114. duration: 500
  115. })
  116. },
  117. eqdetails(item){
  118. item.type = Number(this.device_id)
  119. console.log(item)
  120. let data = JSON.stringify(item)
  121. if(item.type==10){
  122. uni.navigateTo({
  123. url: '/pages/cb/xy2.0/particulars?info=' + data
  124. });
  125. }else{
  126. uni.navigateTo({
  127. url: '/pages/cb/equip-detail/equip-detail?info=' + data
  128. });
  129. }
  130. }
  131. },
  132. onLoad(option){
  133. this.device_id = option.device_id
  134. },
  135. onReachBottom() {
  136. this.page++
  137. console.log(1)
  138. if(this.device_id==10){
  139. this.getxyEquipList()
  140. }else{
  141. this.searchEquip()
  142. }
  143. },
  144. onBackPress(options) {
  145. if (options.from === 'navigateBack') {
  146. return false;
  147. }
  148. this.clickLeft();
  149. return true;
  150. },
  151. onPageScroll(e) { //nvue暂不支持滚动监听,可用bindingx代替
  152. if (e.scrollTop > 200) { //距离大于200时显示
  153. this.isTop = true
  154. } else { //距离小于200时隐藏
  155. this.isTop = false
  156. }
  157. },
  158. }
  159. </script>
  160. <style lang="scss">
  161. .search_top_input {
  162. width: 80%;
  163. height: 54rpx;
  164. background-color: #E4E4E4;
  165. border-radius: 27rpx;
  166. position: absolute;
  167. top: 33rpx;
  168. right: 18rpx;
  169. padding-top: 8rpx;
  170. box-sizing: border-box;
  171. input {
  172. width: 85%;
  173. // text-indent: 1rem;
  174. font-size: 26rpx;
  175. padding-left: 20px;
  176. box-sizing: border-box;
  177. }
  178. .icon {
  179. position: absolute;
  180. top: 8rpx;
  181. right: 26rpx;
  182. }
  183. }
  184. .nonetishi{
  185. width: 100%;
  186. position: absolute;
  187. top: 60px;
  188. height: 200rpx;
  189. text-align: center;
  190. line-height: 200rpx;
  191. font-size: 22px;
  192. }
  193. .prevents {
  194. width: 100%;
  195. position: absolute;
  196. top: 60px;
  197. .prevents_item {
  198. width: 95%;
  199. margin: 0 auto 30rpx;
  200. border-radius: 10rpx;
  201. box-shadow: 0 0 10rpx #bcb9ca;
  202. padding: 20rpx 40rpx 20rpx 80rpx;
  203. box-sizing: border-box;
  204. position: relative;
  205. .prevents_item_img {
  206. width: 30rpx;
  207. height: 50rpx;
  208. position: absolute;
  209. top: -4rpx;
  210. left: 30rpx;
  211. }
  212. .prevents_item_top {
  213. display: flex;
  214. justify-content: space-between;
  215. height: 60rpx;
  216. border-bottom: 2rpx solid #F4F4F4;
  217. line-height: 60rpx;
  218. font-size: 26rpx;
  219. .red {
  220. color: #ff0000;
  221. }
  222. .green {
  223. color: #7DBB91;
  224. }
  225. }
  226. .prevents_item_bot {
  227. margin-top: 20rpx;
  228. font-size: 26rpx;
  229. color: #BDBDBD;
  230. }
  231. }
  232. }
  233. .top {
  234. position: fixed;
  235. right: 30px;
  236. bottom: 100px;
  237. z-index: 100;
  238. image{
  239. width: 100rpx;
  240. height: 100rpx;
  241. }
  242. }
  243. </style>