index.js 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. // --------------头部轮播图--------------------------
  2. var mySwiper1 = new Swiper(".yw_swiper", {
  3. autoplay: 5000,//可选选项,自动滑动
  4. loop: true,
  5. centeredSlides: true,
  6. slidesPerView:1.1,
  7. paginationClickable: true,
  8. spaceBetween: 10
  9. });
  10. // --------------广告图 --------------------------
  11. if ($('#v3adv_box ul li').length >2) {
  12. var mySwiper1 = new Swiper('#v3adv_box',{
  13. autoplay:5000,
  14. loop : false,
  15. })
  16. }else{
  17. var mySwiper1 = new Swiper('#v3adv_box',{
  18. autoplay:false,
  19. loop : false,
  20. })
  21. }
  22. // --------------品房海外精选--------------------------
  23. //导航移动 demo示例六 通过id调取
  24. $('#demo06').navbarscroll({
  25. defaultSelect: 0, //默认选中
  26. scrollerWidth: 4,
  27. fingerClick: 1,
  28. endClickScroll: function (obj) {
  29. // console.log(obj.text())
  30. }
  31. });
  32. $('.m_click li').on('click', function () {
  33. var _country = $(this).attr('country');
  34. var html = '';
  35. $.ajax({
  36. url: "/index/gethouse", // 索取
  37. data: {id: _country}, //传ID
  38. type: "GET",
  39. dataType: "json",
  40. success: function (data) {//请求成功完成后要执行的方法
  41. $.each(data.data, function (i, data) {
  42. html += '<li class="c">';
  43. html += '<a href="/house/' + data.id + '" class="c">';
  44. html += '<div class="xm_sellimgbox c">';
  45. html += '<div class="xm_sellimg">';
  46. html += '<img src="' + data.thumb + '" alt="">';
  47. html += '<p>';
  48. if (data.price != null && data.price != '' && data.price != 0) {
  49. html += '<span><i>' + data.price + '</i> ' + data.price_nuit + '</span>';
  50. } else {
  51. html += '<span><i>待定</i></span>';
  52. }
  53. html += '</p>';
  54. html += '<i class="yxq">有效期:' + data.time + '</i>';
  55. html += '</div>';
  56. html += '</div>';
  57. html += '<div class="xm_sellconter_right">';
  58. html += '<p class="title">' + data.name + '</p>';
  59. html += '<p class="style">';
  60. if (data.label) {
  61. $.each(data.label, function (k, v) {
  62. html += '<i>' + v + '</i>';
  63. })
  64. }
  65. html += '</p>';
  66. html += '<div class="xm_shuju c">';
  67. html += '<p><span>' + data.recent_price + '</span><i>房价涨幅</i></p>';
  68. html += '<p><span>' + data.down_payment_ratio + '</span><i>首付比例</i></p>';
  69. html += '<p><span>' + data.rent + '</span><i>租金回报率</i></p>';
  70. html += '</div>';
  71. html += '</div>';
  72. html += '</a>';
  73. html += '</li>';
  74. });
  75. $('.xm_sell_conter ul').html(html);
  76. }
  77. });
  78. })
  79. $('.m_click li').eq(0).click();
  80. // --------------视频看房--------------------------
  81. var mySwiper1 = new Swiper(".xm_swiper", {
  82. loop: true,
  83. centeredSlides: true,
  84. slidesPerView:1.2,
  85. paginationClickable: true,
  86. spaceBetween: 10
  87. })
  88. // --------------房产资讯--------------------------
  89. $('.xm_zixundaohang span').on('click', function () { // 房产资讯切换
  90. var qhid = $(this).attr('qhid');
  91. $('.xm_zixun .xm_zixunnr').hide();
  92. $('.xm_zixun .xm_zixunnr[qhid="' + qhid + '"]').show();
  93. $(this).attr('class', 'on').siblings().attr('class', '');
  94. })
  95. $('.xm_zixundaohang span').eq(0).click();
  96. var _top = '';
  97. var ster = 0;
  98. // 头部导航
  99. $(window).scroll(function () {
  100. ster = $(this).scrollTop();
  101. });
  102. $('.xm_zixunnr .xm_wenda').on('click', function () { // 点击问答显示弹窗
  103. $('.xm_wenda_tcbox').show();
  104. _top = $(window).scrollTop(); // 弹窗开启 遮罩层以外的东西不移动
  105. $('body').css("top", -ster + "px");
  106. $('body').addClass('add');
  107. var _title = $(this).find('.xm_wenda_r em').html();
  108. var _text = $(this).find('.xm_wenda_r span').html();
  109. $('.xm_wenda_tcr em').html(_title);
  110. $('.xm_wenda_tcr .text').html(_text);
  111. })
  112. $('.xm_wenda_tcbox .title i').on('click', function () { // 关闭问答
  113. $('.xm_wenda_tcbox').hide();
  114. $('body').removeClass('add');//去掉给body的类
  115. $(window).scrollTop(_top);//设置页面滚动的高度,如果不设置,关闭弹出层时页面会回到顶部。
  116. })
  117. $('.xm_wenda_tcbj').on('click', function () { // 关闭问答
  118. $('.xm_wenda_tcbox').hide();
  119. $('body').removeClass('add');//去掉给body的类
  120. $(window).scrollTop(_top);//设置页面滚动的高度,如果不设置,关闭弹出层时页面会回到顶部。
  121. })
  122. /*-----------------------------------视频播放--------------------------------------------*/
  123. PublicAction.AjaxSend({CORID:'ybm_buttom'/*操作ID*/});
  124. $('.liveBm_bg,.liveBm_gb a').click(function(){
  125. $('.liveBm_bg,.liveBm').hide();
  126. })
  127. // 视频播放
  128. var lpvideo = document.getElementById("myVideo");
  129. var btn_vid = document.getElementById("lpvideo");
  130. var musitime= 0;
  131. var cubicle = "true";
  132. if (btn_vid) {
  133. btn_vid.onclick = function () {
  134. // cubicle = $('#lpvideo').attr('data-boole');
  135. // console.log(cubicle)
  136. if (lpvideo.paused) { //判断当前的状态是否为暂停,若是则点击播放,否则暂停
  137. $('#myVideo').attr('controls','controls'); //点击 显示默认的控件
  138. $('.xm_video_img').hide();
  139. if(musitime >= 1000 && cubicle == "true"){
  140. AudioWind_video(); //视频报名窗口
  141. return false;
  142. }
  143. lpvideo.play();
  144. watchMusicTime_vid()
  145. }else{
  146. lpvideo.pause();
  147. }
  148. var getCookie=cookie.get("authorization");
  149. // 判断一下COOKIE 是否存在了,存在就不弹出报名窗口,直接播放
  150. if(getCookie){
  151. $('body #lpvideo').attr('data-boole','false');
  152. }
  153. }
  154. };
  155. // 视频报名窗口
  156. function AudioWind_video(){
  157. // var getCookie=cookie.get("authorization");
  158. // // 判断一下COOKIE 是否存在了,存在就不弹出报名窗口,直接播放
  159. // if(getCookie){
  160. // $('body #lpvideo').attr('data-boole','false');
  161. // return false;
  162. // }
  163. // console.log(15)
  164. if($('body .liveBm').is(':hidden')){
  165. $('body .liveBm').show(10);
  166. $('body .liveBm_bg').show();
  167. parent.w_id = $("#lpvideo").attr('value'); //把楼盘ID传向父级
  168. $('body .liveBm').find('.liveBm_box input[name="hid"]').val($("#lpvideo").attr('value'))
  169. }
  170. }
  171. //监听音乐实时播放的时间
  172. function watchMusicTime_vid(){
  173. let _this = this;
  174. //监听播放时间
  175. // let musicDom = document.getElementsByTagName('audio')[0];//获取Audio的DOM节点
  176. let musicDom =lpvideo;//获取Audio的DOM节点
  177. //使用事件监听方式捕捉事件
  178. musicDom.addEventListener("timeupdate",function(){//监听音频播放的实时时间事件
  179. cubicle = $('#lpvideo').attr('data-boole'); //2019-11-20 把获取报名成功后,可以继续播放的状态放置这里
  180. // console.log(musicDom.duration)//播放时间
  181. let timeDisplay;
  182. //用秒数来显示当前播放进度
  183. timeDisplay = Math.floor(musicDom.currentTime);//获取实时时间
  184. musitime = timeDisplay;
  185. // console.log(timeDisplay)
  186. // 处理 10秒内试听
  187. // console.log(cubicle)
  188. if(timeDisplay >= 1000 && cubicle == "true"){
  189. lpvideo.pause();
  190. AudioWind_video(); //视频报名窗口
  191. }
  192. //处理时间
  193. //分钟
  194. let minute = timeDisplay / 60;
  195. let minutes = parseInt(minute);
  196. if (minutes < 10) {
  197. minutes = "0" + minutes;
  198. }
  199. //秒
  200. let second = timeDisplay % 60;
  201. let seconds = Math.round(second);
  202. if (seconds < 10) {
  203. seconds = "0" + seconds;
  204. }
  205. let shun= minutes+":"+seconds;//将实时时间存储到vuex中
  206. // console.log(shun)
  207. // console.log(_this.$store.state.realMusicTime);
  208. },false);
  209. }