You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
2.4 KiB
73 lines
2.4 KiB
{include file="public:header2"/}
|
|
{if condition="isset($banners) and count($banners)"}
|
|
|
|
<div id="banners">
|
|
<div class="banner-wraper">
|
|
{foreach name="banners" item="vo"}
|
|
<div class="banner"><a href="{$vo.lk_url}">
|
|
{if condition="empty($vo['lk_pic'])"}
|
|
<img src="{$yf_theme_path}/public/img/default2.png" class="img-responsive" width="100%" style="max-width:auto;" />
|
|
{else}
|
|
<img src="{$vo.lk_pic|get_imgurl}" title="{$vo.lk_name}" width="100%" style="max-width:auto;" οnerrοr="javascript:this.src='{$yf_theme_path}/public/img/default2.png';">
|
|
{/if}
|
|
</a></div>
|
|
{/foreach}
|
|
</div>
|
|
</div>
|
|
<script>
|
|
$(".banner img").each(function(){
|
|
var index=$(this).index();
|
|
var wid=$(window).width();
|
|
if(index==0){
|
|
// 测试缓存不加时间戳
|
|
let img_url =$(this).attr('src');
|
|
|
|
// 创建对象
|
|
let img = new Image();
|
|
|
|
// 改变图片的src
|
|
img.src = img_url;
|
|
var imgwid=0;
|
|
// 判断是否有缓存
|
|
if (img.complete) {
|
|
// 打印数据
|
|
imgwid=img.width;
|
|
|
|
if(imgwid>wid*1.4){
|
|
var curwid=wid*1.4;
|
|
$(".banner img").css({"width":curwid});
|
|
}else if(imgwid<wid){
|
|
$(".banner img").css({"width":wid});
|
|
}
|
|
} else {
|
|
|
|
// 加载完执行
|
|
img.onload = function () {
|
|
imgwid=img.width;
|
|
|
|
if(imgwid>wid*1.4){
|
|
var curwid=wid*1.4;
|
|
$(".banner img").css({"width":curwid});
|
|
}else if(imgwid<wid){
|
|
$(".banner img").css({"width":wid});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
$(function(){
|
|
$(".banner-wraper").slick({
|
|
dots:true,
|
|
arrows:false,
|
|
autoplay: true,
|
|
centerMode: true,
|
|
variableWidth: true,
|
|
autoplaySpeed: 2000,
|
|
});
|
|
});
|
|
</script>
|
|
{/if}
|
|
<div class="main container page">
|
|
{__CONTENT__}
|
|
</div>
|
|
{include file="public:footer"/}
|