photoImage.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. <template>
  2. <view class="photo-image">
  3. <view class="photo-tabs">
  4. <view class="photo-tab-item" :class="{ active: activeTab === 0 }" @click="changeTabActive(0)">全部</view>
  5. <view class="photo-tab-item" :class="{ active: activeTab === 1 }" @click="changeTabActive(1, ding_one_device_id)">{{ ding_one_device_id }}</view>
  6. <view class="photo-tab-item" :class="{ active: activeTab === 2 }" @click="changeTabActive(2, ding_two_device_id)">{{ ding_two_device_id }}</view>
  7. <view class="photo-tab-item" :class="{ active: activeTab === 3 }" @click="changeTabActive(3, ding_three_device_id)">{{ ding_three_device_id }}</view>
  8. </view>
  9. <view
  10. class="photo-image__tabs"
  11. v-if="disableShow"
  12. >
  13. <view
  14. class="photo-image__tab"
  15. v-for="(pest, index) in pestList"
  16. :key="index"
  17. :class="{ active: activeIndexList.includes(index) }"
  18. @click="changeTab(index)"
  19. >
  20. <text class="tab-text">{{ pest.pest_name }}({{ pest.pest_num }})</text>
  21. </view>
  22. </view>
  23. <view class="photo-image__content" v-if="images.length">
  24. <view class="photo-image__grid">
  25. <view class="photo-image__item" v-for="(item, index) in images" :key="index" @click="handleClick(item)">
  26. <view class="photo-image__item-img-container">
  27. <image
  28. class="photo-image__item-img"
  29. :src="getSrc(item)"
  30. />
  31. <view class="photo-image__item-icon-container">
  32. <image
  33. v-if="item.has_mark == 1 || item.has_identify == 1"
  34. class="photo-image__item-icon"
  35. src="https://s3.hnyfwlw.com/webstaticimg/bigdata_app/img/ai.png"
  36. />
  37. <image
  38. v-if="item.has_photo == 1"
  39. class="photo-image__item-icon-video"
  40. src="https://s3.hnyfwlw.com/webstaticimg/bigdata_app/img/video.png"
  41. />
  42. <image
  43. v-if="item.has_video == 1"
  44. class="photo-image__item-icon-img"
  45. src="https://s3.hnyfwlw.com/webstaticimg/bigdata_app/img/img.png"
  46. />
  47. </view>
  48. </view>
  49. <view class="photo-image__item-title">
  50. {{ item.event_id }}
  51. </view>
  52. <view class="photo-image__item-time">
  53. {{ formatDate(item.addtime) }}
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. <view v-else>
  59. <u-empty text="暂无图片"></u-empty>
  60. </view>
  61. </view>
  62. </template>
  63. <script>
  64. export default {
  65. props:{
  66. disableShow:{
  67. type: Boolean,
  68. default: true
  69. },
  70. pestList:{
  71. type: Array,
  72. default: () => []
  73. },
  74. images:{
  75. type: Array,
  76. default: () => []
  77. },
  78. deviceInfo:{
  79. type: Object,
  80. default: () => ({})
  81. },
  82. currentYear:{
  83. type: String | Number,
  84. default: ''
  85. },
  86. ding_one_device_id:{
  87. type: String,
  88. default: ''
  89. },
  90. ding_three_device_id:{
  91. type: String,
  92. default: ''
  93. },
  94. ding_two_device_id:{
  95. type: String,
  96. default: ''
  97. },
  98. },
  99. data() {
  100. return {
  101. activeIndexList:[],
  102. activePest:[],
  103. activeTab: 0,
  104. tabs: ['全部', '稻飞虱', '水龟虫', '蝼蛄', '系统','全部', '稻飞虱', '水龟虫', '蝼蛄', '系统'],
  105. };
  106. },
  107. methods: {
  108. getSrc(item){
  109. return item.photo_list[0]?.addr;
  110. },
  111. changeTab(index) {
  112. if(this.activeIndexList.includes(index)){
  113. this.activePest = this.activePest.filter(item => item !== this.pestList[index])
  114. this.activeIndexList = this.activeIndexList.filter(item => item !== index)
  115. }else{
  116. this.activeIndexList.push(index)
  117. this.activePest.push(this.pestList[index])
  118. }
  119. this.$emit('changeTab', this.activePest)
  120. },
  121. changeTabActive(index, event_id) {
  122. this.activeTab = index
  123. this.$emit('changeTab', event_id)
  124. },
  125. // 格式化时间
  126. formatDate(dateString) {
  127. const date = new Date(dateString*1000);
  128. const year = date.getFullYear();
  129. const month = String(date.getMonth() + 1).padStart(2, '0');
  130. const day = String(date.getDate()).padStart(2, '0');
  131. const hour = String(date.getHours()).padStart(2, '0');
  132. const minute = String(date.getMinutes()).padStart(2, '0');
  133. const second = String(date.getSeconds()).padStart(2, '0');
  134. return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
  135. },
  136. handleClick(item) {
  137. uni.navigateTo({
  138. url: '/pages/shuHai/devicePhoto?device_id=' + item?.device_id + '&addtime=' + item?.addtime + '&id=' + this.deviceInfo.id + '&currentYear=' + this.currentYear + '&event_id=' + item?.event_id
  139. })
  140. }
  141. },
  142. };
  143. </script>
  144. <style lang="scss" scoped>
  145. .photo-image {
  146. width: 100%;
  147. box-sizing: border-box;
  148. .photo-tabs{
  149. display: flex;
  150. align-items: center;
  151. justify-content: space-between;
  152. text-align: center;
  153. border-radius: 16rpx;
  154. background: #ffffff;
  155. padding: 20rpx;
  156. .photo-tab-item{
  157. flex:1;
  158. font-size: 28rpx;
  159. color: #999999;
  160. font-family: "Source Han Sans CN VF";
  161. font-weight: 400;
  162. padding: 0 5px;
  163. }
  164. .photo-tab-item.active{
  165. border-radius: 4px;
  166. background: #0BBC58;
  167. color: #ffffff;
  168. line-height: 46rpx;
  169. display: flex;
  170. align-items: center;
  171. justify-content: center;
  172. }
  173. }
  174. &__header {
  175. margin-bottom: 32rpx;
  176. white-space: nowrap;
  177. &::-webkit-scrollbar {
  178. display: none;
  179. }
  180. }
  181. &__tabs {
  182. box-sizing: border-box;
  183. width: 100%;
  184. overflow-x: auto;
  185. overflow-y: hidden;
  186. white-space: nowrap;
  187. // 去掉滚动条
  188. -ms-overflow-style: none;
  189. scrollbar-width: none;
  190. }
  191. .photo-image__content{
  192. margin-top: 24rpx;
  193. .photo-image__grid{
  194. display: grid;
  195. grid-template-columns: repeat(2, 1fr);
  196. gap: 20rpx;
  197. }
  198. }
  199. &__tab {
  200. position: relative;
  201. display: inline-block;
  202. box-sizing: border-box;
  203. margin-right: 16rpx;
  204. background: #ffffff;
  205. color: #999999;
  206. font-family: "Source Han Sans CN VF";
  207. font-size: 28rpx;
  208. padding: 10rpx 32rpx;
  209. border-radius: 8rpx;
  210. &:last-child {
  211. margin-right: 0;
  212. }
  213. .tab-text {
  214. margin-right: 8rpx;
  215. }
  216. .tab-check {
  217. color: #4CAF50;
  218. font-weight: bold;
  219. }
  220. &.active {
  221. color: #0BBC58;
  222. }
  223. .tab-underline {
  224. position: absolute;
  225. bottom: 0;
  226. left: 0;
  227. right: 0;
  228. height: 4rpx;
  229. background: #4CAF50;
  230. border-radius: 2rpx;
  231. }
  232. }
  233. &__item {
  234. border-radius: 16rpx;
  235. padding: 20rpx;
  236. position: relative;
  237. width: 100%;
  238. box-sizing: border-box;
  239. display: inline-block;
  240. overflow: hidden;
  241. background: #ffffff;
  242. &-img-container {
  243. width: 100%;
  244. padding-bottom: 60%;
  245. position: relative;
  246. border-radius: 16rpx;
  247. overflow: hidden;
  248. background-color: #f5f5f5;
  249. }
  250. .photo-image__item-icon-container{
  251. position: absolute;
  252. display: flex;
  253. gap: 4rpx;
  254. top: 8rpx;
  255. left: 8rpx;
  256. width: 100%;
  257. height: 100%;
  258. }
  259. &-img {
  260. position: absolute;
  261. top: 0;
  262. left: 0;
  263. width: 100%;
  264. height: 100%;
  265. }
  266. &-icon {
  267. width: 40rpx;
  268. height: 40rpx;
  269. }
  270. &-icon-video {
  271. width: 40rpx;
  272. height: 40rpx;
  273. }
  274. &-icon-img {
  275. width: 40rpx;
  276. height: 40rpx;
  277. }
  278. &-title {
  279. font-size: 28rpx;
  280. color: #333333;
  281. font-family: "Source Han Sans CN VF";
  282. font-weight: 500;
  283. margin-top: 12rpx;
  284. }
  285. &-time {
  286. width: 100%;
  287. padding: 0;
  288. overflow: hidden;
  289. text-overflow: ellipsis;
  290. white-space: nowrap;
  291. margin-top: 12rpx;
  292. font-size: 22rpx;
  293. color: #666666;
  294. }
  295. }
  296. }
  297. </style>