index.vue 2.1 KB

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