<extend name="Public:pinduoduobase" />
<block name="content">    

<div class="container coupon-container no-footer" id="index-content">
	<ul class="coupon-tabbar">
        <li class="coupon-tab" onclick="location.href='{:U('User/myvoucherlist', array('type' => 1))}'">
            <span <?php if($type == 1){ ?>class="selected"<?php } ?>>未使用</span>
        </li>
        <li class="coupon-tab" onclick="location.href='{:U('User/myvoucherlist', array('type' => 2))}'">
            <span <?php if($type == 2){ ?>class="selected"<?php } ?>>已使用/已过期</span>
        </li>
    </ul>
	<ul class="coupon-list">
		<?php if($type == 1){ ?>
		<li class="available-coupon-list" id="available-coupon-list">
		<?php } ?>
		<?php if($type == 2){ ?>
		<li class="out-coupon-list" id="out-coupon-list">
		<?php } ?>
		
			<div class="base-list-wrapper" id="tuan_list">
				<volist name="list" id="d">
				<div >
					<div class="coupon-list-item">
					    <div class="detail" style="<?php if($type == 1){ ?>color: rgb(255, 171, 51);<?php } ?><?php if($type == 2){ ?>color: rgb(150, 150, 150);<?php } ?>">
					        <?php if($type == 1){ ?>
					        <img class="" src="__PUBLIC__/pinduoduo/assets/img/mall_available_bg.png">
					        <?php } ?>
					        <?php if($type == 2){ ?>
					         <img class="" src="__PUBLIC__/pinduoduo/assets/img/mall_expired_bg.png">
					         <?php } ?>
					        <p class="coupon-type"><?php if($d['type'] == 0){ ?>店铺券<?php }else{ ?>全网通用<?php } ?></p>
					        <div class="discount">
					            <div class="discount-value">
					                <b>￥</b><?php echo round($d['credit']); ?>
					            </div>
					        </div>
					        <div class="info">
					            <div class="more-info">
					                <p class="batch-name">
					     				<?php if($d['limit_money'] >0) { ?>
					     				满<?php echo round($d['limit_money']); ?>减<?php echo round($d['credit']); ?>
					     				<?php } ?>           
					                </p>
					                <p class="scope scope-available">
					                <?php if($d['type'] == 0){ ?>
					               		 仅限{$d.store_name}
					                <?php } ?>
					                </p>
					                <p class="duration">
					                	<?php echo date('Y.m.d',$d['begin_time']); ?>
					                	 - 
					                	<?php echo date('Y.m.d',$d['end_time']); ?> 
					                </p>
					            </div>
					        </div>
				        <!--ms-if-->
				   	 	</div>
					</div>
				</div>
				</volist>
			
			</div>
			
		</li>
	</ul>
	


</div>


<div class="center" id="center_pullup" style="display:none;">
	 <span><img class="img_rotate" src="__PUBLIC__/pinduoduo/assets/img/pull_loading_8eba142.png"/>
	 </span><span class="orders_text"></span>
</div>
<style>
.coupon-tabbar .coupon-tab { 
	width:49%;
}
.center {
    width: 170px;
    margin: 0 auto;
    text-align: center;
}
.img_rotate {
    width: 30px;
    height: 30px;
    margin-top: 7px;
    margin-right: 5px;
    -webkit-animation: loading 1s linear 0s infinite;
}

@-webkit-keyframes loading {
    0% {
        -webkit-transform: rotate(0);
    }

    100% {
        -webkit-transform: rotate(360deg);
    }
}
.orders_text {
    line-height: 45px;
    font-weight: 700;
    font-size: 15px;
}

</style>
<script>
var offset = 0;
var _pa = 2;
var is_can_next = 1;
var cur_url = "{:U('User/myvoucherlist',array('type' => $type))}";
var req_step = 1;

function loaddata()
{ 
	var totalheight = parseFloat($(window).height()) + parseFloat($(window).scrollTop());     //浏览器的高度加上滚动条的高度 

	if ($(document).height() <= totalheight+200)     //当文档的高度小于或者等于总的高度的时候，开始动态加载数据
	{ 
		if(is_can_next == 1)//加载数据
		{
			is_can_next = 0;
			nextpage();
		}
	} 
}

function nextpage()
{	
	$('#center_pullup').show();
	$.ajax(
		{ 
			url: cur_url, 
			type:'post',
			data:{page:_pa},
			dataType: 'json', 
			success: function(result){

				if(result.code == 1)
				{
					$('#tuan_list').append(result.html);
					$('#center_pullup').hide();
					_pa++;
					is_can_next = 1;
				} else if(result.code == 0) {
					$('#center_pullup').remove();
				}
				
			}
		}
	);
}
$(function(){
	$(window).scroll( function() { 
		loaddata();
	});
})

</script>
</block>
