timelimitsgroup.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  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. if (data.panorama != 0 && data.panorama != '' && data.panorama != null && data.panorama != undefined) {
  45. html += '<img class="m_lpList_vr" src="/image/lp_vr.png" alt="">';
  46. }
  47. html += '<div class="m_lpList_xgsj c">';
  48. html += '<div class="m_xgsj_title"><img src="/overseas/img/timelimitsgroup/lp_list3.png" alt=""><span>限时团购</span></div>';
  49. html += '<div class="m_xgsj_time" start-time="' + data.start_time + '"></div>';
  50. html += '<span class="m_xgsj_ms"></span>';
  51. html += '</div>';
  52. html += '<div class="m_lpList_gz">' + data.click + '人已关注</div>';
  53. html += '<div class="m_lpList_qg">' + data.group_num + '人已抢<img src="/overseas/img/timelimitsgroup/lp_list6.png" alt=""></div>';
  54. html += '</div>';
  55. html += '<div class="m_lpList_text">';
  56. html += '<div class="m_lpList_text_title c"><a href="/house/' + data.id + '"><img src="/overseas/img/timelimitsgroup/lp_list7.png" alt=""><span>' + data.name + '</span></a></div>';
  57. html += '<div class="m_lpList_text_jzmj">建筑面积:' + data.main_units + '</div>';
  58. html += '<div class="m_lpList_text_jg">';
  59. if (data.group_price != null && data.group_price != 0 && data.group_price != "") {
  60. html += '<em><i>¥' + data.group_price + '</i></em>';
  61. } else {
  62. html += '<em><i>待定</i></em>';
  63. }
  64. if (data.sale_price != null && data.sale_price != 0 && data.sale_price != "") {
  65. html += '<span>¥' + data.sale_price + '' + data.price_unit + '</span>';
  66. }
  67. html += '<i style="position:absolute;top:87px;right:155px;font-size: 12px; size:16px;color:#c2bfbf;">有效期:2018/12/01-2020/03/01</i>';
  68. html += '</div>';
  69. html += '<div class="m_lpList_text_style">';
  70. $.each(data.style, function (k, v) {
  71. html += '<i>' + v + '</i>';
  72. })
  73. html += '</div>';
  74. html += '<div class="m_lpList_dh"><a href="tel:' + data.citytel + '"><img src="/image/index/tel_calltu.png" alt=""></a></div>';
  75. html += '</div>';
  76. html += '</div>';
  77. })
  78. $('.m_lpList_box').append(html);
  79. ajax_lp();
  80. $('.m_lpList').each(function () {
  81. var that = $(this);
  82. var timeid = that.find('.m_xgsj_time').attr('start-time');
  83. // console.log(timeid);
  84. setInterval(function () {
  85. // let nowTime = new Date(timeid) - new Date;
  86. // // console.log(nowTime);
  87. // let minutes = parseInt(nowTime / 1000 / 60 % 60, 10);//计算剩余的分钟
  88. // // console.log(minutes);
  89. // let seconds = parseInt(nowTime / 1000 % 60, 10);//计算剩余的秒数
  90. // minutes = checkTime(minutes);
  91. // seconds = checkTime(seconds);
  92. // let hours = parseInt(nowTime / ( 1000 * 60 * 60), 10); //计算剩余的小时
  93. // hours = checkTime(hours);
  94. let nowTime = new Date(timeid) - new Date;
  95. let minutes = parseInt(nowTime / 1000 / 60 % 60, 10);//计算剩余的分钟
  96. let seconds = parseInt(nowTime / 1000 % 60, 10);//计算剩余的秒数
  97. minutes = checkTime(minutes);
  98. seconds = checkTime(seconds);
  99. let days = parseInt(nowTime / 1000 / 60 / 60 / 24, 10); //计算剩余的天数
  100. let hours = parseInt(nowTime / 1000 / 60 / 60 % 24, 10); //计算剩余的小时
  101. days = checkTime(days);
  102. hours = checkTime(hours);
  103. // document.getElementById('m_time').innerHTML=days + "天" + hours + "小时" + minutes + "分" + seconds + "秒";
  104. // 判断当前时间
  105. var Set_up = new Date(timeid);
  106. var current = new Date;
  107. if (Set_up > current) {
  108. that.find('.m_xgsj_time').html('<i>' + days + '</i> 天 <i>' + hours + '</i> 时 <i>' + minutes + '</i> 分 <i>' + seconds + '</i> 秒');
  109. } else {
  110. that.find('.m_xgsj_time').html('<i>00</i> 天 <i>00</i> 时 <i>00</i> 分 <i>00</i> 秒');
  111. }
  112. }, 1000);
  113. function checkTime(i) { //将0-9的数字前面加上0,例1变为01
  114. if (i < 10) {
  115. i = "0" + i;
  116. }
  117. return i;
  118. }
  119. })
  120. }
  121. }
  122. }
  123. });
  124. $(document).scrollTop(0);
  125. })
  126. function ajax_lp() {
  127. $('.m_lpList_box').dropload({
  128. scrollArea: window,
  129. loadDownFn: function (me, da) {
  130. $('.dropload-down').remove();
  131. page++;
  132. // 拼接HTML
  133. var html = '';
  134. $.ajax({
  135. type: 'GET',
  136. url: '/timelimitsgroup/gethouselist',
  137. data: {id: IdData, page: page, limit: size, csrf_token_f: csrfToken},
  138. // dataType: 'json',
  139. async: false,
  140. success: function (data) {
  141. // Qalert(data.count);
  142. if (data.code == 200) {
  143. var data = data.data.data;
  144. if (data != null) {
  145. console.log(data);
  146. $.each(data, function (i, data) {
  147. html += '<div class="m_lpList">';
  148. html += '<div class="m_lpList_img">';
  149. html += '<a href="/house/' + data.id + '"><img src="' + data.thumb + '/pfgwatermark" alt=""></a>';
  150. if (data.panorama != 0 && data.panorama != '' && data.panorama != null && data.panorama != undefined) {
  151. html += '<img class="m_lpList_vr" src="/image/lp_vr.png" alt="">';
  152. }
  153. html += '<div class="m_lpList_xgsj c">';
  154. html += '<div class="m_xgsj_title"><img src="/overseas/img/timelimitsgroup/lp_list3.png" alt=""><span>限时团购</span></div>';
  155. html += '<div class="m_xgsj_time" start-time="' + data.start_time + '"></div>';
  156. html += '<span class="m_xgsj_ms"></span>';
  157. html += '</div>';
  158. html += '<div class="m_lpList_gz">' + data.click + '人已关注</div>';
  159. html += '<div class="m_lpList_qg">' + data.group_num + '人已抢<img src="/overseas/img/timelimitsgroup/lp_list6.png" alt=""></div>';
  160. html += '</div>';
  161. html += '<div class="m_lpList_text">';
  162. html += '<div class="m_lpList_text_title c"><a href="/house/' + data.id + '"><img src="/overseas/img/timelimitsgroup/lp_list7.png" alt=""><span>' + data.name + '</span></a></div>';
  163. html += '<div class="m_lpList_text_jzmj">建筑面积:' + data.main_units + '</div>';
  164. html += '<div class="m_lpList_text_jg">';
  165. if (data.group_price != null && data.group_price != 0 && data.group_price != "") {
  166. html += '<em><i>¥' + data.group_price + '</i></em>';
  167. } else {
  168. html += '<em><i>待定</i></em>';
  169. }
  170. if (data.sale_price != null && data.sale_price != 0 && data.sale_price != "") {
  171. html += '<span>¥' + data.sale_price + '' + data.price_unit + '</span>';
  172. }
  173. html += '<i style="position:absolute;top:87px;right:155px;font-size: 12px; size:16px;color:#c2bfbf;">有效期:2018/12/01-2020/03/01</i>';
  174. html += '</div>';
  175. html += '<div class="m_lpList_text_style">';
  176. $.each(data.style, function (k, v) {
  177. html += '<i>' + v + '</i>';
  178. })
  179. html += '</div>';
  180. html += '<div class="m_lpList_dh"><a href="tel:' + data.citytel + '"><img src="/image/index/tel_calltu.png" alt=""></a></div>';
  181. html += '</div>';
  182. html += '</div>';
  183. })
  184. // 如果没有数据
  185. }
  186. } else {
  187. // 锁定
  188. me.lock();
  189. // 无数据
  190. me.noData();
  191. }
  192. // 处理资讯详情页面的底部一个月的有效日期
  193. var myDate = new Date;
  194. var year = myDate.getFullYear(); //获取当前时间年份
  195. var yue = myDate.getMonth() + 1;//获取当前时间月份
  196. if (yue < 10) {
  197. yue = '0' + yue;
  198. } else if (yue == 13) {
  199. yue = '01';
  200. }
  201. ;
  202. // 返回下个月有多少天数
  203. function mGetDate(yue) {
  204. var date = new Date();
  205. var year = date.getFullYear();
  206. var d = new Date(year, parseInt(yue), 0);
  207. return d.getDate();
  208. }
  209. var htmltime = year + '/' + yue + '/' + '01' + '-' + year + '/' + yue + '/' + mGetDate(yue);
  210. $('.m_lpList_box').append(html);
  211. // 每次数据插入,必须重置
  212. me.resetload();
  213. $('.m_lpList').each(function () {
  214. var that = $(this);
  215. var timeid = that.find('.m_xgsj_time').attr('start-time');
  216. // console.log(timeid);
  217. setInterval(function () {
  218. // let nowTime = new Date(timeid) - new Date;
  219. // // console.log(nowTime);
  220. // let minutes = parseInt(nowTime / 1000 / 60 % 60, 10);//计算剩余的分钟
  221. // // console.log(minutes);
  222. // let seconds = parseInt(nowTime / 1000 % 60, 10);//计算剩余的秒数
  223. // minutes = checkTime(minutes);
  224. // seconds = checkTime(seconds);
  225. // let hours = parseInt(nowTime / ( 1000 * 60 * 60), 10); //计算剩余的小时
  226. // hours = checkTime(hours);
  227. let nowTime = new Date(timeid) - new Date;
  228. let minutes = parseInt(nowTime / 1000 / 60 % 60, 10);//计算剩余的分钟
  229. let seconds = parseInt(nowTime / 1000 % 60, 10);//计算剩余的秒数
  230. minutes = checkTime(minutes);
  231. seconds = checkTime(seconds);
  232. let days = parseInt(nowTime / 1000 / 60 / 60 / 24, 10); //计算剩余的天数
  233. let hours = parseInt(nowTime / 1000 / 60 / 60 % 24, 10); //计算剩余的小时
  234. days = checkTime(days);
  235. hours = checkTime(hours);
  236. // document.getElementById('m_time').innerHTML=days + "天" + hours + "小时" + minutes + "分" + seconds + "秒";
  237. // 判断当前时间
  238. var Set_up = new Date(timeid);
  239. var current = new Date;
  240. if (Set_up > current) {
  241. that.find('.m_xgsj_time').html('<i>' + days + '</i> 天 <i>' + hours + '</i> 时 <i>' + minutes + '</i> 分 <i>' + seconds + '</i> 秒');
  242. } else {
  243. that.find('.m_xgsj_time').html('<i>00</i> 天 <i>00</i> 时 <i>00</i> 分 <i>00</i> 秒');
  244. }
  245. }, 1000);
  246. function checkTime(i) { //将0-9的数字前面加上0,例1变为01
  247. if (i < 10) {
  248. i = "0" + i;
  249. }
  250. return i;
  251. }
  252. })
  253. },
  254. error: function (xhr, type) {
  255. // alert('Ajax error!');
  256. // 即使加载出错,也得重置
  257. me.resetload();
  258. }
  259. });
  260. }
  261. });
  262. }