index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. <template>
  2. <!-- 监控管理 -->
  3. <view>
  4. <uv-navbar title="" :placeholder="true" :titleStyle="{color:'#ffffff'}" leftIconColor="#ffffff"
  5. bgColor="#1d345e" @leftClick="leftClick">
  6. <template v-slot:center>
  7. <view class="uv-nav-slot" style="width: 72%;">
  8. <uv-search v-model="monitoringAids" :actionStyle="{color:'#fff'}" placeholder="请输入设备名称"
  9. @search="searchWork" @custom="searchWork"></uv-search>
  10. </view>
  11. </template>
  12. </uv-navbar>
  13. <scroll-view :style="{height: `calc(100vh - ${(headTop + 44) + 'px'})`,}" :scroll-top="scrollTop"
  14. scroll-with-animation="true" scroll-y="true" @scrolltolower="loadMore" @scroll="handleScroll"
  15. :lower-threshold="50">
  16. <view class="camera_type_box">
  17. <view class="item_type_camera">
  18. <view class="camera_bxo_sum">
  19. <text class="iconfont">&#xe6c8;</text>
  20. <view class="sum_title_camera">总量</view>
  21. </view>
  22. <span class="sum_camera" style="color: #39ecf5;">{{totalContent }}</span>
  23. </view>
  24. <!-- <view class="item_type_camera">
  25. <span class="sum_title_camera">在线</span>
  26. <view class="center_in">
  27. <text class="iconfont" style="color: rgb(34, 190, 68);">&#xe62e;</text>
  28. <span class="sum_camera">999</span>
  29. </view>
  30. </view>
  31. <view class="item_type_camera">
  32. <span class="sum_title_camera">离线</span>
  33. <view class="center_in">
  34. <text class="iconfont" style="color: rgb(211, 205, 85);">&#xe6d6;</text>
  35. <span class="sum_camera">999</span>
  36. </view>
  37. </view> -->
  38. </view>
  39. <view class="card_camera" v-if="workData.length > 0">
  40. <view class="camera_item" v-for="(item,index) in workData" :key="index" @click="goparticulars(item)">
  41. <view class="facility_cameraName">{{item.name}}</view>
  42. <view class="facility_code">编号:{{item.indexCode}}</view>
  43. <view class="facility_secondary">区域位置:{{getLocation(item.regionPathName)}}</view>
  44. <view class="camera_img">
  45. <uv-image width="100%" mode="widthFix" height="354rpx" :src="item.url">
  46. <template v-slot:loading>
  47. <uv-loading-icon color="#1599db"></uv-loading-icon>
  48. </template>
  49. <template v-slot:error>
  50. <view style="display: flex;flex-direction: column;align-items: center;">
  51. <uv-icon name="photo" size="30"></uv-icon>
  52. <view style="font-size: 24rpx;">加载失败</view>
  53. </view>
  54. </template>
  55. </uv-image>
  56. </view>
  57. </view>
  58. <view style="padding-bottom:20rpx" v-if="pageNo > 1">
  59. <uv-load-more :status="status" color="#ffffff" />
  60. </view>
  61. </view>
  62. <view style="margin-top: 30%;" v-else>
  63. <x-empty></x-empty>
  64. </view>
  65. </scroll-view>
  66. <view class="top-back" @click="topBack" v-if="backShow">
  67. <text class="iconfont icon_back_top">&#xe806;</text>
  68. </view>
  69. </view>
  70. </template>
  71. <script setup lang="ts">
  72. import { GetCameraSearch } from "@/api/monitoring";
  73. import { ref, nextTick } from 'vue'
  74. const cameraData : any = ref(10)
  75. import { onShow, onReady } from "@dcloudio/uni-app";
  76. onReady(() => {
  77. // #ifdef APP-PLUS
  78. plus.navigator.setStatusBarStyle("light");
  79. // #endif
  80. })
  81. onShow(() => {
  82. // #ifdef APP-PLUS
  83. plus.navigator.setStatusBarStyle("light");
  84. // #endif
  85. nextTick(() => {
  86. pageNo.value = 1
  87. workData.value = []
  88. getCamera()
  89. })
  90. });
  91. const headTop = ref(0)
  92. const scrollTop : any = ref(-1)
  93. const backShow : any = ref(false)
  94. const currentScrollTop = ref(0)
  95. const totalContent = ref(0)
  96. const monitoringAids = ref('')
  97. const status = ref('loadmore')
  98. const workData : any = ref([])
  99. const current = ref(0)
  100. const pageNo = ref(1)
  101. const pageSize = ref(10)
  102. const loadingMore = ref(true)
  103. // 防抖函数
  104. function debounce(func : any, wait : any) {
  105. let timeout : any = null
  106. return function executedFunction(...args : any) {
  107. const later = () => {
  108. clearTimeout(timeout)
  109. func(...args)
  110. }
  111. clearTimeout(timeout)
  112. timeout = setTimeout(later, wait)
  113. }
  114. }
  115. // 处理滚动事件
  116. const handleScroll = debounce((e : any) => {
  117. scrollTop.value = -1
  118. currentScrollTop.value = e.detail.scrollTop
  119. // 滚动超过200px显示返回顶部按钮
  120. backShow.value = e.detail.scrollTop > 200
  121. }, 100)
  122. // 返回顶部
  123. function topBack() {
  124. scrollTop.value = 0
  125. setTimeout(() => {
  126. backShow.value = false
  127. }, 300)
  128. }
  129. // 获取监控点列表
  130. const getCamera = () => {
  131. GetCameraSearch({
  132. pageNo: pageNo.value,
  133. pageSize: pageSize.value,
  134. name: monitoringAids.value,
  135. }).then((res : any) => {
  136. if (res.code == 200) {
  137. const data = res.data.list
  138. totalContent.value = res.data.total
  139. if (data.length > 0) {
  140. workData.value = workData.value.concat(data)
  141. }
  142. if (data.length < pageSize.value) {
  143. status.value = 'nomore'
  144. loadingMore.value = true
  145. } else {
  146. status.value = 'loading'
  147. loadingMore.value = false
  148. pageNo.value++
  149. }
  150. }
  151. })
  152. }
  153. // 加载更多数据
  154. const loadMore = () => {
  155. console.log('到底了吗');
  156. if (!loadingMore.value) {
  157. getCamera()
  158. }
  159. };
  160. // 获取位置/截取
  161. function getLocation(params) {
  162. if (!params) {
  163. return ''
  164. }
  165. const parts = params.split('/').filter(p => p)
  166. if (parts.length > 2) {
  167. return `${parts[parts.length - 2]}/${parts[parts.length - 1]}`
  168. }
  169. return parts.join(' / ')
  170. }
  171. // 搜索监控设备
  172. const searchWork = () => {
  173. pageNo.value = 1
  174. workData.value = []
  175. getCamera()
  176. }
  177. // 监控详情
  178. const goparticulars = (val : any) => {
  179. uni.navigateTo({
  180. url: '/pages/monitoring/particulars?indexCode=' + val.indexCode,
  181. })
  182. }
  183. function leftClick() {
  184. uni.navigateBack({
  185. delta: 1
  186. });
  187. }
  188. </script>
  189. <style lang="scss" scoped>
  190. .scroll-container {
  191. height: calc(100vh - 88rpx) // 减去搜索框的高度
  192. }
  193. .center_in {
  194. display: flex;
  195. justify-content: center;
  196. align-items: center;
  197. flex-direction: column;
  198. }
  199. .camera_type_box {
  200. display: flex;
  201. align-items: center;
  202. justify-content: space-between;
  203. margin: 20rpx 30rpx 0rpx 30rpx;
  204. }
  205. .item_type_camera {
  206. width: calc(100% - 40rpx);
  207. // width: calc(32% - 40rpx);
  208. display: flex;
  209. align-items: center;
  210. justify-content: space-between;
  211. // height: 200rpx;
  212. background-color: rgba(85, 110, 143, .3);
  213. border-radius: 10rpx;
  214. padding: 20rpx;
  215. }
  216. .sum_title_camera {
  217. font-size: 30rpx;
  218. color: #fff;
  219. margin-left: 20rpx;
  220. }
  221. .camera_bxo_sum {
  222. display: flex;
  223. align-items: center;
  224. }
  225. .iconfont {
  226. color: rgb(57, 236, 245);
  227. font-size: 60rpx;
  228. margin-bottom: 5rpx;
  229. }
  230. .sum_camera {
  231. color: #fff;
  232. font-weight: bold;
  233. font-size: 32rpx;
  234. margin-right: 10rpx;
  235. }
  236. .card_camera {
  237. display: flex;
  238. flex-direction: column;
  239. }
  240. .camera_item {
  241. padding: 30rpx;
  242. margin: 30rpx 30rpx 0rpx 30rpx;
  243. background-color: rgba(85, 110, 143, .3);
  244. border-radius: 10rpx;
  245. }
  246. .camera_img {
  247. margin-top: 20rpx;
  248. width: 100%;
  249. height: 350rpx;
  250. }
  251. .camera_img_video {
  252. width: 100%;
  253. height: 100%;
  254. }
  255. .facility_cameraName {
  256. color: #fff;
  257. font-size: 30rpx;
  258. font-weight: bold;
  259. }
  260. .facility_secondary {
  261. font-size: 26rpx;
  262. color: #DCDFE6;
  263. }
  264. .facility_code {
  265. margin-top: 4rpx;
  266. font-size: 26rpx;
  267. color: #DCDFE6;
  268. }
  269. .search_card {
  270. display: flex;
  271. align-items: center;
  272. margin: 20rpx 30rpx 0rpx 30rpx;
  273. }
  274. .top-back {
  275. position: fixed;
  276. right: 30rpx;
  277. bottom: 120rpx;
  278. width: 80rpx;
  279. height: 80rpx;
  280. background: rgba(0, 0, 0, 0.5);
  281. border-radius: 50%;
  282. display: flex;
  283. flex-direction: column;
  284. justify-content: center;
  285. align-items: center;
  286. color: white;
  287. font-size: 28rpx;
  288. z-index: 999;
  289. animation: heart 0.3s;
  290. @keyframes heart {
  291. 0% {
  292. right: -30rpx;
  293. }
  294. 100% {
  295. right: 30rpx;
  296. }
  297. }
  298. }
  299. .icon_back_top {
  300. color: #fff;
  301. font-size: 46rpx;
  302. }
  303. </style>