index.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. async onLoad() {
  39. await this.$onLaunched;
  40. this.getCameraList();
  41. },
  42. onReachBottom(e) {
  43. if (this.cameraList.length >= this.total) {
  44. return;
  45. }
  46. this.params.page += 1;
  47. this.getCameraList();
  48. },
  49. methods: {
  50. // 获取监控列表
  51. async getCameraList() {
  52. this.$api.loading('加载中...');
  53. const {
  54. data,
  55. counts
  56. } = await getCameraList(this.params);
  57. this.$api.hide();
  58. this.cameraList = [...this.cameraList, ...data];
  59. this.total = counts;
  60. },
  61. /**
  62. * 打开监控详情
  63. * @param {string} id 设备id
  64. */
  65. openCameraDetails(id) {
  66. uni.navigateTo({
  67. url: `details?id=${id}`
  68. })
  69. }
  70. }
  71. }
  72. </script>
  73. <style lang="scss">
  74. // 可视监控面板
  75. .camera-panel {
  76. padding: 24rpx;
  77. margin-top: 24rpx;
  78. background-color: #fff;
  79. }
  80. .camera-list {
  81. display: flex;
  82. flex-wrap: wrap;
  83. }
  84. // 可视列表项
  85. .camera-item {
  86. width: 336rpx;
  87. margin-right: 28rpx;
  88. margin-bottom: 24rpx;
  89. border-radius: 12rpx;
  90. border: 1rpx solid #F1F1F1;
  91. &:nth-child(2n) {
  92. margin-right: 0;
  93. }
  94. .pic {
  95. display: block;
  96. width: 336rpx;
  97. height: 255rpx;
  98. border-radius: 4rpx;
  99. }
  100. .text {
  101. font-size: 20rpx;
  102. color: #666666;
  103. }
  104. .tips {
  105. width: 24rpx;
  106. height: 24rpx;
  107. background: #07F546;
  108. border-radius: 100%;
  109. &.close {
  110. background: #e93f27;
  111. }
  112. }
  113. }
  114. </style>