<extend name="Public/bases" />
<block name="css">
  <link href="__CSS__/user.css" rel="stylesheet" >
</block>
<block name="body" >
    
    <body class="user">
    <header class="header">
      <div class="">
        <a href="{:U('User/index')}" class="hbtn back"><i class="iconfont icon-drop-left"></i></a>
        <h1 class="caption">我的游戏</h1>
      </div>
    </header>
    <div class="occupy"></div>
    <section class="trunker">
      <section class="container">
        <div class="trunker-section user-game-list">
          <ul class="t-content clearfix" id="ajaxContainer" currentpage="1" >
            <volist name='data' id="vo">
            <li>
              <a href="" class="za_iconmygift">
                
				  <img src="{:get_img_url($vo['icon'])}" class="icon" onerror="this.src='__IMG__/empty.jpg';this.onerror=null">
				
              </a>
              <div class="btnbox">
                <if condition='$vo.and_dow_address eq "" && $vo.add_game_address eq "" && $vo.ios_dow_address eq "" &&  $vo.ios_game_address eq "" '>
                  <a class="btn disabled">下载</a>
                <else/>
                  <?php $devicetype = get_device_type();?>
                  <eq name='devicetype' value='1'>
										<eq name="vo.down_port" value="2">
										<a href="{$vo['add_game_address']}" class="btn">下载</a>
										<else />
										<a url="<if condition='$vo.dow_status eq 0'>#<else/>{:U('AjaxDown/down_file?game_id='.$vo['relation_game_id'].'&type=1')}</if>" class="btn down">下载</a>
										</eq>
									<else />
                  <eq name='devicetype' value='2'>
										<eq name="vo.down_port" value="2">
										<a href="{$vo['add_game_address']}" class="btn">下载</a>
										<else />
										<a url="<if condition='$vo.dow_status eq 0'>#<else/>{:U('AjaxDown/down_file?game_id='.$vo['relation_game_id'].'&type=2')}</if>" class="btn down">下载</a>
										</eq>
									<else/>
                  <!-- <a url="#" class="btn disabled">下载</a> -->     
									<eq name="vo.sdk_version" value="1">
										<eq name="vo.down_port" value="2">
										<a href="{$vo['add_game_address']}" class="btn">下载</a>
										<else />
										<a url="<if condition='$vo.dow_status eq 0'>#<else/>{:U('AjaxDown/down_file?game_id='.$vo['relation_game_id'].'&type=1')}</if>" class="btn down">下载</a>
										</eq>
                  </eq>
									<eq name="vo.sdk_version" value="2">
										<eq name="vo.down_port" value="2">
										<a href="{$vo['ios_game_address']}" class="btn">下载</a>
										<else />
										<a url="<if condition='$vo.dow_status eq 0'>#<else/>{:U('AjaxDown/down_file?game_id='.$vo['relation_game_id'].'&type=2')}</if>" class="btn down">下载</a>
										</eq>
                  </eq>
                  </eq>
                  </eq>                  
                </if>                
              </div>

              <div class="text">
                <div class="namebox">
                  <a href="" class="name">{$vo.game_name}</a>
                    <p class="stars"><i style="width:{:$vo['game_score']*10}%;"></i></p>
                </div>
                <div class="info">
                  <span class="size">{$vo.game_size}</span>
                  <span class="dlnumber">{$vo.dow_num}人下载</span>
                </div>
                <p class="description">{$vo.features}</p>
              </div>
            </li>
            </volist>
          </ul>
        </div>
      </section>
    </section>
    <div class="popmsg pop-dialog"></div>
    <div class="space"></div>
    <div class="loading ms-none hidden" id="moreBtn"><a href="javascript:" class="link"></a></div>
    <script src="__JS__/ajaxload.js"></script>
    <script src="__JS__/pop.lwx.min.js"></script>
    <script>
      $(function() {
        var pmsg = $('.popmsg').pop();
        var popmsg = $('.loading').pop();
        <?php if(!$data){?>
          pmsg.msg('暂无数据');
        <?php }?>
        var ac = $('#ajaxContainer');
        ajaxload('{:U("ajaxUserGame")}',{},function(data) {
            if (data.status == 1) {
                ac.attr('currentpage',data.page);
                var html = '',d = data.lists;
                
                for (var i in d) {
                    var item = d[i];
                    html += '<li> <a href="">'+
                            '  <img src="'+item.icon+'" class="icon" onerror="this.src=\'__IMG__/empty.jpg\';this.onerror=null">'+
                            '  </a><div class="text">'+
                            '    <div class="namebox">'+
                            '      <a href="" class="name">'+item.game_name+'</a>';
                    var game_score_html = '<p class="stars"><i style="width:'+item.game_score+'0%;"></i></p>';
                    html += game_score_html;

                    html += '    </div>'+
                            '    <div class="info">'+
                            '      <span class="size">'+item.game_size+'</span>'+
                            '      <span class="dlnumber">'+item.dow_num+'人下载</span>'+
                            '    </div>'+
                            '    <p class="description">'+item.features+'</p>'+
                            '  </div>'+
                            '</li>';
                                          
                }
                ac.append(html);
                $('.loading').addClass('ms-none');
                $('#moreBtn').removeClass('ms-none');loads = false;
            } else {
               $('.loading').removeClass('hidden').addClass('ms-none');
                popmsg.msg('已经到底了~');
            }
        })

        $(".btn").click(function(){
          var url = $(this).attr('url');
          if(url == "#"){
            pmsg.msg("此游戏暂不能下载");
          }
          $.ajax({
            url:url,
            type:"get",
            dataType:"json",
            data:{},
            success:function(result){
              if(result.status == 0){
                pmsg.msg(result.info);
              }else{
                location.href=result.url;
                return false;
                // var url = result.url;
                // fromDownFile(url);
              }
            },
            error:function(){
              alert("服务器异常");
            }
          })
        })
      });
      

    </script>
  </body>
</block>
<block name="footer"></block>