<extend name="Public/bases" />
<block name="css"> 
  <link href="__CSS__/{:C('DEFAULT_THEME')}/game.css" rel="stylesheet" >
</block>
<block name="header">
<div class="header header-list">
	<section class="wrap">
		<div class="caption">
			<span class="table">
				<span class="table-cell">
					<a href="{:U('Game/index',array('account'=>I('account'),'rs'=>1))}" class="tab-item <eq name='Think.get.rs' value='1'>active</eq>"><span>推荐</span></a>
				</span>
				<span class="table-cell">
					<a href="{:U('Game/index',array('account'=>I('account'),'rs'=>2))}" class="tab-item <eq name='Think.get.rs' value='2'>active</eq>"><span>热门</span></a>
				</span>
				<span class="table-cell">
					<a href="{:U('Game/index',array('account'=>I('account'),'rs'=>3))}" class="tab-item <eq name='Think.get.rs' value='3'>active</eq>"><span>最新</span></a>
				</span>
				<span class="table-cell">
					<a href="{:U('Game/index',array('account'=>I('account')))}" class="tab-item <empty name='Think.get.rs'>active</empty>"><span>所有</span></a>
				</span>
			</span>
		</div>
	</section>
</div>
<div class="header-space"></div>
</block>
<block name="body">
<div class="trunk-box">
	<div class="wrap">
		<div class="list">
			<notempty name="lists">
			<ul class="clearfix">
				<volist name="lists" id="vo">
				<li>
					<div class="item">
						<div class="pic"><a href="{$vo.jump_url}"><span class="font table"><span class="table-cell">----游戏</span></span><img src="{$vo.game_icon_url}"></a></div>
						<div class="but">
							<span class="table">
								<span class="table-cell">
									<eq name="vo.game_source" value="2">
									<a href="javascript:;" date-id="{$vo[id]}" date-value="{$vo.game_dow_url}" date-promote="{$vo.promote_id}"  class="butn goto <empty name='vo.game_dow_url'>disabled</empty>">下载</a>
									<else />
									<a href="http://{$_SERVER['HTTP_HOST']}{:U('Down/down_file',array('game_id'=>$vo['game_id'],'promote_id'=>$vo['promote_id'],'type'=>$vo['sdk_version']))}" class="butn">下载</a>
									</eq>
								</span>
							</span>
						</div>
						<div class="txt">
							<a href="{$vo.jump_url}" class="name">{$vo['game_name']}</a>
							<p class="info"><span>{$vo['download_number']}人下载</span><i></i><span>{$vo.game_size|default=0}MB</span></p>
							<p class="description">{$vo.summary}</p>
						</div>
					</div>
				</li>
				</volist>
			</ul>
			
			<a href="javascript:;" class="loading jsmore">加载更多</a>
			
			<else />
			<div class="empty">
				<span class="table">
				<span class="table-cell">
				<img src="__IMG__/wap/empty_icon_list.png" class="empty-icon">
				<p class="empty-text"><span>无数据</span></p>
				</span>
				</span>
			</div>
			</notempty>
		</div>
	</div>
</div>
</block>

<block name="footer">
<include file="Public:footer" />
</block>

<block name="script">
<empty name="lists">
<script>
	window.onload = function(){
		$('.list').css({'height':($(window).height()-$('.header-space').height()-$('.footer-space').height())+'px'});
	}
</script>
<else />
<script>
	var total = "{$total}";
	var page = 1;
	var loadflag = false;
	$(function() {
        $('.goto').click(function(){
            var url = $(this).attr("date-value");
            if(url == '')return false;
            var game_id = $(this).attr("date-id");
            var promote_id = $(this).attr("date-promote");
            $.ajax({
                type:'GET',
                dataType:'json',
                url:'{:U("Game/setdownload")}',
                data:{game_id:game_id,promote_id:promote_id},
                success:function(data) {
                },
            });
            window.location.href = url;
        })
		$('.jsmore').on('click',function() {
			ajax();
		});
		
		load();
		
		$(window).scroll(function() {

			load();
			
			return false;
		});
		
	});
	
	function load() {
		var totalheight = parseFloat($(window).height()) + parseFloat($(window).scrollTop());
		
		if ($(document).height() <= totalheight) {
			ajax();
		} else {
			ajax();
		}
		
	}
	
	function ajax() {
	
		var loading = $('.jsmore');
		
		if (loadflag) {return false;}
		
		if (page>total) {loading.html('数据加载完成');return false;}
		
		$.ajax({
			type:'get',
			dataType:'json',
			url:'{:U("more")}',
			data:{p:++page,account:'{:I("account")}',rs:'{:I("rs")}'},
			beforeSend:function() {
				loading.html('<span class="icon"></span>');loadflag = true;
			},
			success:function(data) {
				
				if (parseInt(data.status) == 1) {
					loading.html('加载更多');
					var html = '';
					
					$.each(data.list,function(i,n) {
						
					html+='	<li>'
					html+='		<div class="item">'
				html+='			<a href="'+n.jump_url+'" class="name"><div class="pic"><span class="font table"><span class="table-cell">----游戏</span></span><img src="'+n.game_icon_url+'"></div></a>'
					html+='			<div class="but">'
					html+='				<span class="table">'
					html+='					<span class="table-cell">'
					if (n.downloadurl)
						html+='						<a href="'+n.downloadurl+'" class="butn">下载</a>'
					else
						html+='						<a href="javascript:;" class="butn disabled">下载</a>'
					html+='					</span>'
					html+='				</span>'
					html+='			</div>'
					html+='			<div class="txt">'
					html+='				<a href="'+n.jump_url+'" class="name">'+n.game_name+'</a>'
					html+='				<p class="info"><span>'+n.download_number+'人下载</span><i></i><span>'+n.game_size+'MB</span></p>'
					html+='				<p class="description">'+n.summary+'</p>'
					html+='			</div>'
					html+='		</div>'
					html+='	</li>'
						
					});
					
					$('.list ul').append(html);
					
				} else {
					loading.html('数据加载完成'); 
				}
				loadflag = false;
			},
			error:function() {
				loading.html('加载更多');loadflag = false;
			}
		});
	}
</script>
</empty>
</block>