search.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  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;background-color: #FFFFFF;height: 80px;">
  6. <uni-nav-bar @clickLeft="clickLeft" left-icon="back" left-text="返回" title="设备搜索"></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>设备 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://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. async getthxyEquipList(act) {
  88. this.loadingtf = true
  89. const res = await this.$myRequest({
  90. url: '/api/api_gateway?method=forecast.worm_lamp.xy_three_list',
  91. data: {
  92. device_type_id: this.device_id,
  93. page: this.page,
  94. page_size: 10,
  95. device_id: this.imports,
  96. }
  97. })
  98. this.eqlistdata = this.eqlistdata.concat(res.data)
  99. console.log(res)
  100. if(this.eqlistdata.length==0){
  101. this.none = true
  102. }else{
  103. this.none = false
  104. }
  105. },
  106. async getxctEquipList(act) {
  107. this.loadingtf = true
  108. const res = await this.$myRequest({
  109. url: '/api/api_gateway?method=forecast.worm_lamp.xct_list',
  110. data: {
  111. device_type_id: this.device_id,
  112. page: this.page,
  113. page_size: 10,
  114. device_id: this.imports,
  115. }
  116. })
  117. this.eqlistdata = this.eqlistdata.concat(res.data)
  118. console.log(res)
  119. if(this.eqlistdata.length==0){
  120. this.none = true
  121. }else{
  122. this.none = false
  123. }
  124. },
  125. searchinp(){
  126. Debounce(() => {
  127. this.eqlistdata = []
  128. this.page = 1
  129. if (this.device_id == 8) {
  130. this.getthxyEquipList(8)
  131. } else if (this.device_id == 12) {
  132. this.getxctEquipList(12)
  133. } else if (this.device_id == 10) {
  134. this.getxyEquipList(10)
  135. } else {
  136. this.searchEquip(this.device_id)
  137. }
  138. }, 1000)()
  139. },
  140. search(){
  141. this.eqlistdata = []
  142. this.page = 1
  143. if (this.device_id == 8) {
  144. this.getthxyEquipList(8)
  145. } else if (this.device_id == 12) {
  146. this.getxctEquipList(12)
  147. } else if (this.device_id == 10) {
  148. this.getxyEquipList(10)
  149. } else {
  150. this.searchEquip(this.device_id)
  151. }
  152. },
  153. clickLeft(){
  154. uni.navigateTo({
  155. url:"./index"
  156. })
  157. },
  158. top() {
  159. uni.pageScrollTo({
  160. scrollTop: 0,
  161. duration: 500
  162. })
  163. },
  164. eqdetails(item){
  165. item.type = Number(this.device_id)
  166. console.log(item)
  167. let data = JSON.stringify(item)
  168. if (item.type == 10) {
  169. uni.navigateTo({
  170. url: '/pages/cb/xy2.0/particulars?info=' + data
  171. });
  172. } else if (item.type == 8) {
  173. console.log(data)
  174. uni.navigateTo({
  175. url: '/pages/cb/thxydetail/thxydetail?imei=' + item.imei
  176. });
  177. } else if (item.type == 12) {
  178. uni.navigateTo({
  179. url: '/pages/cb/xctdetail/xctdetail?info=' + data
  180. });
  181. } else{
  182. uni.navigateTo({
  183. url: '/pages/cb/equip-detail/equip-detail?info=' + data
  184. });
  185. }
  186. }
  187. },
  188. onLoad(option){
  189. this.device_id = option.device_id
  190. },
  191. onReachBottom() {
  192. this.page++
  193. console.log(1)
  194. if (this.device_id == 8) {
  195. this.getthxyEquipList(8)
  196. } else if (this.device_id == 12) {
  197. this.getxctEquipList(12)
  198. } else if (this.device_id == 10) {
  199. this.getxyEquipList(10)
  200. } else {
  201. this.searchEquip(this.device_id)
  202. }
  203. },
  204. onBackPress(options) {
  205. if (options.from === 'navigateBack') {
  206. return false;
  207. }
  208. this.clickLeft();
  209. return true;
  210. },
  211. onPageScroll(e) { //nvue暂不支持滚动监听,可用bindingx代替
  212. if (e.scrollTop > 200) { //距离大于200时显示
  213. this.isTop = true
  214. } else { //距离小于200时隐藏
  215. this.isTop = false
  216. }
  217. },
  218. }
  219. </script>
  220. <style lang="scss">
  221. .search_top_input {
  222. width: 90%;
  223. height: 54rpx;
  224. background-color: #E4E4E4;
  225. border-radius: 27rpx;
  226. position: absolute;
  227. top: 100rpx;
  228. right: 5%;
  229. padding-top: 8rpx;
  230. box-sizing: border-box;
  231. input {
  232. width: 85%;
  233. // text-indent: 1rem;
  234. font-size: 26rpx;
  235. padding-left: 20px;
  236. // box-sizing: border-box;
  237. }
  238. .icon {
  239. position: absolute;
  240. top: 8rpx;
  241. right: 26rpx;
  242. }
  243. }
  244. .nonetishi{
  245. width: 100%;
  246. position: absolute;
  247. top: 60px;
  248. height: 200rpx;
  249. text-align: center;
  250. line-height: 200rpx;
  251. font-size: 16px;
  252. }
  253. .prevents {
  254. width: 100%;
  255. position: absolute;
  256. top: 100px;
  257. .prevents_item {
  258. width: 95%;
  259. margin: 0 auto 30rpx;
  260. border-radius: 10rpx;
  261. box-shadow: 0 0 10rpx #bcb9ca;
  262. padding: 20rpx 40rpx 20rpx 80rpx;
  263. box-sizing: border-box;
  264. position: relative;
  265. .prevents_item_img {
  266. width: 30rpx;
  267. height: 50rpx;
  268. position: absolute;
  269. top: -4rpx;
  270. left: 30rpx;
  271. }
  272. .prevents_item_top {
  273. display: flex;
  274. justify-content: space-between;
  275. height: 60rpx;
  276. border-bottom: 2rpx solid #F4F4F4;
  277. line-height: 60rpx;
  278. font-size: 26rpx;
  279. .red {
  280. color: #ff0000;
  281. }
  282. .green {
  283. color: #7DBB91;
  284. }
  285. }
  286. .prevents_item_bot {
  287. margin-top: 20rpx;
  288. font-size: 26rpx;
  289. color: #BDBDBD;
  290. }
  291. }
  292. }
  293. .top {
  294. position: fixed;
  295. right: 30px;
  296. bottom: 100px;
  297. z-index: 100;
  298. image{
  299. width: 100rpx;
  300. height: 100rpx;
  301. }
  302. }
  303. </style>