

//打开页面加载数据

window.onload=function(){

	glist_json("list/10");

	

	var oWinW=$(window).width();

    var oWinH=$(window).height()-160;

	var oWinH1=$(window).height();

  	$(".slideBox .bd2 a,.slideBox").css("height",oWinH);

	

	$("#tiao01").click(function(){$(".indexclose,.bigbg,.wqzg").show()})

	$(".indexclose,.bigbg").click(function(){$(".indexclose,.bigbg,.firstbox").hide()})

	

	$("#tiao02").click(function(){$(".indexclose,.bigbg,.wqhs").show()})

	$(".indexclose,.bigbg").click(function(){$(".indexclose,.bigbg,.firstbox").hide()})

	

	$("#tiao03").click(function(){

		$("html,body").animate({scrollTop:oWinH1},300);

	});

}

//获取数据

function glist_json(parm){

	$("#urladdress").val('');

	$("#pagenum").val('');

	$.getJSON('{WEB_PATH}/mobile/mobile/glistajax/'+parm,function(data){

		$("#divGoodsLoading").css('display','none');		

		if(data[0].sum){

			var fg=parm.split("/");

			$("#urladdress").val(fg[0]+'/'+fg[1]);

			$("#pagenum").val(data[0].page);

			for(var i=0;i<data.length;i++){	

			

			var ul='<div id="'+data[i].id+'" class="shopbox clearfix">';

				ul+='<div class="fl" style="background:#FFF;"><table width="770" height="346" border="0" cellspacing="0" cellpadding="0"><tr><td align="center"><img src="{G_UPLOAD_PATH}/'+data[i].thumb+'" height="346"></td></tr></table></div>';

				ul+='<div class="boxinfo">';

				ul+='<div class="shoptop"><span class="jd-logo"></span>本奖品由京东提供，并负责发货</div>';

				ul+='<h3><span>(第'+data[i].qishu+'期)</span> '+data[i].title+'</h3>';

				ul+='<p class="p-Total">总需：'+data[i].zongrenshu+' 人次</p>';

				ul+='<div class="Progress-bar">';

				ul+='<p class="w-progressBar-wrap"><span class="w-progressBar-bar" style="width:'+(data[i].canyurenshu / data[i].zongrenshu)*100+'%;"></span></p>';

				ul+='<ul class="Pro-bar-li clearfix">';

				ul+='<li class="P-bar01 fl"><em>'+data[i].canyurenshu+'</em>已参与人次</li>';

				ul+='<li class="P-bar03 fr"><em>'+data[i].shenyurenshu+'</em>剩余人次</li>';

				ul+='</ul></div>';

				ul+='<div class="shopbut"><a href="javascript:;" target="_blank">立即1元云购</a></div>';

				ul+='</div></div>';

			

				$("#divGoodsLoading").before(ul);			

			}

			if(data[0].page<=data[0].sum){

				$("#btnLoadMore").css('display','block');

				$("#btnLoadMore2").css('display','none');

				$("#btnLoadMore3").css('display','none');

			}else if(data[0].page>data[0].sum){

				$("#btnLoadMore").css('display','none');

				$("#btnLoadMore2").css('display','none');

				$("#btnLoadMore3").css('display','block');

			}

		}else{

			$("#btnLoadMore").css('display','none');

			$("#btnLoadMore2").css('display','block');	

			$("#btnLoadMore3").css('display','none');			

		}

	});

}

$(document).ready(function(){

	//加载更多

	$("#btnLoadMore").click(function(){		

		var url=$("#urladdress").val(),

			page=$("#pagenum").val();

		glist_json(url+'/'+page);

	});	

	//跳转页面

	var gt='.shopbox';

	$(document).on('click',gt,function(){

		var id=$(this).attr('id');

		if(id){

			window.location.href="{WEB_PATH}/goods/"+id;

		}			

	});



});