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.

119 lines
3.3 KiB

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- {if $new_goods} -->
<div class="m m2 collect">
<div class="mt">
<h2>最近上新</h2>
</div>
<div class="mc colList" style="max-height:512px;">
<div class="slider colFrame" id="slider">
<ul style="left: 0px;">
<!--{foreach from=$new_goods item=goods name=new_goods}-->
<li <!-- {if $smarty.foreach.new_goods.iteration eq 1} --> style="border-top:none;" <!-- {/if} --> >
<div class="p-img"><a href="{$goods.url}"><img width="100" height="100" alt="{$goods.name}" data-original="{$goods.thumb}" src="images/spacer.gif" class="loading" /></a></div>
<div class="rate"><a href="{$goods.url}" title="{$goods.name}">{$goods.name|truncate:12}</a></div>
<div class="p-price"><strong>
<!-- {if $goods.promote_price neq 0} -->
{$goods.formated_promote_price}
<!-- {else}-->
{$goods.shop_price}
<!--{/if}-->
</strong></div>
</li>
<!--{/foreach}-->
</ul>
</div>
<a id="btn-left" class="prev" title="上一个" onclick="top2()"></a>
<a id="btn-right" class="next" title="下一个" onclick="bottom2()"></a>
<div class="clear"></div>
</div>
<script type="text/javascript">
var _scrolling="";
var a=1;
var $slider = $('.slider ul');
var $slider_child_l = $('.slider ul li').length;
var $slider_height = $('.slider ul li').height();
$slider.height($slider_child_l * $slider_height);
var slider_count = 0;
if ($slider_child_l <=3) {
$('#btn-right').css({cursor: 'auto'});
$('#btn-right').removeClass("dasabled");
}
var time="";
function bottom1(){
if (slider_count >= $slider_child_l - 3){
a=0;
top1();
}else{
slider_count++;
$slider.animate({top: '-=' + $slider_height + 'px'}, 'slow');
slider_pic();
time = setTimeout("bottom1()",5000);
}
}
function top1(){
if (slider_count <= 0) {
a=1;
bottom1();
}else{
slider_count--;
$slider.animate({top: '+=' + $slider_height + 'px'}, 'slow');
slider_pic();
time = setTimeout("top1();",5000);
}
}
function bottom2(){
if (slider_count >= $slider_child_l - 3){
return false;
}else{
slider_count++;
$slider.animate({top: '-=' + $slider_height + 'px'}, 'slow');
slider_pic();
}
}
function top2(){
if (slider_count <= 0) {
return false;
}else{
slider_count--;
$slider.animate({top: '+=' + $slider_height + 'px'}, 'slow');
slider_pic();
}
}
function slider_pic() {
if (slider_count >= $slider_child_l - 3) {
$('#btn-right').css({cursor: 'auto'});
$('#btn-right').addClass("dasabled");
}
else if (slider_count > 0 && slider_count <= $slider_child_l - 3) {
$('#btn-left').css({cursor: 'pointer'});
$('#btn-left').removeClass("dasabled");
$('#btn-right').css({cursor: 'pointer'});
$('#btn-right').removeClass("dasabled");
}
else if (slider_count <= 0) {
$('#btn-left').css({cursor: 'auto'});
$('#btn-left').addClass("dasabled");
}
}
$(function(){
bottom1();
$("#slider>ul").hover(function(){
//鼠标移动DIV上停止
clearTimeout(time);
},function(){
//离开继续调用
if(a==1){
bottom1();
}else if(a==0){
top1();
}
});
});
</script>
</div>
<!-- {/if} -->