<%@ page language="java" pageEncoding="utf-8"%>
<%@ page language="java" import="com.fadu.web.util.Constant" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<% 
	String token = (String)session.getAttribute(Constant.Session.TOKEN) ;
	String openid = (String)session.getAttribute(Constant.Session.DWLSD_OPENID);
%>
<c:set var="contextPath" value="${pageContext.request.contextPath}"></c:set>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="wap-font-scale" content="no">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no">
    <title>我的订单</title>
	<script src="${contextPath}/static/js/flexible.min.js"></script>
	<link rel="stylesheet" type="text/css" href="${contextPath}/static/weixin/cd/css/sprite.css">
	<link rel="stylesheet" type="text/css" href="${contextPath}/static/weixin/cd/css/common.css">
	<link rel="stylesheet" type="text/css" href="${contextPath}/static/weixin/cd/css/main.css">
</head>
<body>
	<div class="page">
		<header class="top bg-blue text-center fc-white fs-16 ub ub-pj">
			<a href="javascript:history.back(-1);" class="pad-l-30">
				<span class="icon icon-back"></span>
			</a>
			<span>我的订单</span>
			<span class="pad-l-40 pad-r-30"></span>
		</header>
		<ul class="my-order-list">			
		</ul>
	</div>

	<script type="text/javascript" src="${contextPath}/static/js/jquery-1.12.0.min.js"></script>
	<script type="text/javascript" src="${contextPath}/static/weixin/cd/js/main.js"></script>
	<script type="text/javascript" src="${contextPath}/static/js/jstorage.js"></script>
	<script type="text/javascript" src="${contextPath}/static/weixin/cd/js/util.js"></script>
		<script type="text/javascript">
		var baseUrl = '<%=com.fadu.app.util.AppConfig.url_duowenapp_b%>';
		var openid = '<%=openid==null?"":openid%>';
		var token = '<%=token==null?"":token%>';
		
		$(document).ready(function() {
			/*if(!token){
				showMsg('没有登录,请登录!');
				sessionStorage.setItem("loginPreUrl", window.location.href);
				location.href="${contextPath}/web/ssdb/toLogin";
			}*/			
			postData(baseUrl + '/B/android', JSON.stringify({actionCode:'B616',page:1, pageSize:0,token:token}), orderListSucc, postDataDefaultErrorCallback);
		});			
		function orderListSucc(data){
			if(data.success){
				var html = "";
				var ary = data.orders;
				for(var i=0; i<ary.length; i++){					
					var url = '${contextPath}'+'/web/cd/toOrderDetail?orderId='+ary[i].orderId+'&step=0';
					if('待付款'==ary[i].orderState){
						url = '${contextPath}'+'/web/cd/toLawyerPay?orderId='+ary[i].orderId+ "&price=" + ary[i].price;
					}else if('查档中'==ary[i].orderState){
						url = '${contextPath}'+'/web/cd/toCdIng?orderId='+ary[i].orderId;
					}else if('待查收'==ary[i].orderState ){
						url = '${contextPath}'+'/web/cd/toCdIng?orderId='+ary[i].orderId;
					}else if('待确认'==ary[i].orderState ){
						url = '${contextPath}'+'/web/cd/toPlatConfirm?orderId='+ary[i].orderId;
					}else if( '待配送'==ary[i].orderState ){
						url = '${contextPath}'+'/web/cd/toCdIng?orderId='+ary[i].orderId;
					}else if( '已配送'==ary[i].orderState ){
						url = '${contextPath}'+'/web/cd/toCdIng?orderId='+ary[i].orderId;
					}
					
					html += '<li class="mar-b-20 bg-white br-top1 br-bottom1 pos-relate">';					
					html += '<a href="'+url+'" class="fc-grey fs-14 block" >';
					html += '	<div class="pad-l-15 pad-r-15 ub ub-ac ub-pj my-order-title">';
					html += '		<p class="fs-14 ub-f1 text-overflow">'+getOrderTypeName(ary[i].orderType)+'</p>';
					html += '		<div class="pad-l-5 my-order-num">';
					html += '			<span class="mar-r-5">订单号：'+ary[i].orderId+'</span>';
					html += '			<span class="icon icon-top icon-turn-right"></span>';
					html += '		</div>';
					html += '	</div>';
					html += '	<div class="mar-l-15 fs-14 ub ub-ac br-top1 br-bottom1 pos-relate my-order-center">';
					html += '		<div class="width100">';
					html += '			<p class="fc-blue pad-b-5">价格：'+ary[i].price+'</p>';
					html += '			<p class="fc-grey text-overflow">查档地区：'+ary[i].areaFullName+'</p>';
					html += '		</div>';
					html += '	</div>';
					html += '	<div class="mar-l-15 pad-r-15 ub ub-ac ub-pj my-order-bottom">';
					html += '		<p class="fs-12 fc-xlgrey">'+ary[i].createDate+'</p>';
					html += '		<p class="fs-14 fc-orange">'+ary[i].orderState+'</p>';
					html += '	</div>';
					html += '</a>';
					html += '</li>	';
				}				
				$(".my-order-list").html(html);
			} else {
				showMsg("网络异常！");
			}
		}
	</script>
</body>
</html>