//获取url中的参数
function getUrlParam(name){
//构造一个含有目标参数的正则表达式对象
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
//匹配目标参数
var r = window.location.search.substr(1).match(reg);
//alert(r);
//返回参数值
if (r!=null) return decodeURI(r[2]);
return null;
}
// URL接受参数
var _albumid = getUrlParam('type_id'); //类型
var _hid = getUrlParam('hid'); //楼盘ID
var _index = getUrlParam('mindex'); //下标
index_lp();
// 相册ajax
function index_lp (){
var html = '';
$('.m_swiper_ajax').html('')
$.ajax({
url: "/house/housetype",
data:{hid:_hid,type_id:_albumid},
type: "POST",
dataType: "json",
success: function(data) {//请求成功完成后要执行的方法
if (data.code == 200) {
html+='
';
html+='
';
html+='
';
html+='';
html+='
';
html+='
';
html+='
';
html+='
';
$.each(data.data, function (i, data) {
html+='
';
});
html+='
';
html+='
';
html+='
';
};
$('.m_swiper_ajax').html(html);
// 相册插件
var swipercx = new Swiper('.m_swiper', {
// loop : true,
zoom: true,
// autoHeight: true,
initialSlide :_index,
nextButton: '.swiper-button-next',
prevButton: '.swiper-button-prev',
pagination : '.swiper-pagination',
paginationType : 'custom',
paginationCustomRender: function (swiper, current, total) {
return current + ' / ' + total;
},
// onInit: function(swiper){
// $('#swiperzs').hide();
// },
observer:true,//修改swiper自己或子元素时,自动初始化swiper
// onSlideChangeEnd: function(){
// $('#swiperzs').show();
// },
});
$('.m_swiper_qb a').on('click',function(){
console.log(_albumid);
window.location='/house/type/'+_hid+'?type_id='+_albumid+'';
})
}
});
}
//demo示例六 通过id调取 底部菜单插件
$('#demo06').navbarscroll({
defaultSelect:0,
scrollerWidth:6,
fingerClick:1,
endClickScroll:function(obj){
// console.log(obj.text())
}
});
// 底部菜单选中
$('.scroller ul li[data-id="'+_albumid+'"]').attr('class','cur').siblings().attr('class','');
// 底部菜单
$('.scroller ul li').on('click',function(){
_hid = $(this).attr('hid');
_albumid = $(this).attr('data-id');
_index = 0;
index_lp();
})