大事记bug修改

master
Lee 2023-01-05 15:02:22 +08:00
parent 453e07471f
commit 3ead1cad37
3 changed files with 9 additions and 26 deletions

View File

@ -941,17 +941,11 @@
.history .img>span { .history .img>span {
display: block; display: block;
width: 100%; width: 100%;
height: 0; opacity: 1;
opacity: 0;
overflow: hidden; overflow: hidden;
transition: all .6s; transition: all .6s;
} }
.history .img>span.active {
height: auto;
opacity: 1;
}
.history .img img { .history .img img {
width: 100%; width: 100%;
min-height: 500px; min-height: 500px;

View File

@ -182,11 +182,6 @@ $(function(){
prevEl: '.history-swiper-bg .swiper-button-prev', prevEl: '.history-swiper-bg .swiper-button-prev',
}, },
}); });
$('.history .img>span').eq(0).addClass('active');
$(document).on('click','.history-swiper .swiper-slide',function() {
$('.history .img>span').eq($(this).index()).addClass("active").siblings().removeClass('active');
})
} }

View File

@ -61,7 +61,7 @@ foreach ($items as $item) {
$eventList = json_decode($info['imgs'], true); $eventList = json_decode($info['imgs'], true);
{/php} {/php}
{foreach $eventList as $event} {foreach $eventList as $event}
<span style="cursor: pointer" data-src="{$event.src ?? ''}" class="show-event-img"> <span style="cursor: pointer" data-src="{$event.src ?? ''}" data-title="{$event.title ?? ''}" class="show-event-img">
{$event.title ??''} {$event.title ??''}
</span><br> </span><br>
{/foreach} {/foreach}
@ -80,25 +80,19 @@ foreach ($items as $item) {
</div> </div>
</div> </div>
<div class="img"> <div class="img">
{foreach $yearList as $year => $months} <span><img id="event-img" src="" alt=""></span>
{foreach $months as $month => $info}
{php}
$eventList = json_decode($info['imgs'], true);
{/php}
{foreach $eventList as $k => $event}
{if ($k == 0) }
<span><img id="event-img" src="{$event.src ?? ''}" alt="{$event.title ?? ''}"></span>
{php}break;{/php}
{/if}
{/foreach}
{/foreach}
{/foreach}
</div> </div>
</div> </div>
</div> </div>
<script> <script>
let baseUrl = $('.history-swiper .swiper-slide').eq(0).find('.show-event-img').eq(0).attr('data-src');
let baseTitle = $('.history-swiper .swiper-slide').eq(0).find('.show-event-img').eq(0).attr('data-title');
$('#event-img').attr('src', baseUrl);
$('#event-img').attr('alt', baseTitle);
$('body').on('click', '.show-event-img',function () { $('body').on('click', '.show-event-img',function () {
let src = $(this).attr('data-src'); let src = $(this).attr('data-src');
let title = $(this).attr('data-title');
$('#event-img').attr('src', src); $('#event-img').attr('src', src);
$('#event-img').attr('alt', title);
}) })
</script> </script>