search.vue 7.3 KB

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