function addDatas(data){
	 var htmlStr = "";
	 $("#pageListTable").html("");
	 if(data.totalNum=='0'){
		 htmlStr = "<div style='text-align:center;margin-top:100px;'><p style='font-size:30px;color:#ea4444;font-weight:blod;'>查无此类点卡商品</p></div>"
	 }else{
		 $.each(data.pageList, function (key, val) {
			 htmlStr += addHtmlByDatas(val);
		 });
	 }
	 $("#pageListTable").html(htmlStr);
	 jsReload();
}

function addHtmlByDatas(val){
	var gameItemNumber = Number(val.gameItemNumber);
	var htmlStr = "";
	htmlStr += "<li class='card-item'>";
	htmlStr += "<h2>"+val.gameName+"</h2>";
	htmlStr += "<div class='carousel-wrapper'>";
	htmlStr += "<div class='tempWrap'>";
	htmlStr += "<div class='tempWrap'>";
	//<!--list内容-->
	htmlStr += addItemDatas(val.gameItemList);
	//<!--list内容-->
	htmlStr += "</div>";
	htmlStr += "</div>";
	htmlStr += "<ul class='pagers'>";
	for(var i=0;i<gameItemNumber;i++){
		if(i==0){
			var n = i+1;
			htmlStr += "<li class='on'>"+n+"</li>";
		}else{
			htmlStr += "<li>"+n+"</li>";
		}
	}
	htmlStr += "</ul>";
	htmlStr += "<a class='carousel-btn carousel-prev' href='javascript:void(0);' ></a>";
	htmlStr += "<a class='carousel-btn carousel-next' href='javascript:void(0);' ></a>";
	htmlStr += "</div>";
	htmlStr += "</li>";
	return htmlStr;
}

function addItemDatas(list){
	var htmlStr = "";
	htmlStr += "<ul class='item-list'>";
	$.each(list, function (itemKey, itemVal) {
		htmlStr += addItemHtmlByDatas(itemVal);
	 });
	htmlStr += "</ul>";
	return htmlStr;
}

function addItemHtmlByDatas(itemVal){
	var htmlStr = "";
	var url = urlPath+itemVal.id;//跳转链接
	var imgSrc = projectPath+itemVal.img1;//img1 '订单列表图片 150x90\r\n商品页面大图 500x300',
	
	htmlStr += "<li>";
	htmlStr += "<div class='price'>";
	htmlStr += "<del>原价：￥"+itemVal.marketPrice+"</del>";
	htmlStr += "<strong>￥"+itemVal.price+"</strong>";
	htmlStr += "</div>";
	htmlStr += "<div class='img'>";
	htmlStr += "<a href='"+url+"' target='_blank'><img src="+imgSrc+" /></a>";
	htmlStr += "</div>";
	htmlStr += "<h4>";
	htmlStr += " <a href='"+url+"' target='_blank'>"+itemVal.title+"</a>";
	htmlStr += "</h4>";
	htmlStr += "</li>";
	return htmlStr;
}

function jsReload(){
	 //商品轮播
	    $(".carousel-wrapper").slide({
		titCell : ".pagers",
		mainCell : ".item-list",
		prevCell : ".carousel-prev",
		nextCell : ".carousel-next",
		effect : "leftLoop",
		autoPage : true
	}).hover(function() {
		$(this).find(".carousel-btn").animate({
			"opacity" : "1"
		}, 500);
	}, function() {
		$(this).find(".carousel-btn").animate({
			"opacity" : "0"
		}, 500);
	});
}

function addGameDatas(data){
	 var htmlStr = "";
	 $("#pageListTable").html("");
	 if(data.totalNum=='0'){
		 htmlStr = "<div style='text-align:center;margin-top:100px;'><p style='font-size:30px;color:#ea4444;font-weight:blod;'>查无此类点卡商品</p></div>"
	 }else{
		 $.each(data.pageList, function (key, val) {
			 htmlStr += addGameHtmlByDatas(val);
		 });
	 }
	 $("#pageListTable").html(htmlStr);
}

function addGameHtmlByDatas(val){
	var htmlStr = "";
	var imgSrc = projectPath+val.img1;//img1 '订单列表图片 150x90\r\n商品页面大图 500x300',
	var url = urlPath+val.id;//跳转链接
	htmlStr += "<li class='card-item'>";
	htmlStr += "<h2>"+val.title+"</h2>";
	htmlStr += "<div class='carousel-wrapper'>";
	htmlStr += "<div class='tempWrap'>";
	htmlStr += "<ul class='item-list'>";
	htmlStr += "<li>";
	htmlStr += "<div class='price'>";
	htmlStr += "<del>原价：￥"+val.marketPrice+"</del>";
	htmlStr += "<strong>￥"+val.price+"</strong>";
	htmlStr += "</div>";
	htmlStr += "<div class='img'>";
	htmlStr += "<a href='"+url+"'><img src="+imgSrc+" /></a>";
	htmlStr += "</div>";
	htmlStr += "<h4>";
	htmlStr += " <a href='"+url+"'>"+val.title+"</a>";
	htmlStr += "</h4>";
	htmlStr += "</li>";
	htmlStr += "</ul>";
	htmlStr += "</div>";
	htmlStr += "</div>";
	htmlStr += "</div>";
	htmlStr += "</li>";
	return htmlStr;
}

