index.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <template>
  2. <!-- 可视监控 -->
  3. <view class="camera-panel">
  4. <view class="camera-list">
  5. <!-- 监控列表 -->
  6. <block v-for="(item,index) in cameraList" :key="index">
  7. <view class="camera-item" @click="openCameraDetails(item.device_id)">
  8. <image class="pic" mode="aspectFill" :src="item.jk_live_img">
  9. </image>
  10. <view class="row-between p-10">
  11. <text class="text">{{item.device_id}}</text>
  12. <text class="tips" :calss="item.status?'':'close'"></text>
  13. </view>
  14. </view>
  15. </block>
  16. <!-- 监控列表end -->
  17. </view>
  18. <ui-empty v-if="cameraList.length==0"></ui-empty>
  19. </view>
  20. </template>
  21. <script>
  22. import {
  23. getCameraList
  24. } from '@/api/camera.js'
  25. export default {
  26. data() {
  27. return {
  28. params: {
  29. page: 1,
  30. page_size: 10,
  31. // device_id:
  32. },
  33. // 监控列表
  34. cameraList: [],
  35. total: 0, // 设备总数
  36. };
  37. },
  38. onLoad() {
  39. this.getCameraList();
  40. },
  41. onReachBottom(e) {
  42. if (this.cameraList.length >= this.total) {
  43. return;
  44. }
  45. this.params.page += 1;
  46. this.getCameraList();
  47. },
  48. methods: {
  49. // 获取监控列表
  50. async getCameraList() {
  51. this.$api.loading('加载中...');
  52. const {
  53. data,
  54. counts
  55. } = await getCameraList(this.params);
  56. this.$api.hide();
  57. this.cameraList = [...this.cameraList, ...data];
  58. this.total = counts;
  59. },
  60. /**
  61. * 打开监控详情
  62. * @param {string} id 设备id
  63. */
  64. openCameraDetails(id) {
  65. uni.navigateTo({
  66. url: `details?id=${id}`
  67. })
  68. }
  69. }
  70. }
  71. </script>
  72. <style lang="scss">
  73. // 可视监控面板
  74. .camera-panel {
  75. padding: 24rpx;
  76. margin-top: 24rpx;
  77. background-color: #fff;
  78. }
  79. .camera-list {
  80. display: flex;
  81. flex-wrap: wrap;
  82. }
  83. // 可视列表项
  84. .camera-item {
  85. width: 336rpx;
  86. margin-right: 28rpx;
  87. margin-bottom: 24rpx;
  88. border-radius: 12rpx;
  89. border: 1rpx solid #F1F1F1;
  90. &:nth-child(2n) {
  91. margin-right: 0;
  92. }
  93. .pic {
  94. display: block;
  95. width: 336rpx;
  96. height: 255rpx;
  97. border-radius: 4rpx;
  98. }
  99. .text {
  100. font-size: 20rpx;
  101. color: #666666;
  102. }
  103. .tips {
  104. width: 24rpx;
  105. height: 24rpx;
  106. background: #07F546;
  107. border-radius: 100%;
  108. &.close {
  109. background: #e93f27;
  110. }
  111. }
  112. }
  113. </style>