<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-gift-list">
          <ul class="t-content clearfix" id="ajaxContainer" currentpage="{$page}">
            <volist name="data" id="vo">
            <li>
              <div class="item">
                <a href="{:U('Gift/detail',array('id'=>$vo['gift_id']))}" class="za_iconmygift">
                   <img src="{$vo['icon']}" class="icon" onerror="this.src='__IMG__/empty.jpg';this.onerror=null">
                   
                </a>
                <div class="delbox jsbutton touch">
                  <span>&nbsp;</span>
                  <a href="javascript:;" class="del jsdel"><span><i>删除</i></span></a>
                </div>
                <div class="text">
                  <div class="namebox">
                    <a href="{:U('Gift/detail',array('id'=>$vo['gift_id']))}" class="name">{$vo.gift_name}</a>
                  </div>
                  <div class="info">有效期:{$vo.start_time|date="Y-m-d",###}~{$vo['end_time']}</div>
									
									<div class="copybtntb">
										<div class="copybtntable">
											<span class="prefix"><p>礼包码:</p></span>
											<span class="middle">
											<input type="text" class="input copytext" readonly="" value="{$vo['novice']}">
											</span>
											<span class="subfix">
											<button class="btn notice_btn jsgetgiftcopy" data-clipboard-text="{$vo.novice}">复制</button>
											</span>
										</div>
                  </div>
									
                </div>
              </div>
            </li>
            </volist>
          </ul>
        </div>
      </section>
    </section>
    <div class="loading ms-none hidden" id="moreBtn"><a href="javascript:" class="link"></a></div>
    <div class="pop pop-dialog"></div>
    <div class="popmsg pop-dialog"></div>
    <div class="space"></div>
    <script src="__JS__/ajaxload.js"></script>
    <script src="__JS__/pop.lwx.min.js"></script>
    <script src="__JS__/clipboard.min.js"></script>
    <script src="__JS__/slider.lwx.min.js"></script>
    <script>
      $(function() {
				var pmsg = $('.popmsg').pop();
				
				var clipboard = new Clipboard('.jsgetgiftcopy');

				clipboard.on('success', function(e) {
						pmsg.msg('复制成功');
						e.clearSelection();
				});

				clipboard.on('error', function(e) {
						pmsg.msg('此浏览器不支持此操作,请长按礼包码复制');
				});
			
			
        $('.jscopy').click(function(event) {
          var elem = $(this).siblings('input');
          if (window.clipboarData) {
            window.clipboarData.clearData();
            window.clipboarData.setData('text',elem.val());
            alert('已经成功复制');
          } else {
            elem.select();
            alert('请长按礼包号码上选择');
          }
          return false;
        });

        slider.init('.jsbutton');
        var pop = $('.pop').pop();
        $('.jsdel').click(function() {
          pop.msg('dddd');
        });

        var popmsg = $('.loading').pop();
        
        <?php if(!$data){?>
          pmsg.msg('暂无数据');
        <?php }?>
        var ac = $('#ajaxContainer');
        ajaxload('{:U("ajaxUserGift")}',{},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>'+
                          '  <div class="item"><a href="'+item.url+'" class="za_iconmygift">'+
                          '  <img src="'+item.icon+'" class="icon" onerror="this.src=\'__IMG__/empty.jpg\';this.onerror=null">'+
                          '   </a><div class="delbox jsbutton touch">'+
                          '      <span>&nbsp;</span>'+
                          '      <a href="javascript:;" class="del jsdel"><span><i>删除</i></span></a>'+
                          '    </div>'+
                          '    <div class="text">'+
                          '      <div class="namebox">'+
                          '        <a href="'+item.url+'" class="name">'+item.gift_name+'</a>'+
                          '      </div>'+
                          '      <div class="info">有效期'+item.start_time+'~'+item.end_time+'</div>'+
													'      <div class="copybtntb">'+
													'      	<div class="copybtntable">'+
													'      		<span class="prefix"><p>礼包码:</p></span>'+
													'      		<span class="middle">'+
													'      		<input type="text" class="input copytext" readonly="" value="'+item.novice+'">'+
													'      		</span>'+
													'      		<span class="subfix">'+
													'      		<button class="btn notice_btn jsgetgiftcopy" data-clipboard-text="'+item.novice+'">复制</button>'+
													'      		</span>'+
													'      	</div>'+
													'      </div>'+
                          '    </div>'+
                          '  </div>'+
                          '</li>';                        
              }
              ac.append(html);
							
							
							
							
							
              $('.loading').addClass('ms-none');
              $('#moreBtn').removeClass('ms-none');loads = false;
          } else {
              $('.loading').removeClass('hidden').addClass('ms-none');
              pmsg.msg('已经到底了~');
          }
        })
      });

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