search.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  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. item.pur_id = this.pur_id
  171. let data = JSON.stringify(item)
  172. if (item.type == 10) {
  173. uni.navigateTo({
  174. url: '/pages/cb/xy2.0/particulars?info=' + data
  175. });
  176. } else if (item.type == 8) {
  177. console.log(data)
  178. uni.navigateTo({
  179. url: '/pages/cb/thxydetail/thxydetail?imei=' + item.imei
  180. });
  181. } else if (item.type == 12) {
  182. uni.navigateTo({
  183. url: '/pages/cb/xctdetail/xctdetail?info=' + data
  184. });
  185. }else if (item.type == 32||item.type == 33||item.type == 34||item.type == 35) {
  186. uni.navigateTo({
  187. url: '/pages/cb/equip-detail/equip-detail-new?info=' + data
  188. });
  189. }else{
  190. uni.navigateTo({
  191. url: '/pages/cb/equip-detail/equip-detail?info=' + data
  192. });
  193. }
  194. }
  195. },
  196. onLoad(option){
  197. this.device_id = option.device_id
  198. this.pur_id = option.pur_id
  199. },
  200. onReachBottom() {
  201. this.page++
  202. console.log(1)
  203. if (this.device_id == 8) {
  204. this.getthxyEquipList(8)
  205. } else if (this.device_id == 12) {
  206. this.getxctEquipList(12)
  207. } else if (this.device_id == 10) {
  208. this.getxyEquipList(10)
  209. } else {
  210. this.searchEquip(this.device_id)
  211. }
  212. },
  213. onBackPress(options) {
  214. if (options.from === 'navigateBack') {
  215. return false;
  216. }
  217. this.clickLeft();
  218. return true;
  219. },
  220. onPageScroll(e) { //nvue暂不支持滚动监听,可用bindingx代替
  221. if (e.scrollTop > 200) { //距离大于200时显示
  222. this.isTop = true
  223. } else { //距离小于200时隐藏
  224. this.isTop = false
  225. }
  226. },
  227. }
  228. </script>
  229. <style lang="scss">
  230. .search_top_input {
  231. width: 90%;
  232. height: 54rpx;
  233. background-color: #E4E4E4;
  234. border-radius: 27rpx;
  235. position: absolute;
  236. top: 100rpx;
  237. right: 5%;
  238. padding-top: 8rpx;
  239. box-sizing: border-box;
  240. input {
  241. width: 85%;
  242. // text-indent: 1rem;
  243. font-size: 26rpx;
  244. padding-left: 20px;
  245. // box-sizing: border-box;
  246. }
  247. .icon {
  248. position: absolute;
  249. top: 8rpx;
  250. right: 26rpx;
  251. }
  252. }
  253. .nonetishi{
  254. width: 100%;
  255. position: absolute;
  256. top: 60px;
  257. height: 200rpx;
  258. text-align: center;
  259. line-height: 200rpx;
  260. font-size: 16px;
  261. }
  262. .prevents {
  263. width: 100%;
  264. position: absolute;
  265. top: 100px;
  266. .prevents_item {
  267. width: 95%;
  268. margin: 0 auto 30rpx;
  269. border-radius: 10rpx;
  270. box-shadow: 0 0 10rpx #bcb9ca;
  271. padding: 20rpx 40rpx 20rpx 80rpx;
  272. box-sizing: border-box;
  273. position: relative;
  274. .prevents_item_img {
  275. width: 30rpx;
  276. height: 50rpx;
  277. position: absolute;
  278. top: -4rpx;
  279. left: 30rpx;
  280. }
  281. .prevents_item_top {
  282. display: flex;
  283. justify-content: space-between;
  284. height: 60rpx;
  285. border-bottom: 2rpx solid #F4F4F4;
  286. line-height: 60rpx;
  287. font-size: 26rpx;
  288. .red {
  289. color: #ff0000;
  290. }
  291. .green {
  292. color: #7DBB91;
  293. }
  294. }
  295. .prevents_item_bot {
  296. margin-top: 20rpx;
  297. font-size: 26rpx;
  298. color: #BDBDBD;
  299. }
  300. }
  301. }
  302. .top {
  303. position: fixed;
  304. right: 30px;
  305. bottom: 100px;
  306. z-index: 100;
  307. image{
  308. width: 100rpx;
  309. height: 100rpx;
  310. }
  311. }
  312. </style>