hximage.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. //获取url中的参数
  2. function getUrlParam(name){
  3. //构造一个含有目标参数的正则表达式对象
  4. var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
  5. //匹配目标参数
  6. var r = window.location.search.substr(1).match(reg);
  7. //alert(r);
  8. //返回参数值
  9. if (r!=null) return decodeURI(r[2]);
  10. return null;
  11. }
  12. // URL接受参数
  13. var _albumid = getUrlParam('type_id'); //类型
  14. var _hid = getUrlParam('hid'); //楼盘ID
  15. var _index = getUrlParam('mindex'); //下标
  16. index_lp();
  17. // 相册ajax
  18. function index_lp (){
  19. var html = '';
  20. $('.m_swiper_ajax').html('')
  21. $.ajax({
  22. url: "/house/housetype",
  23. data:{hid:_hid,type_id:_albumid},
  24. type: "POST",
  25. dataType: "json",
  26. success: function(data) {//请求成功完成后要执行的方法
  27. if (data.code == 200) {
  28. console.log(data)
  29. html+='<div class="m_swiper_box">';
  30. html+='<div class="m_swiper_head">';
  31. html+='<div class="m_swiper_fh"><a href="javascript:history.back(-1)"><img src="/image/v2/lpindex3.png" alt=""></a></div>';
  32. html+='<div class="swiper-pagination" id="swiperzs"></div>';
  33. // html+='<div class="m_swiper_qb"><a href="javascript:void(0)">全部图片</a></div>';
  34. html+='</div>';
  35. html+='<div class="m_swiper swiper-container">';
  36. html+='<div class="m_swiper_ul swiper-wrapper">';
  37. $.each(data.data, function (i, data) {
  38. html+='<div class="m_swiper_li swiper-slide">';
  39. html+='<div class="m_swiper_title">'+data.title+'</div>';
  40. html+='<div class="swiper-zoom-container" data-style="'+data.type_id+'"><img src="'+data.img+'"></div>';
  41. html+='</div>';
  42. });
  43. html+='</div>';
  44. html+='</div>';
  45. html+='</div>';
  46. };
  47. $('.m_swiper_ajax').html(html);
  48. // 相册插件
  49. var swipercx = new Swiper('.m_swiper', {
  50. // loop : true,
  51. zoom: true,
  52. // autoHeight: true,
  53. initialSlide :_index,
  54. nextButton: '.swiper-button-next',
  55. prevButton: '.swiper-button-prev',
  56. pagination : '.swiper-pagination',
  57. paginationType : 'custom',
  58. paginationCustomRender: function (swiper, current, total) {
  59. return current + ' / ' + total;
  60. },
  61. // onInit: function(swiper){
  62. // $('#swiperzs').hide();
  63. // },
  64. observer:true,//修改swiper自己或子元素时,自动初始化swiper
  65. // onSlideChangeEnd: function(){
  66. // $('#swiperzs').show();
  67. // },
  68. });
  69. $('.m_swiper_qb a').on('click',function(){
  70. console.log(_albumid);
  71. window.location='/house/type/'+_hid+'?type_id='+_albumid+'';
  72. })
  73. }
  74. });
  75. }
  76. //demo示例六 通过id调取 底部菜单插件
  77. $('#demo06').navbarscroll({
  78. defaultSelect:0,
  79. scrollerWidth:6,
  80. fingerClick:1,
  81. endClickScroll:function(obj){
  82. // console.log(obj.text())
  83. }
  84. });
  85. // 底部菜单选中
  86. $('.scroller ul li[data-id="'+_albumid+'"]').attr('class','cur').siblings().attr('class','');
  87. // 底部菜单
  88. $('.scroller ul li').on('click',function(){
  89. _hid = $(this).attr('hid');
  90. _albumid = $(this).attr('data-id');
  91. _index = 0;
  92. index_lp();
  93. })