search.vue 7.6 KB

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