search.vue 7.3 KB

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