hximage.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. html+='<div class="m_swiper_box">';
  29. html+='<div class="m_swiper_head">';
  30. html+='<div class="m_swiper_fh"><a href="javascript:history.back(-1)"><img src="/image/v2/lpindex3.png" alt=""></a></div>';
  31. html+='<div class="swiper-pagination" id="swiperzs"></div>';
  32. html+='<div class="m_swiper_qb"><a href="javascript:void(0)">全部图片</a></div>';
  33. html+='</div>';
  34. html+='<div class="m_swiper swiper-container">';
  35. html+='<div class="m_swiper_ul swiper-wrapper">';
  36. $.each(data.data, function (i, data) {
  37. html+='<div class="m_swiper_li swiper-slide">';
  38. html+='<div class="swiper-zoom-container" data-style="'+data.type_id+'"><img src="'+data.img+'"></div>';
  39. html+='</div>';
  40. });
  41. html+='</div>';
  42. html+='</div>';
  43. html+='</div>';
  44. };
  45. $('.m_swiper_ajax').html(html);
  46. // 相册插件
  47. var swipercx = new Swiper('.m_swiper', {
  48. // loop : true,
  49. zoom: true,
  50. // autoHeight: true,
  51. initialSlide :_index,
  52. nextButton: '.swiper-button-next',
  53. prevButton: '.swiper-button-prev',
  54. pagination : '.swiper-pagination',
  55. paginationType : 'custom',
  56. paginationCustomRender: function (swiper, current, total) {
  57. return current + ' / ' + total;
  58. },
  59. // onInit: function(swiper){
  60. // $('#swiperzs').hide();
  61. // },
  62. observer:true,//修改swiper自己或子元素时,自动初始化swiper
  63. // onSlideChangeEnd: function(){
  64. // $('#swiperzs').show();
  65. // },
  66. });
  67. $('.m_swiper_qb a').on('click',function(){
  68. console.log(_albumid);
  69. window.location='/house/type/'+_hid+'?type_id='+_albumid+'';
  70. })
  71. }
  72. });
  73. }
  74. //demo示例六 通过id调取 底部菜单插件
  75. $('#demo06').navbarscroll({
  76. defaultSelect:0,
  77. scrollerWidth:6,
  78. fingerClick:1,
  79. endClickScroll:function(obj){
  80. // console.log(obj.text())
  81. }
  82. });
  83. // 底部菜单选中
  84. $('.scroller ul li[data-id="'+_albumid+'"]').attr('class','cur').siblings().attr('class','');
  85. // 底部菜单
  86. $('.scroller ul li').on('click',function(){
  87. _hid = $(this).attr('hid');
  88. _albumid = $(this).attr('data-id');
  89. _index = 0;
  90. index_lp();
  91. })