<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<jsp:include page="../../common.jsp" />

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport"
    content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<title>充值记录</title>
</head>
    <body class="pb100">
        <div class="positionf wp100 left0 top0 zindex100 bluebg h40 tcenter">
            <div>
                <a href="${ctx }/vip/myVIPCard?storeId=${sessionScope.sessionMerchantMenber.storeId}&phone=${sessionScope.sessionMerchantMenber.phone}" class="white f21 h40 left0 top0 positiona">
                    <span class="dblock w40 h40 icon icon-59 white f22"></span>
                </a>
                <span class="white">充值记录</span>
            </div>
        </div>
        <!-- 容器 -->
        <div class="weui-tab">
            <div class="mt50" id="data_content">
                <div class="weui-flex lgraybg">
               <div class="weui-flex__item pt15 pb15 dgray tcenter f14">金额(元)</div>
                <div class="weui-flex__item pt15 pb15 dgray tcenter f14">时间</div>
                <div class="weui-flex__item pt15 pb15 dgray tcenter f14">状态</div>
                </div>
            
            </div>
        </div>
    </body>
    <input type="hidden" id="memberCode" name="memberCode" value="${memberCode }" />
    <input type="hidden" id="storeId" name="storeId" value="${storeId }" />
    
     <!-- 定义分页的当前页码和总页码start -->
            <input type="hidden" id="currPage" value="1" />
            <input type="hidden" id="PageCount" value="0" />
<script type="text/javascript">



var pageIndex=1;
$(document).ready(function(){
    //调用查询
    pageIndex=StringUtil.getQueryString('pageIndex');
    if(pageIndex==undefined||pageIndex==null){
        pageIndex=1;
    }
    queryMerchantMenberRecharge(pageIndex);
});

var loading = false;  //状态标记
$(document.body).infinite().on("infinite",function() {
  if(loading) return;
  loading = true;
  setTimeout(function() {
      if ($('#currPage').val()<=$('#PageCount').val()) {
    	  queryMerchantMenberRecharge($('#currPage').val());
        } else {
            $.toast("已到底！", "text");
        }
    loading = false;
  }, 1500);   //模拟延迟
});



//查询
function queryMerchantMenberRecharge(index){
    if(typeof(index)=='undefined'){
        index=1;
    }
    var url=ctx+'/vip/goRechargeLog';
    $.ajax({  
        url:url,  
        type:"post", 
        dataType:"json",
        data:{  
            "currPage":index,
             "memberCode":$("#memberCode").val(),
             "storeId":$("#storeId").val(),
        },  
        success:function(result){
        	if(result.merchantMenberRechargeList.lenght==0){}else{
        		var data='';
                $.each(result.merchantMenberRechargeList,function(i){
                    var merchantMenberRecharge=result.merchantMenberRechargeList[i];
                    console.log(new Date(merchantMenberRecharge.createDt) instanceof Date);
                    console.log(merchantMenberRecharge.createDt);
                    var createDt='';
                    if(StringUtil.isNotBlank(merchantMenberRecharge.createDt)){
                    	createDt = myTime(merchantMenberRecharge.createDt);
                    	createDt = formatDateTime(createDt);
                    }
                    data+='<div class="weui-flex bdbe">';
                    data+='<div class="weui-flex__item pt15 pb15 tcenter f14">¥'+merchantMenberRecharge.rechargeMoney+'</div>';
                    data+='<div class="weui-flex__item pt15 pb15 tcenter f14">'+createDt+'</div>';
                    data+='<div class="weui-flex__item pt15 pb15 tcenter f14 f-green">充值成功</div>';
                    data+='</div>';
                });
                $('#data_content').append(data);
                $('#currPage').val(result.currPage + 1);
                $('#PageCount').val(result.pageCount);
        	}
        } 
    });  
}



function myTime(date){
    var arr=date.split("T");
    var d=arr[0];
    var darr = d.split('-');

    var t=arr[1];
    var tarr = t.split('.000');
    var marr = tarr[0].split(':');

    var dd = parseInt(darr[0])+"/"+parseInt(darr[1])+"/"+parseInt(darr[2])+" "+parseInt(marr[0])+":"+parseInt(marr[1])+":"+parseInt(marr[2]);
    return dd;
}

function  addZero(num) {
    return num < 10 ? '0' + num : num;
}

function formatDateTime (date) {
    var time = new Date(Date.parse(date));
    time.setTime(time.setHours(time.getHours() + 8));
    var Y = time.getFullYear() + '/';
    var M = this.addZero(time.getMonth() + 1) + '/';
    var D = this.addZero(time.getDate()) + ' ';
    var h = this.addZero(time.getHours()) + ':';
    var m = this.addZero(time.getMinutes()) + ':';
    var s = this.addZero(time.getSeconds());
    return Y + M + D + h + m + s;
}











    
</script>
</html>