index.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. <template>
  2. <view class="">
  3. <view class="status_bar"></view>
  4. <view class="" style="position: relative;top: 44px;">
  5. <view style="position: fixed;z-index: 100;">
  6. <uni-nav-bar @clickLeft="clickLeft" left-icon="back" left-text="返回" title="监控系统" right-icon="search"
  7. @clickRight="clickRight" size="16"></uni-nav-bar>
  8. <view class="inputs" :style="{'width':width+'rpx'}">
  9. <input type="text" value="" placeholder="请输入设备ID或设备名称" v-model="imports" @input="searchinp"
  10. class="inputbox" :clearable="false" />
  11. <u-icon name="search" size="40" class="icon" @click="search"></u-icon>
  12. </view>
  13. <view class="" style="margin-top: -10rpx;">
  14. <image :src="$imageURL+'/bigdata_app/image/monitor/banner.png'" mode="widthFix">
  15. </image>
  16. </view>
  17. </view>
  18. <view class="loading" v-if="loadingtf">
  19. <image src="../../static/images/ajax-loader.gif" mode="" class="img"></image>
  20. </view>
  21. <view class="contenttf" v-if="contenttf">
  22. 暂无数据
  23. </view>
  24. <view class="content" v-else>
  25. <template v-for="(item,index) in listArr">
  26. <equipItem @click.native="itemClick(item)" v-bind:item="item" :key="index">
  27. <view class="content_title">
  28. <view class="" style="font-size:28rpx;color: #999;">
  29. 设备ID:{{item.device_id}}
  30. </view>
  31. <!-- @click.stop="modification(item)" -->
  32. <view class="sim" v-if="item.sim" @click.stop="siminfo(item.sim)">
  33. SIM卡
  34. </view>
  35. </view>
  36. <view class="type-name">
  37. <u-icon name="jiankong" custom-prefix="custom-icon"
  38. :class="item.is_online==1?'icon':'noicon'"></u-icon>
  39. <text>
  40. 监控
  41. </text>
  42. </view>
  43. </equipItem>
  44. </template>
  45. </view>
  46. </view>
  47. <view class="top" v-if="isTop" @click="top">
  48. <image :src="$imageURL+'/bigdata_app/image/6209a98f0cb3b5086f2ca36152c9269.png'" mode="">
  49. </image>
  50. </view>
  51. </view>
  52. </template>
  53. <script>
  54. import {
  55. Debounce
  56. } from "../../util/anitthro.js"
  57. import equipItem from "../../components/equip-item/equip-item"
  58. export default {
  59. data() {
  60. return {
  61. listArr: [],
  62. page: 1,
  63. accessToken: '',
  64. counts: '',
  65. isTop: false,
  66. contenttf: false,
  67. width: 0, //顶部搜索栏宽度
  68. imports: "", //搜索id
  69. loadingtf:false,//loading
  70. }
  71. },
  72. onLoad() {
  73. this.getEquipList()
  74. },
  75. onPullDownRefresh() {
  76. this.page = 1
  77. this.listArr = []
  78. this.getEquipList()
  79. setTimeout(() => {
  80. uni.stopPullDownRefresh()
  81. }, 1000)
  82. },
  83. onReachBottom() {
  84. this.page++
  85. if (this.counts == this.listArr.length) {
  86. return false
  87. }
  88. this.getEquipList()
  89. },
  90. onPageScroll(e) { //nvue暂不支持滚动监听,可用bindingx代替
  91. if (e.scrollTop > 200) { //距离大于200时显示
  92. this.isTop = true
  93. } else { //距离小于200时隐藏
  94. this.isTop = false
  95. }
  96. },
  97. methods: {
  98. async getEquipList() {
  99. this.loadingtf = true
  100. const res = await this.$myRequest({
  101. url: '/api/api_gateway?method=camera.camera_manage.list_camera',
  102. data: {
  103. page: this.page,
  104. page_size: 10,
  105. device_id: this.imports,
  106. }
  107. })
  108. this.loadingtf = false
  109. console.log(res)
  110. if (res.counts == 0) {
  111. this.contenttf = true
  112. } else {
  113. this.contenttf = false
  114. }
  115. let data = res.data
  116. let arr = data.map(item => {
  117. item.imei = item.device_id
  118. item.is_online = item.status
  119. return {
  120. ...item,
  121. device_status: item.status
  122. }
  123. })
  124. console.log(res)
  125. console.log(this.listArr)
  126. this.listArr = [...this.listArr, ...arr]
  127. this.accessToken = res.accessToken
  128. this.counts = res.counts
  129. },
  130. clickLeft() {
  131. uni.switchTab({
  132. url: "../index/index"
  133. })
  134. },
  135. itemClick(item) {
  136. uni.navigateTo({
  137. url: "/pages/webview?device_id=" + item.device_id + "&accessToken=" + uni.getStorageSync('session_key')
  138. })
  139. },
  140. top() {
  141. uni.pageScrollTo({
  142. scrollTop: 0,
  143. duration: 500
  144. })
  145. },
  146. siminfo(sim) {
  147. uni.navigateTo({
  148. url: "./sim?simid=" + sim
  149. })
  150. },
  151. clickRight() {
  152. // uni.navigateTo({
  153. // url: "./search"
  154. // })
  155. this.width = 600
  156. },
  157. search() { //搜索按钮搜索
  158. this.listArr = []
  159. this.getEquipList()
  160. },
  161. searchinp() { //自动搜索
  162. Debounce(() => {
  163. this.listArr = []
  164. this.getEquipList()
  165. }, 1000)()
  166. },
  167. },
  168. components: {
  169. equipItem
  170. }
  171. }
  172. </script>
  173. <style lang="scss">
  174. image {
  175. width: 100%;
  176. }
  177. .inputs {
  178. height: 54rpx;
  179. background-color: #E4E4E4;
  180. border-radius: 27rpx;
  181. position: absolute;
  182. right: 20rpx;
  183. top: 20rpx;
  184. transition: width 0.5s;
  185. overflow: hidden;
  186. padding-top: 8rpx;
  187. box-sizing: border-box;
  188. .inputbox {
  189. width: 85%;
  190. text-indent: 1rem;
  191. font-size: 26rpx;
  192. }
  193. .icon {
  194. position: absolute;
  195. top: 8rpx;
  196. right: 26rpx;
  197. }
  198. }
  199. .type-name {
  200. color: #999;
  201. display: flex;
  202. justify-content: flex-start;
  203. font-size: 12px;
  204. .icon {
  205. font-size: 32rpx;
  206. color: #19BE6B;
  207. }
  208. .noicon {
  209. font-size: 32rpx;
  210. color: #f00;
  211. }
  212. text {
  213. margin-left: 10px;
  214. }
  215. }
  216. .contenttf {
  217. position: absolute;
  218. top: 170px;
  219. width: 95%;
  220. left: 2.5%;
  221. text-align: center;
  222. font-size: 20px;
  223. }
  224. .loading{
  225. position: fixed;
  226. top: 440px;
  227. width: 95%;
  228. left: 2.5%;
  229. text-align: center;
  230. .img{
  231. width: 300rpx;
  232. height: 40rpx;
  233. }
  234. }
  235. .content {
  236. position: absolute;
  237. top: 130px;
  238. width: 95%;
  239. left: 2.5%;
  240. .content_title {
  241. display: flex;
  242. justify-content: space-between;
  243. .sim {
  244. width: 126rpx;
  245. color: #42b983;
  246. height: 40rpx;
  247. text-align: center;
  248. border: 1rpx solid #42b983;
  249. border-radius: 25rpx;
  250. font-size: 24rpx;
  251. line-height: 35rpx;
  252. position: absolute;
  253. top: 100rpx;
  254. right: 20rpx;
  255. }
  256. }
  257. }
  258. .top {
  259. position: fixed;
  260. right: 30px;
  261. bottom: 100px;
  262. z-index: 100;
  263. image {
  264. width: 100rpx;
  265. height: 100rpx;
  266. }
  267. }
  268. </style>