detail.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template>
  2. <!-- 图片列表 -->
  3. <view class="lamp-panel">
  4. <!-- 选择时间范围 -->
  5. <view class="mb">
  6. <uni-datetime-picker v-model="searchTime" type="daterange" rangeSeparator="-"
  7. @change="changeSearchTime" :clear-icon="false"/>
  8. </view>
  9. <view class="lamp-list" v-if="lampList.length > 0">
  10. <!-- 图片列表 -->
  11. <block v-for="(item,index) in lampList" :key="index">
  12. <view class="lamp-item" @click="openlampDetails(item.img_url)">
  13. <image class="pic" mode="aspectFill" :src="item.thumb_url">
  14. </image>
  15. <view class="row-between p-10">
  16. <text class="text">{{new Date(item.create_time).getTime()/1000 | timeFrom}}</text>
  17. </view>
  18. </view>
  19. </block>
  20. <!-- 图片列表end -->
  21. </view>
  22. <ui-empty v-else></ui-empty>
  23. <!-- 图片放大 -->
  24. <uni-popup ref="popup" type="center" mask-background-color="rgba(0,0,0,0.8)">
  25. <view class="popup-content" style="width: 100vw;">
  26. <image class="pic" mode="widthFix" :src="img_url">
  27. </image>
  28. </view>
  29. </uni-popup>
  30. </view>
  31. </template>
  32. <script>
  33. import {
  34. getDetail
  35. } from '@/api/traplamp.js';
  36. import {
  37. timeFormat,
  38. timeFrame,
  39. timeFrameText
  40. } from '@/utils/utils.js';
  41. export default {
  42. data() {
  43. return {
  44. params: {
  45. start_time: timeFormat(timeFrame('start')), // 开始时间
  46. end_time: timeFormat(timeFrame('end')), // 结束时间
  47. device_id: '', //设备号
  48. page: 1,
  49. page_size: 10,
  50. },
  51. // 图片列表
  52. lampList: [],
  53. timeVal: timeFormat(timeFrame('start')).slice(-8), // 存当前时分秒
  54. searchTime: [timeFrameText('start'), timeFrameText('end')],
  55. total: 0, // 设备总数
  56. img_url:'',
  57. };
  58. },
  59. async onLoad(options) {
  60. await this.$onLaunched;
  61. this.params.device_id = options.id
  62. this.getlampList();
  63. },
  64. onReachBottom(e) {
  65. if (this.lampList.length >= this.total) {
  66. return;
  67. }
  68. this.params.page += 1;
  69. this.getlampList();
  70. },
  71. methods: {
  72. // 时间选择
  73. changeSearchTime(val) {
  74. console.log(val)
  75. if(val.length == 0) {
  76. val = [timeFormat(timeFrame('start')), timeFormat(timeFrame('end'))];
  77. this.searchTime = val
  78. }
  79. this.params.start_time = val[0] + ' ' + this.timeVal;
  80. this.params.end_time = val[1] + ' ' + this.timeVal;
  81. this.lampList = [];
  82. this.params.page = 1;
  83. this.getlampList()
  84. },
  85. // 获取图片列表
  86. async getlampList() {
  87. this.$api.loading('加载中...');
  88. const res = await getDetail(this.params);
  89. this.$api.hide();
  90. if(res) {
  91. this.lampList = [...this.lampList, ...res.data];
  92. this.total = res.num
  93. };
  94. },
  95. /**
  96. * 打开图片详情
  97. * @param {string} id 设备id
  98. */
  99. openlampDetails(url) {
  100. this.img_url = url;
  101. this.$refs.popup.open()
  102. }
  103. }
  104. }
  105. </script>
  106. <style lang="scss">
  107. // 可视图片面板
  108. .lamp-panel {
  109. padding: 24rpx;
  110. margin-top: 24rpx;
  111. background-color: #fff;
  112. }
  113. .lamp-list {
  114. display: flex;
  115. flex-wrap: wrap;
  116. }
  117. // 可视列表项
  118. .lamp-item {
  119. width: 336rpx;
  120. margin-right: 28rpx;
  121. margin-bottom: 24rpx;
  122. border-radius: 12rpx;
  123. border: 1rpx solid #F1F1F1;
  124. &:nth-child(2n) {
  125. margin-right: 0;
  126. }
  127. .pic {
  128. display: block;
  129. width: 336rpx;
  130. height: 255rpx;
  131. border-radius: 4rpx;
  132. }
  133. .text {
  134. font-size: 20rpx;
  135. color: #666666;
  136. }
  137. .tips {
  138. width: 24rpx;
  139. height: 24rpx;
  140. background: #07F546;
  141. border-radius: 100%;
  142. &.close {
  143. background: #e93f27;
  144. }
  145. }
  146. }
  147. </style>