| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- <template>
- <view class="photo-image">
- <view class="photo-image__tabs">
- <view
- class="photo-image__tab"
- v-for="(pest, index) in pestList"
- :key="index"
- :class="{ active: activeIndexList.includes(index) }"
- @click="changeTab(index)"
- >
- <text class="tab-text">{{ pest.pest_name }}({{ pest.pest_num }})</text>
- </view>
- </view>
- <view class="photo-image__content" v-if="images.length">
- <view class="photo-image__grid">
- <view class="photo-image__item" v-for="(item, index) in images" :key="index" @click="handleClick(item)">
- <view class="photo-image__item-img-container">
- <image
- class="photo-image__item-img"
- :src="item.addr"
- mode="aspectFill"
- />
- </view>
- <view class="photo-image__item-time">
- {{ formatDate(item.addtime) }}
- </view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- props:{
- pestList:{
- type: Array,
- default: () => []
- },
- images:{
- type: Array,
- default: () => []
- },
- id:{
- type: String,
- default: ''
- },
- currentYear:{
- type: String,
- default: ''
- },
- },
- data() {
- return {
- activeIndexList:[],
- activePest:[],
- activeTab: 0,
- tabs: ['全部', '稻飞虱', '水龟虫', '蝼蛄', '系统','全部', '稻飞虱', '水龟虫', '蝼蛄', '系统'],
- };
- },
- methods: {
- changeTab(index) {
- if(this.activeIndexList.includes(index)){
- this.activePest = this.activePest.filter(item => item !== this.pestList[index])
- this.activeIndexList = this.activeIndexList.filter(item => item !== index)
- }else{
- this.activeIndexList.push(index)
- this.activePest.push(this.pestList[index])
- }
- this.$emit('changeTab', this.activePest)
- },
- // 格式化时间
- formatDate(dateString) {
- const date = new Date(dateString*1000);
- const year = date.getFullYear();
- const month = String(date.getMonth() + 1).padStart(2, '0');
- const day = String(date.getDate()).padStart(2, '0');
- const hour = String(date.getHours()).padStart(2, '0');
- const minute = String(date.getMinutes()).padStart(2, '0');
- const second = String(date.getSeconds()).padStart(2, '0');
- return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
- },
- handleClick(item) {
- uni.navigateTo({
- url: '/pages/cbd/devicePhoto?device_id=' + item?.device_id + '&img_id=' + item?.ids + '&id=' + this.id + '¤tYear=' + this.currentYear
- })
- }
- },
- };
- </script>
- <style lang="scss" scoped>
- .photo-image {
- width: 100%;
- box-sizing: border-box;
- &__header {
- margin-bottom: 32rpx;
- white-space: nowrap;
- &::-webkit-scrollbar {
- display: none;
- }
- }
- &__tabs {
- box-sizing: border-box;
- width: 100%;
- overflow-x: auto;
- overflow-y: hidden;
- white-space: nowrap;
- // 去掉滚动条
- -ms-overflow-style: none;
- scrollbar-width: none;
- }
- .photo-image__content{
- padding: 30rpx;
- background: #ffffff;
- border-radius: 16rpx;
- margin-top: 30rpx;
- }
- &__tab {
- position: relative;
- display: inline-block;
- box-sizing: border-box;
- margin-right: 16rpx;
- background: #ffffff;
- color: #999999;
- font-family: "Source Han Sans CN VF";
- font-size: 28rpx;
- padding: 10rpx 32rpx;
- border-radius: 8rpx;
- &:last-child {
- margin-right: 0;
- }
- .tab-text {
- margin-right: 8rpx;
- }
- .tab-check {
- color: #4CAF50;
- font-weight: bold;
- }
- &.active {
- color: #0BBC58;
- }
- .tab-underline {
- position: absolute;
- bottom: 0;
- left: 0;
- right: 0;
- height: 4rpx;
- background: #4CAF50;
- border-radius: 2rpx;
- }
- }
- &__item {
- position: relative;
- width: 33.33%;
- padding: 0 10rpx;
- box-sizing: border-box;
- display: inline-block;
- margin-bottom: 24rpx;
- &-img-container {
- width: 100%;
- padding-bottom: 100%;
- position: relative;
- border-radius: 8rpx;
- overflow: hidden;
- background-color: #f5f5f5;
- border: 2rpx solid #333;
- }
- &-img {
- position: absolute;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- }
- &-time {
- position: absolute;
- bottom: 10rpx;
- margin-top: 12rpx;
- font-size: 22rpx;
- color: #fff;
- text-align: center;
- background-color: rgba(0, 0, 0, 0.5);
- }
- }
- }
- </style>
|