|
@@ -17,8 +17,102 @@ $(function(){
|
|
|
var EndTime= new Date('2017/09/20 00:00:00');
|
|
|
var NowTime = new Date();
|
|
|
var t =EndTime.getTime() - NowTime.getTime();
|
|
|
- var d=Math.floor(t/1000/60/60/24);
|
|
|
- document.getElementById("t_d").innerHTML = d + "天";
|
|
|
+ var d=Math.floor(t/1000/60/60/24);
|
|
|
+ var s=Math.floor(t/1000%60);
|
|
|
+ document.getElementById("t_d").innerHTML = d + "天";
|
|
|
+ //document.getElementById("t_d").innerHTML = s ;
|
|
|
+ var timet=$('#t_d').text();
|
|
|
+ if(timet<0){
|
|
|
+ alert(0)
|
|
|
+ clearInterval(times)
|
|
|
+ $('#t_d').text('已结束');
|
|
|
+ $('#t_d').css({"fontSize":"50px","color":"#cccccc","top":"220px","left":"120px"})
|
|
|
+ }
|
|
|
}
|
|
|
- setInterval(GetRTime,0);
|
|
|
-})
|
|
|
+ var times = setInterval(GetRTime,0);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ var htmlwidth=$(document).width();
|
|
|
+ $(".btn_div>div").width((htmlwidth-1200)/2);
|
|
|
+ $(".leftdiv").css({"left":-(htmlwidth-1200)/2});
|
|
|
+ $(".rightdiv").css({"right":-(htmlwidth-1200)/2});
|
|
|
+ var $imgBig=$('.ct_img_big'),
|
|
|
+ $btnNext=$('.btn_next1'),
|
|
|
+ $btnPre=$('.btn_pre1'),
|
|
|
+ $CT = $('.carousel'),
|
|
|
+ $imgSmall=$('.ct_img_small');
|
|
|
+ var $imgWidth=$imgBig.find('li').width();//获取图片的宽度;
|
|
|
+ var $imgLength=$imgBig.children().length;//获取克隆前的图片的长度;
|
|
|
+ // 拷贝第一张和最后一张;把最后一张图放在最前面;把最前面的图放在最后;
|
|
|
+ var $firstImg=$imgBig.find('li'),
|
|
|
+ $lastImg=$imgBig.find('li');
|
|
|
+ $imgBig.prepend($lastImg.clone());
|
|
|
+ $imgBig.append($firstImg.clone()); //设置imgBig clone后的宽度
|
|
|
+ $imgBig.width( $imgWidth*$imgBig.children().length)//这时的个数是添加完以后的个数
|
|
|
+ $imgBig.css({'left':'-='+$imgWidth+'px'})//把第一张图放入可视区
|
|
|
+ var pageIndex = 0 ; //img的下标;
|
|
|
+ var isAnimate = false//防止重复点击 上锁
|
|
|
+
|
|
|
+ $btnNext.on('click',function(e){
|
|
|
+ e.preventDefault();
|
|
|
+ playNext();
|
|
|
+ setTimeout(function(){
|
|
|
+
|
|
|
+ },1500)
|
|
|
+ });
|
|
|
+ $btnPre.on('click',function(e){
|
|
|
+ e.preventDefault()
|
|
|
+ playPre();
|
|
|
+ setTimeout(function(){
|
|
|
+
|
|
|
+ },1500)
|
|
|
+ });
|
|
|
+
|
|
|
+ $imgSmall.find('li').on('click',function(){
|
|
|
+ var smallIdx= $(this).index();
|
|
|
+ if(smallIdx>pageIndex){
|
|
|
+ playNext(smallIdx-pageIndex)
|
|
|
+ }
|
|
|
+ else if(smallIdx<pageIndex){
|
|
|
+ playPre(pageIndex-smallIdx)
|
|
|
+ }
|
|
|
+ });
|
|
|
+ function playNext(n){
|
|
|
+ var idx = n ||1;
|
|
|
+ if(isAnimate) return;
|
|
|
+ isAnimate = true;
|
|
|
+ $imgBig.animate({'left':'-='+ $imgWidth*idx+'px'},function(){
|
|
|
+ //如果页数=图片的最后一个,就让图片回到第一张;即data-index=0;
|
|
|
+ pageIndex = pageIndex+idx;
|
|
|
+ if( pageIndex ===$imgLength ){
|
|
|
+ $imgBig.css({'left':'-'+$imgWidth+'px'})
|
|
|
+ pageIndex = 0;
|
|
|
+ }
|
|
|
+ isAnimate = false;
|
|
|
+ smallImg()
|
|
|
+ })
|
|
|
+ }
|
|
|
+ function playPre(n){
|
|
|
+ var idx = n ||1;
|
|
|
+ if(isAnimate) return;
|
|
|
+ isAnimate = true;
|
|
|
+ $imgBig.animate({'left':'+='+$imgWidth*idx+'px'},function(){
|
|
|
+ pageIndex=pageIndex-idx;
|
|
|
+ if(pageIndex<0){
|
|
|
+ $imgBig.css({'left':'-'+$imgWidth*$imgLength+'px'});
|
|
|
+ pageIndex = $imgLength-1;
|
|
|
+ }
|
|
|
+ isAnimate = false;
|
|
|
+ smallImg()
|
|
|
+ })
|
|
|
+ }
|
|
|
+ //设置小图的class
|
|
|
+ function smallImg(){
|
|
|
+ $imgSmall.children()
|
|
|
+ .removeClass('active')
|
|
|
+ .eq(pageIndex) .addClass('active')
|
|
|
+ }
|
|
|
+
|
|
|
+})
|