timelimitsgroup1.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. // 头部导航----------------------------
  2. $(function(){
  3. //demo示例六 通过id调取
  4. $('#demo06').navbarscroll({
  5. defaultSelect:0,
  6. scrollerWidth:6,
  7. fingerClick:1,
  8. endClickScroll:function(obj){
  9. // console.log(obj.text())
  10. }
  11. });
  12. });
  13. //--------------------------------------
  14. // 楼盘ajax切换--------------------------------
  15. // 页数
  16. var page = 0;
  17. // 每页展示5个
  18. var size = 5;
  19. var IdData = $('.m_switch li').eq(0).attr("dataid"); //默认传全国ID
  20. ajax_lp();
  21. $('.m_switch li').on('click',function(){
  22. var _this = $(this);
  23. page = 1;
  24. IdData = _this.attr("dataid");
  25. $('.dropload-down').remove();
  26. $.ajax({
  27. type: 'GET',
  28. url: '/timelimitsgroup/gethouselist',
  29. data:{id:IdData,page:page,limit:size,csrf_token_f:csrfToken},
  30. dataType: 'json',
  31. async:false,
  32. success: function(data){
  33. // Qalert(data.count);
  34. if (data.code == 200) {
  35. var data = data.data.data;
  36. if(data != null){
  37. console.log(data);
  38. var html = "";
  39. $('.m_lpList_box').html("");
  40. $.each(data, function (i, data) {
  41. html+= '<div class="m_lpList">';
  42. html+= '<div class="m_lpList_img">';
  43. html+= '<a href="/house/'+data.id+'/"><img src="'+data.thumb+'/pfgwatermark" alt=""></a>';
  44. html+= '<div class="m_lpList_xgsj c">';
  45. html+= '<div class="m_xgsj_title"><img src="/overseas/img/timelimitsgroup/lp_list3.png" alt=""><span>限时团购</span></div>';
  46. html+= '<div class="m_xgsj_time" start-time="'+data.start_time+'"></div>';
  47. html+= '<span class="m_xgsj_ms"></span>';
  48. html+= '</div>';
  49. html+= '<div class="m_lpList_gz">'+data.click+'人已关注</div>';
  50. html+= '<div class="m_lpList_qg">'+data.group_num+'人已抢<img src="/overseas/img/timelimitsgroup/lp_list6.png" alt=""></div>';
  51. html+= '</div>';
  52. html+= '<div class="m_lpList_text">';
  53. html+= '<div class="m_lpList_text_title c"><a href=""><img src="/overseas/img/timelimitsgroup/lp_list7.png" alt=""><span>'+data.name+'</span></a></div>';
  54. html+= '<div class="m_lpList_text_jzmj">建筑面积:'+data.main_units+'</div>';
  55. html+= '<div class="m_lpList_text_jg">';
  56. if(data.group_price!=null && data.group_price!=0 && data.group_price!=""){
  57. html+= '<em><i>¥'+data.group_price+'</i></em>';
  58. }else{
  59. html+= '<em><i>待定</i></em>';
  60. }
  61. if(data.sale_price!=null && data.sale_price!=0 && data.sale_price!=""){
  62. html+= '<span>¥'+data.sale_price+''+data.price_unit+'</span>';
  63. }
  64. html+= '</div>';
  65. html+= '<div class="m_lpList_text_style">';
  66. $.each(data.style,function(k,v){
  67. html +='<i>'+v+'</i>';
  68. })
  69. html+= '</div>';
  70. html+= '<div class="m_lpList_dh"><a href="tel:'+data.citytel+'"><img src="/image/index/tel_calltu.png" alt=""></a></div>';
  71. html+= '</div>';
  72. html+= '</div>';
  73. })
  74. $('.m_lpList_box').append(html);
  75. ajax_lp();
  76. $('.m_lpList').each(function(){
  77. var that = $(this);
  78. var timeid = that.find('.m_xgsj_time').attr('start-time');
  79. // console.log(timeid);
  80. setInterval(function(){
  81. let nowTime = new Date(timeid) - new Date;
  82. // console.log(nowTime);
  83. let minutes = parseInt(nowTime / 1000 / 60 % 60, 10);//计算剩余的分钟
  84. // console.log(minutes);
  85. let seconds = parseInt(nowTime / 1000 % 60, 10);//计算剩余的秒数
  86. minutes = checkTime(minutes);
  87. seconds = checkTime(seconds);
  88. let hours = parseInt(nowTime / ( 1000 * 60 * 60), 10); //计算剩余的小时
  89. hours = checkTime(hours);
  90. // 判断当前时间
  91. var Set_up = new Date(timeid);
  92. var current = new Date;
  93. if (Set_up > current) {
  94. that.find('.m_xgsj_time').html( '<i>'+hours+'</i> : <i>'+ minutes +'</i> : <i>'+seconds+'</i>');
  95. }else{
  96. that.find('.m_xgsj_time').html( '<i>00</i> : <i>00</i> : <i>00</i>');
  97. }
  98. },1000);
  99. function checkTime(i) { //将0-9的数字前面加上0,例1变为01
  100. if (i < 10) {
  101. i = "0" + i;
  102. }
  103. return i;
  104. }
  105. })
  106. }
  107. }
  108. }
  109. });
  110. $(document).scrollTop(0);
  111. })
  112. function ajax_lp(){
  113. $('.m_lpList_box').dropload({
  114. scrollArea : window,
  115. loadDownFn : function(me,da){
  116. $('.dropload-down').remove();
  117. page++;
  118. // 拼接HTML
  119. var html = '';
  120. $.ajax({
  121. type: 'GET',
  122. url: '/timelimitsgroup/gethouselist',
  123. data:{id:IdData,page:page,limit:size,csrf_token_f:csrfToken},
  124. // dataType: 'json',
  125. async:false,
  126. success: function(data){
  127. // Qalert(data.count);
  128. if (data.code == 200) {
  129. var data = data.data.data;
  130. if(data != null){
  131. console.log(data);
  132. $.each(data, function (i, data) {
  133. html+= '<div class="m_lpList">';
  134. html+= '<div class="m_lpList_img">';
  135. html+= '<a href="/house/'+data.id+'/"><img src="'+data.thumb+'/pfgwatermark" alt=""></a>';
  136. html+= '<div class="m_lpList_xgsj c">';
  137. html+= '<div class="m_xgsj_title"><img src="/overseas/img/timelimitsgroup/lp_list3.png" alt=""><span>限时团购</span></div>';
  138. html+= '<div class="m_xgsj_time" start-time="'+data.start_time+'"></div>';
  139. html+= '<span class="m_xgsj_ms"></span>';
  140. html+= '</div>';
  141. html+= '<div class="m_lpList_gz">'+data.click+'人已关注</div>';
  142. html+= '<div class="m_lpList_qg">'+data.group_num+'人已抢<img src="/overseas/img/timelimitsgroup/lp_list6.png" alt=""></div>';
  143. html+= '</div>';
  144. html+= '<div class="m_lpList_text">';
  145. html+= '<div class="m_lpList_text_title c"><a href=""><img src="/overseas/img/timelimitsgroup/lp_list7.png" alt=""><span>'+data.name+'</span></a></div>';
  146. html+= '<div class="m_lpList_text_jzmj">建筑面积:'+data.main_units+'</div>';
  147. html+= '<div class="m_lpList_text_jg">';
  148. if(data.group_price!=null && data.group_price!=0 && data.group_price!=""){
  149. html+= '<em><i>¥'+data.group_price+'</i></em>';
  150. }else{
  151. html+= '<em><i>待定</i></em>';
  152. }
  153. if(data.sale_price!=null && data.sale_price!=0 && data.sale_price!=""){
  154. html+= '<span>¥'+data.sale_price+''+data.price_unit+'</span>';
  155. }
  156. html+= '</div>';
  157. html+= '<div class="m_lpList_text_style">';
  158. $.each(data.style,function(k,v){
  159. html +='<i>'+v+'</i>';
  160. })
  161. html+= '</div>';
  162. html+= '<div class="m_lpList_dh"><a href="tel:'+data.citytel+'"><img src="/image/index/tel_calltu.png" alt=""></a></div>';
  163. html+= '</div>';
  164. html+= '</div>';
  165. })
  166. // 如果没有数据
  167. }
  168. }else{
  169. // 锁定
  170. me.lock();
  171. // 无数据
  172. me.noData();
  173. }
  174. $('.m_lpList_box').append(html);
  175. // 每次数据插入,必须重置
  176. me.resetload();
  177. $('.m_lpList').each(function(){
  178. var that = $(this);
  179. var timeid = that.find('.m_xgsj_time').attr('start-time');
  180. // console.log(timeid);
  181. setInterval(function(){
  182. let nowTime = new Date(timeid) - new Date;
  183. // console.log(nowTime);
  184. let minutes = parseInt(nowTime / 1000 / 60 % 60, 10);//计算剩余的分钟
  185. // console.log(minutes);
  186. let seconds = parseInt(nowTime / 1000 % 60, 10);//计算剩余的秒数
  187. minutes = checkTime(minutes);
  188. seconds = checkTime(seconds);
  189. let hours = parseInt(nowTime / ( 1000 * 60 * 60), 10); //计算剩余的小时
  190. hours = checkTime(hours);
  191. // 判断当前时间
  192. var Set_up = new Date(timeid);
  193. var current = new Date;
  194. if (Set_up > current) {
  195. that.find('.m_xgsj_time').html( '<i>'+hours+'</i> : <i>'+ minutes +'</i> : <i>'+seconds+'</i>');
  196. }else{
  197. that.find('.m_xgsj_time').html( '<i>00</i> : <i>00</i> : <i>00</i>');
  198. }
  199. },1000);
  200. function checkTime(i) { //将0-9的数字前面加上0,例1变为01
  201. if (i < 10) {
  202. i = "0" + i;
  203. }
  204. return i;
  205. }
  206. })
  207. },
  208. error: function(xhr, type){
  209. // alert('Ajax error!');
  210. // 即使加载出错,也得重置
  211. me.resetload();
  212. }
  213. });
  214. }
  215. });
  216. }