<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8" %>
<%@ include file="/WEB-INF/include/taglib.jsp" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="renderer" content="webkit">
    <meta name="description" content="">
    <meta name="keywords" content="">

    <link rel="stylesheet" href="/static/weChat/css/public.css">
    <link rel="stylesheet" href="/static/weChat/css/bai_basic.css">
    <title>订单管理</title>
</head>
<body id="container">
<%--过度动画--%>
<div id="mask">
    <div class="main">
        <div class="loading">
            <span></span>
            <span></span>
            <span></span>
            <span></span>
            <span></span>
        </div>
    </div>
    <div class="black-mask-my"></div>
</div>
<div class="arment-head">
   <%-- <div class="arment-left">
        <img src="/static/weChat/images/arment-left.png"/>
    </div>--%>
    <p>订单管理</p>
    <div class="arment-right">
        <%--<a href="javascript:;">--%>
            <%--<img src="/static/weChat/images/search.png" />--%>
        <%--</a>--%>
    </div>
</div>
<div class="goods-tab">
    <ul>
        <li class="on" status="25">
            <a>全部</a>
        </li>
        <li status="1">
            <a>未完成</a>
        </li>
        <li status="4">
            <a>待支付</a>
        </li>
        <li status="6">
            <a>已购买</a>
        </li>
        <li status="24">
            <a>已失效</a>
        </li>
    </ul>
</div>
<div id="wrapper">
    <div class="administer" id="scroller">
<div class="goods-list">

    <ul class="list-one" id="list-one">
   <%--     <li>
            <h2>
                <p>保单号：12345678965412</p>
                <span>投保中1</span>
            </h2>
            <div class="list-wed">
                <div class="list-cont">
                    <p>百联保全年综合意外10+1保障计划-幸福版</p>
                    <span>起保日期：2016-12-12</span>
                    <span>保险期限：1年</span>
                </div>
                <div class="tou">
                    <a href="javascript:;">继续投保</a>
                </div>
            </div>
            <div class="lapse-img">
                <img src="/static/weChat/images/lapse.png"/>
            </div>
        </li>
        <li>
            <h2>
                <p>保单号：12345678965412</p>
                <span>已承保</span>
            </h2>
            <div class="list-wed">
                <div class="list-cont">
                    <p>百联保全年综合意外10+1保障计划-幸福版</p>
                    <span>起保日期：2016-12-12</span>
                    <span>保险期限：1年</span>
                </div>
                <div class="tou">
                    <a href="javascript:;">订单详情</a>
                </div>
            </div>
            <div class="lapse-img">
                <img src="/static/weChat/images/lapse.png"/>
            </div>
        </li>--%>
        <%--
       <li class="lapse">
           <h2>
               <p>保单号：12345678965412</p>
               <span>已失效</span>
           </h2>
           <div class="list-wed">
               <div class="list-cont">
                   <p>百联保全年综合意外10+1保障计划-幸福版</p>
                   <span>起保日期：2016-12-12</span>
                   <span>保险期限：1年</span>
               </div>
               <div class="tou">
                   <a href="javascript:;">订单详情</a>
               </div>
           </div>
           <div class="lapse-img">
               <img src="/static/weChat/images/lapse.png" />
           </div>
       </li>
       --%>
   </ul>
</div>
        <div id="pullUp">
            <span class="pullUpLabel">上拉加载更多...</span>
        </div>
        <p id="ert"></p>
    </div>
</div>

<div class="bottom-list">
    <div class="list-cont">
        <div class="list product_list ">
            <a href="/weixin/product/win/list">
                <img  src="/static/weChat/images/product-q1.png" />
                <span>产品</span>
            </a>
        </div>
        <div class="list order_list active">
            <a href="/weixin/order/order_list">
                <img src="/static/weChat/images/order-q2-more.png" />
                <span>订单</span>
            </a>
        </div>
        <div class="list mine_list ">
            <a href="/weixin/usercenter/index">
                <img src="/static/weChat/images/user-q3.png" />
                <span>我</span>
            </a>
        </div>
    </div>
</div>

</body>
<script src="/static/weChat/js/jquery-1.8.3.min.js"></script>
<script src="/static/weChat/js/flexible.js"></script>
<script src="/static/weChat/js/basic.js"></script>

<script src="/static/weChat/js/jquery.formHelper.js"></script>
<script src="/static/weChat/common/layer_mobile/layer.js"></script>
<link rel="stylesheet" href="/static/weChat/common/layer_mobile/need/right.css"/>
<script src="/static/weChat/js/weixin_g.js"></script>

<script src="/static/weChat/js/iscroll.js"></script>
<script src="/static/weChat/js/order-one.js"></script>
<script>
    $(document).ready(function() {
        getData(); //初始化加载
    });

    var p = { limit: 5, offset: 0, status:25};

    $(function () {
        $('.goods-tab ul li').click(function () {
            //样式变化
            $('.goods-tab ul li').removeClass('on');
            $(this).addClass('on');
//            var s_index = $(this).index();
//            $('.goods-list ul').hide();
//            $('.goods-list ul').eq(s_index).show();

            //列表切换
            $("#list-one").html("");
            $("#ert").text('');
            $("#pullUp").show();
            p = { limit: 5, offset: 0, status: $(this).attr("status")};
            getData(); //初始化加载
            myScroll.refresh();
        })
    });

    function getData(){
        $("#mask").show();
        g_ajax("/weixin/order/query",p ,function(json){
            var el, li, i,order_status,url,text;
            var rows = json.rows;
            var total = json.total;
            el = document.getElementById('list-one');
            if( rows.length==0 ) { //长度为空，或者小于limit条数，说明是已经到最后了
                $("#pullUp").hide();  $("#ert").text('数据已经加载完了！').show();
            }else{
                p.offset += p.limit;
                for(var i in rows){
                    li = document.createElement('li');
                    url="/weixin/order/detail?ins_insurance_slip_id="+rows[i].ins_insurance_slip_id;
                    if (rows[i].order_status==1||rows[i].order_status==2){
//                        if(rows[i].order_status==1 )order_status="投保中";
//                        if(rows[i].order_status==2 )order_status="待核保";
                        text="继续投保";
                        url="/weixin/order/zzx/zzx_write_order1?ins_insurance_slip_id="+rows[i].ins_insurance_slip_id;
                    }else if (rows[i].order_status==3){
//                        order_status="已核保";
                        text="订单详情";
                    }else if(rows[i].order_status==4){
//                        order_status="待支付";
                        text="支付订单";
//                        url="/ZA-API/zaCheckstand?oid="+rows[i].ins_insurance_slip_id+"&webType=app";
                    }else if(rows[i].order_status==5||rows[i].order_status==6){
//                        order_status="已购买";
                        text="订单详情";
                    }else{
//                        order_status="已失效";
                        text="订单详情";
                        li.className="lapse";
                    }

                    var policy_serial_number = rows[i].external_reference==undefined?"订单号："+rows[i].trade_serial_number:"保单号："+rows[i].external_reference;
                    var inception_date  = rows[i].inception_date==undefined?"-":rows[i].inception_date;
                    var ins_period  = rows[i].ins_period==undefined?"-":rows[i].ins_period+'天';
                    //设置保障期限
                    /*var ins_peroid = "-";
                    if(rows[i].product_code!=undefined && rows[i].product_code.indexOf("ZZX-ZA")!=-1)  ins_peroid = "最多15天";
                    if(rows[i].ins_period!=undefined)  ins_peroid = rows[i].ins_period +"天";*/

                    li.innerHTML =
                        '<h2>'
                        +'<p>'+policy_serial_number+'</p>'
                        +'<span>'+rows[i].order_status_text+'</span>'
                        +'</h2>'
                        +'<div class="list-wed">'
                        +'<div class="list-cont">'
                        +'<p>'+rows[i].insurance_name+'</p>'
                        +'<span>起保日期：'+inception_date+'</span>'
                        +'<span>保险期限：'+ins_period+'</span>'
                        +'</div>'
                        +'<div class="tou">'
                        +'<a href="'+url+'" >'+text+'</a>'
                        +'</div>'
                        +'</div>'
                        +'<div class="lapse-img">'
                        +'<img src="/static/weChat/images/lapse.png"/>'
                        +'</div>';
                    el.appendChild(li, el.childNodes[0]);
                }
            }
            $("#mask").hide();
        },true);
    }
    function pullUpAction () {
        getData();
        myScroll.refresh();		// 数据加载完成后，调用界面更新方法 Remember to refresh when contents are loaded (ie: on ajax completion)
    }
</script>
</html>