index.vue 2.1 KB

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