/**
 * Created by 刘丹 on 2017/10/16.
 */
(function(){
	var line_a="";
	var line_a_ulul="";
	var b4_font="";
	var slider3="";
	var url = location.search; //获取url中"?"符后的字串
	var theRequest = new Object();
	if (url.indexOf("?") != -1) {
		var str = url.substr(1);
		strs = str.split("&");
		for(var i = 0; i < strs.length; i ++) {
			theRequest[strs[i].split("=")[0]]=decodeURI(strs[i].split("=")[1]);
		}
	}
	_id=theRequest.id;
	realname=theRequest.housename;

	$.ajax({
		url: "/app.php/app/getShopDetails",
		data: {
			"id":_id
		},
		type: "POST",
		dataType: "json",
		beforeSend: function () {},
		success: function (response) {
			var shang=" ";
			var  shanpu=' ';
			if(shang=="0"){
				 shanpu='<span class="a_fontd">进场费：'+response.data.slotting_fee+'元</span>';
			}else if(shang=="1"){
				 shanpu='<span class="a_fontd">转让费：'+response.data.transfer_fee+'元</span>';
			}
			line_a='<p class="a_fonta">'+response.data.title+'</p>'+
			'<p class="a_fontb">租金均价 :'+response.data.price+'元/月</p>'+
			'<span class="a_fontc">物业管理费：'+response.data.management_fee+'元/月</span>'+
			shanpu;
			$(".line_a").html(line_a);
			var shangpu_tag=response.data.shangpu_tags;
			if(shangpu_tag){
				shangpu_tags=shangpu_tag.split(",");
				for(var i=0;i<shangpu_tags.length;i++){
					line_a_ulul+='<li>'+shangpu_tags[i]+'</li>';
					$(".line_a_ulul").html(line_a_ulul);
				}
			}
			var has_gas = response.data.has_gas;
			if(has_gas=="0"){
				has_gas="是";
			}else{
				has_gas="否";
			}

			$(".balance_num").html(response.data.room_num_left);
			$(".b1_span3").html(response.data.room_area);
			$(".b1_span34").html(response.data.room_area2);
			$(".b1_span4").html(response.data.business_area);
			$(".b3_span").html(response.data.shangpu_type_str);
			$(".b3_span2").html(response.data.yetai);
			$(".b3_span3").html(response.data.has_moved);
            $(".b4_font_p1").html(response.data.sellingpoint);
			$(".b5_font_p1").html(response.data.singn_rule);
			b4_font='<p  class="b4_font_p">详细信息</p>'+
			'<p class="b4_font2">营业时间:<span class="b4_span1 gw">'+response.data.business_date+'</span></p>'+
			'<p class="b4_font2">招商时间:<span class="b4_span1 gw">'+response.data.opentime+'</span></p>'+
			'<p class="b4_font2">开业时间:<span class="b4_span1 gw">'+response.data.start_business_date+'</span></p>'+
			'<p class="b4_font2">是否有煤气:<span class="b4_span1 gw">'+has_gas+'</span></p>'+
			'<p class="b4_font2"><span class="b3_font3 lp">地址:</span><span class="b3_span3 gw">'+response.data.city+response.data.disc+response.data.address+'</span></p>'+
			'<p class="b4_font2"><span class="b3_font3 lp" >交通:</span><span class="b3_span3 gw">'+response.data.traffic+'</span></p>';
			$("#b4_font").html(b4_font);
			//var lp_img=response.data.house_button_img;
			var lp_img=response.data.images;
			var lp_img1=response.data.plan_images;
			var img_item_ul="";
			if(lp_img1.length=="0"){
				$("#planter").hide();
			}
			for(var n=0;n<lp_img1.length;n++){
				slider3+='<div class="slide"><img src="'+response.data.api_path+response.data.plan_images[n].imagename+'"></div>'
				$(".slider3").html(slider3);
			}
			for(var n=0;n<lp_img.length;n++){
				img_item_ul+='<li class="swiper-slide swiper-slide-active" data-index="1" data-totalindex="1" data-class="101" data-sum="6" style="width: 414px;"><a><img src="'+response.data.api_path+response.data.images[n].imagename+'"></a></li>'
				$("#img_item_ul").html(img_item_ul);
			}
			var longitude=response.data.longitude;
			var latitude=response.data.latitude;
// 百度地图API功能
//			var map = new BMap.Map("allmap");    // 创建Map实例
//			map.centerAndZoom(new BMap.Point(longitude, latitude), 11);  // 初始化地图,设置中心点坐标和地图级别
//			map.addControl(new BMap.MapTypeControl());   //添加地图类型控件
//			map.setCurrentCity("上海");          // 设置地图显示的城市 此项是必须设置的
//			map.enableScrollWheelZoom(true);     //开启鼠标滚轮缩放
			var swiper = new Swiper('.lp-bunner',{
				preloadImages: false, lazyLoading: true, lazyLoadingOnTransitionStart: true,
				onTransitionEnd: function(swiper){
					$('.lp-index').text(swiper.activeIndex+1);
				},
				onInit: function(swiper){
					$('.lp-index').text(swiper.activeIndex+1);
					$('.lp-sum').text(swiper.imagesToLoad.length || swiper.imagesLoaded || $('img', '.lp-bunner').size());
				}

			});
			var liWidth = $('.showBigClass li').click(function(){
				$(this).addClass('on').siblings().removeClass('on');
				var albumType = $(this).attr('data-index');
				var $li = $(".shopBigBox .swiper-wrapper").find("[data-class=" + albumType +"]:first");
				bimgSwiper.slideTo(+$li.data("totalindex") - 1, 500, true);
			}).width();
			typeSwiper = new Swiper('.showBigClass',{
				width: liWidth ? liWidth : 52.5
			});


		},
		error: function () {

		}
	});

	//添加下载app链接相关
	var _share = getUrlParam('share');
    if(_share == "1"){
    	$('.m_part3_w').hide();

    	var _fix_top = $(".public");
		_fix_top.show();
		$(".pbl_cha").click(function() {
			_fix_top.hide();
		});
		var _name = getUrlParam('user_name');
  		var _tel = getUrlParam('user_tel');
  		if(_name || _tel){
  			var _fix_bottom = $(".fix_area_bottom");
  			_fix_bottom.show();
  			$("#fix_name").html(_name);
  			$("#fix_tel").attr("href","tel:"+_tel).html(_tel);
  			$("#fix_area_bottom_btn").click(function(){
            	_fix_bottom.hide();
            });
  		};

		jumpEvent();//添加跳转app页面事件
    }
})();
