// 头部导航---------------------------- $(function(){ //demo示例六 通过id调取 $('#demo06').navbarscroll({ defaultSelect:0, scrollerWidth:6, fingerClick:1, endClickScroll:function(obj){ // console.log(obj.text()) } }); }); //-------------------------------------- // 楼盘ajax切换-------------------------------- // 页数 var page = 0; // 每页展示5个 var size = 5; var IdData = $('.m_switch li').eq(0).attr("dataid"); //默认传全国ID ajax_lp(); $('.m_switch li').on('click',function(){ var _this = $(this); page = 1; IdData = _this.attr("dataid"); $('.dropload-down').remove(); $.ajax({ type: 'GET', url: '/timelimitsgroup/gethouselist', data:{id:IdData,page:page,limit:size,csrf_token_f:csrfToken}, dataType: 'json', async:false, success: function(data){ // Qalert(data.count); if (data.code == 200) { var data = data.data.data; if(data != null){ console.log(data); var html = ""; $('.m_lpList_box').html(""); $.each(data, function (i, data) { html+= '
'; html+= '
'; html+= ''; html+= '
'; html+= '
限时团购
'; html+= '
'; html+= ''; html+= '
'; html+= '
'+data.click+'人已关注
'; html+= '
'+data.group_num+'人已抢
'; html+= '
'; html+= '
'; html+= ''; html+= '
建筑面积:'+data.main_units+'
'; html+= '
'; if(data.group_price!=null && data.group_price!=0 && data.group_price!=""){ html+= '¥'+data.group_price+''; }else{ html+= '待定'; } if(data.sale_price!=null && data.sale_price!=0 && data.sale_price!=""){ html+= '¥'+data.sale_price+''+data.price_unit+''; } html+= '
'; html+= '
'; $.each(data.style,function(k,v){ html +=''+v+''; }) html+= '
'; html+= '
'; html+= '
'; html+= '
'; }) $('.m_lpList_box').append(html); ajax_lp(); $('.m_lpList').each(function(){ var that = $(this); var timeid = that.find('.m_xgsj_time').attr('start-time'); // console.log(timeid); setInterval(function(){ let nowTime = new Date(timeid) - new Date; // console.log(nowTime); let minutes = parseInt(nowTime / 1000 / 60 % 60, 10);//计算剩余的分钟 // console.log(minutes); let seconds = parseInt(nowTime / 1000 % 60, 10);//计算剩余的秒数 minutes = checkTime(minutes); seconds = checkTime(seconds); let hours = parseInt(nowTime / ( 1000 * 60 * 60), 10); //计算剩余的小时 hours = checkTime(hours); // 判断当前时间 var Set_up = new Date(timeid); var current = new Date; if (Set_up > current) { that.find('.m_xgsj_time').html( ''+hours+' : '+ minutes +' : '+seconds+''); }else{ that.find('.m_xgsj_time').html( '00 : 00 : 00'); } },1000); function checkTime(i) { //将0-9的数字前面加上0,例1变为01 if (i < 10) { i = "0" + i; } return i; } }) } } } }); $(document).scrollTop(0); }) function ajax_lp(){ $('.m_lpList_box').dropload({ scrollArea : window, loadDownFn : function(me,da){ $('.dropload-down').remove(); page++; // 拼接HTML var html = ''; $.ajax({ type: 'GET', url: '/timelimitsgroup/gethouselist', data:{id:IdData,page:page,limit:size,csrf_token_f:csrfToken}, // dataType: 'json', async:false, success: function(data){ // Qalert(data.count); if (data.code == 200) { var data = data.data.data; if(data != null){ console.log(data); $.each(data, function (i, data) { html+= '
'; html+= '
'; html+= ''; html+= '
'; html+= '
限时团购
'; html+= '
'; html+= ''; html+= '
'; html+= '
'+data.click+'人已关注
'; html+= '
'+data.group_num+'人已抢
'; html+= '
'; html+= '
'; html+= ''; html+= '
建筑面积:'+data.main_units+'
'; html+= '
'; if(data.group_price!=null && data.group_price!=0 && data.group_price!=""){ html+= '¥'+data.group_price+''; }else{ html+= '待定'; } if(data.sale_price!=null && data.sale_price!=0 && data.sale_price!=""){ html+= '¥'+data.sale_price+''+data.price_unit+''; } html+= '
'; html+= '
'; $.each(data.style,function(k,v){ html +=''+v+''; }) html+= '
'; html+= '
'; html+= '
'; html+= '
'; }) // 如果没有数据 } }else{ // 锁定 me.lock(); // 无数据 me.noData(); } $('.m_lpList_box').append(html); // 每次数据插入,必须重置 me.resetload(); $('.m_lpList').each(function(){ var that = $(this); var timeid = that.find('.m_xgsj_time').attr('start-time'); // console.log(timeid); setInterval(function(){ let nowTime = new Date(timeid) - new Date; // console.log(nowTime); let minutes = parseInt(nowTime / 1000 / 60 % 60, 10);//计算剩余的分钟 // console.log(minutes); let seconds = parseInt(nowTime / 1000 % 60, 10);//计算剩余的秒数 minutes = checkTime(minutes); seconds = checkTime(seconds); let hours = parseInt(nowTime / ( 1000 * 60 * 60), 10); //计算剩余的小时 hours = checkTime(hours); // 判断当前时间 var Set_up = new Date(timeid); var current = new Date; if (Set_up > current) { that.find('.m_xgsj_time').html( ''+hours+' : '+ minutes +' : '+seconds+''); }else{ that.find('.m_xgsj_time').html( '00 : 00 : 00'); } },1000); function checkTime(i) { //将0-9的数字前面加上0,例1变为01 if (i < 10) { i = "0" + i; } return i; } }) }, error: function(xhr, type){ // alert('Ajax error!'); // 即使加载出错,也得重置 me.resetload(); } }); } }); }