search.vue 7.2 KB

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