<?php
	session_start();
	require_once("../Wx.Config.php");	//只加载一次
	
	$strStateID = trim($_REQUEST['bstat']);	//单据状态过滤
	//0未支付,1已支付,2已发货,3已完成,4交易取消
	if($strStateID=='')
	{
		$strStateID='0';
	}
	
	$strselcarttempid = trim($_SESSION["main_defcarttempid"]);
	if(strlen($strselcarttempid)<10)
	{
		header('Location: loadpage.php');
	}
	/*
	if($_SESSION["main_viplogined"]!="1" |$_SESSION["main_vipno"]=="")
	{
		//没有登录开始启动登录
		header('location:login.php?stext=&pgid=0');
		exit;
	}
	*/
	$strselDListNo=trim($_SESSION["main_posChainDListNo"]);
	
	$strIndexPage = trim($_SESSION["main_defPageIndex"]);
	if(strlen($strIndexPage)<1)
	{
		$strIndexPage = "index.php";
	}
?>

<!DOCTYPE html>
<html>
<head>
	<meta charset="gb2312">	
	<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
	<meta name="apple-mobile-web-app-capable" content="1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="format-detection" content="telephone=0">
	<meta name="apple-touch-fullscreen" content="1">

	<title>微信点单</title>
	
	<link rel="stylesheet" href="css/mycss.css"> 
	<script src="jsp4/jquery.js"></script>
	<!--<link rel="stylesheet" href="jsp5/jquery.mobile-1.4.5.min.css">-->
	<!--<script src="jsp4/jquery.mobile-1.4.3.min.js"></script>-->
	<script src="jsp5/jquery.mobile-1.4.5.min.js"></script>
	<link rel="stylesheet" href="jsp5/jquery.mobile-1.4.5.min.css">
	
	
	<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
	  
    
	<script language="JavaScript"> 
		//不允许进行后退
		javascript:window.history.forward(0); 
	</script>
</head>

<body leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0">		
<!--第一个页面的内容实现---------------------------->
<section data-role="page" id="page1">
	<header data-role="header" data-position="fixed" data-tap-toggle="false" style="border-top-width:0px;border-bottom-width:0px;">
        <table width="100%" height="52" border="0" cellpadding="0" cellspacing="0" bgcolor="<?php echo WxMainConfig::colHeadBkColor;?>">
		   	<tr>
				<td height="52" width="20"></td>
				<td height="52" align="center" valign="middle">
	                <span style="color:<?php echo WxMainConfig::colHeadTextColor;?>;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:19px;text-shadow:none;">我的订单</span>
               	</td>
				<td height="52" width="20"></td>
		  	</tr>
			
			<tr>
				<td height="1" colspan="3" bgcolor="#F2E2E2"></td>
			</tr>
			<tr>
				<td height="35" colspan="3" bgcolor="#fff">
					<table width="100%" height="37" border="0" cellpadding="0" cellspacing="0">
						<tr>
							<td width="3%" height="35" align="center"></td>
							<td width="22%" height="35" align="center">
								<?php if($strStateID=='0') { ?>
									<table width="100%" height="37" border="0" cellpadding="0" cellspacing="0">
										<tr><td align="center">
											<span style="color: #BBBB00;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:15px;text-shadow:none;">未下单</span>
										</tr></td>
									</table>
								<?php } else {?>
									<div onClick="window.location = 'orderlist.php?bstat=0';">
										<table width="100%" height="37" border="0" cellpadding="0" cellspacing="0">
											<tr><td align="center">
												<span style="color: #000000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:15px;text-shadow:none;">未下单</span>
											</tr></td>
										</table>
									</div>
								<?php } ?>
							</td>
							<td width="2%" height="35" align="center"></td>
							<td width="22%" height="35" align="center">
								<?php if($strStateID=='1' | $strStateID=='2') { ?>
									<table width="100%" height="37" border="0" cellpadding="0" cellspacing="0">
										<tr><td align="center">
											<span style="color: #BBBB00;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:15px;text-shadow:none;">已下单</span>
										</tr></td>
									</table>
								<?php } else {?>
									<div onClick="window.location = 'orderlist.php?bstat=1';">
										<table width="100%" height="37" border="0" cellpadding="0" cellspacing="0">
											<tr><td align="center">
												<span style="color: #000000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:15px;text-shadow:none;">已下单</span>
											</tr></td>
										</table>
									</div>
								<?php } ?>
							</td>
							<td width="2%" height="35" align="center"></td>
							<td width="22%" height="35" align="center">
								<?php if($strStateID=='3') { ?>
									<table width="100%" height="37" border="0" cellpadding="0" cellspacing="0">
										<tr><td align="center">
											<span style="color: #BBBB00;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:15px;text-shadow:none;">已完成</span>
										</tr></td>
									</table>
								<?php } else {?>
									<div onClick="window.location = 'orderlist.php?bstat=3';">
										<table width="100%" height="37" border="0" cellpadding="0" cellspacing="0">
											<tr><td align="center">
												<span style="color: #000000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:15px;text-shadow:none;">已完成</span>
											</tr></td>
										</table>
									</div>
								<?php } ?>
							</td>
							<td width="2%" height="35" align="center"></td>
							<td width="22%" height="35" align="center">
								<?php if($strStateID=='4') { ?>
									<table width="100%" height="37" border="0" cellpadding="0" cellspacing="0">
										<tr><td align="center">
											<span style="color: #BBBB00;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:15px;text-shadow:none;">已取消</span>
										</tr></td>
									</table>
								<?php } else {?>
									<div onClick="window.location = 'orderlist.php?bstat=4';">
										<table width="100%" height="37" border="0" cellpadding="0" cellspacing="0">
											<tr><td align="center">
												<span style="color: #000000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:15px;text-shadow:none;">已取消</span>
											</tr></td>
										</table>
									</div>
								<?php } ?>
							</td>
							<td width="3%" height="35" align="center"></td>
						</tr>
						<tr>
							<td width="3%" height="2" align="center"></td>
							<td width="22%" height="2" align="center" <?php if($strStateID=='0') { echo 'bgcolor="#BBBB00"'; } ?>></td>
							<td width="2%" height="2" align="center" ></td>
							<td width="22%" height="2" align="center" <?php if($strStateID=='1' | $strStateID=='2') { echo 'bgcolor="#BBBB00"'; } ?>></td>
							<td width="2%" height="2" align="center"></td>
							<td width="22%" height="2" align="center" <?php if($strStateID=='3') { echo 'bgcolor="#BBBB00"'; } ?>></td>
							<td width="2%" height="2" align="center"></td>
							<td width="22%" height="2" align="center" <?php if($strStateID=='4') { echo 'bgcolor="#BBBB00"'; } ?>></td>
							<td width="3%" height="2" align="center"></td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
	</header>
	
	<article data-role="none">
		<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
                
                <?php 
					//加载系统参数信息
					require_once("db/db.php");	
					require_once("common/common.php");
	
					$intRowIndex = 0;
	
					//当前登录系统的会员号和微信号		
					$strwxid = trim($_SESSION["main_wxudid"]);
					$strselsubno = trim($_SESSION["main_vipno"]);
	
					$strBillNo = '';
					$intBillState = 0;
					$strReceiveMan = '';
					$strReceiveTel = '';
					$strTradeTime = '';
					$strPayForTime = '';
					
					switch($strStateID)
					{
						case '0':
							$sql=sprintf("SELECT TOP 30 Bill_No,BillState,CONVERT(varchar(16),TradeTime, 120) AS TradeTime,CONVERT(varchar(16),PayForTime, 120) AS PayForTime,
								ReceiveMan,ReceiveTel,ItemCount,ItemValue FROM WX_Bill_Inform Where (Sub_No='%s' Or wx_no='%s') And BillState=0 And DListNo=%s Order By Bill_No DESC",$strselsubno,$strwxid,$strselDListNo);
							break;
						case '1':
							$sql=sprintf("SELECT TOP 30 Bill_No,BillState,CONVERT(varchar(16),TradeTime, 120) AS TradeTime,CONVERT(varchar(16),PayForTime, 120) AS PayForTime,
								ReceiveMan,ReceiveTel,ItemCount,ItemValue FROM WX_Bill_Inform Where (Sub_No='%s' Or wx_no='%s') And (BillState=1 Or BillState=2) And DListNo=%s Order By Bill_No DESC",$strselsubno,$strwxid,$strselDListNo);
							break;
						case '2':
							$sql=sprintf("SELECT TOP 30 Bill_No,BillState,CONVERT(varchar(16),TradeTime, 120) AS TradeTime,CONVERT(varchar(16),PayForTime, 120) AS PayForTime,
								ReceiveMan,ReceiveTel,ItemCount,ItemValue FROM WX_Bill_Inform Where (Sub_No='%s' Or wx_no='%s') And (BillState=1 Or BillState=2) And DListNo=%s Order By Bill_No DESC",$strselsubno,$strwxid,$strselDListNo);
							break;
						case '3':
							$sql=sprintf("SELECT TOP 30 Bill_No,BillState,CONVERT(varchar(16),TradeTime, 120) AS TradeTime,CONVERT(varchar(16),PayForTime, 120) AS PayForTime,
								ReceiveMan,ReceiveTel,ItemCount,ItemValue FROM WX_Bill_Inform Where (Sub_No='%s' Or wx_no='%s') And BillState=3 And DListNo=%s Order By Bill_No DESC",$strselsubno,$strwxid,$strselDListNo);
							break;
						case '4':
							$sql=sprintf("SELECT TOP 30 Bill_No,BillState,CONVERT(varchar(16),TradeTime, 120) AS TradeTime,CONVERT(varchar(16),PayForTime, 120) AS PayForTime,
								ReceiveMan,ReceiveTel,ItemCount,ItemValue FROM WX_Bill_Inform Where (Sub_No='%s' Or wx_no='%s') And BillState=4 And DListNo=%s Order By Bill_No DESC",$strselsubno,$strwxid,$strselDListNo);
							break;
						default:
							$sql=sprintf("SELECT TOP 30 Bill_No,BillState,CONVERT(varchar(16),TradeTime, 120) AS TradeTime,CONVERT(varchar(16),PayForTime, 120) AS PayForTime,
									ReceiveMan,ReceiveTel,ItemCount,ItemValue FROM WX_Bill_Inform Where (Sub_No='%s' Or wx_no='%s') And DListNo=%s Order By Bill_No DESC",$strselsubno,$strwxid,$strselDListNo);
					}
					
					$result = querySql($sql);
					
					while($row = fetch_array($result))
					{
						$strBillNo = $row['Bill_No'];
						$intBillState = $row['BillState'];
						$strReceiveMan = $row['ReceiveMan'];
						$strReceiveTel = $row['ReceiveTel'];
						$strTradeTime = $row['TradeTime'];
						$strPayForTime = $row['PayForTime'];
						$intSumCount = $row['ItemCount'];
						$fltSumValue = $row['ItemValue'];
						
						
						//0未支付,1已支付,2已发货,3已完成,4交易取消
						$strBillState = '未下单';
						$strShowTime = $strTradeTime;
						switch($intBillState)
						{
							case 1:
								$strBillState = '已支付';
								$strShowTime = $strPayForTime;
								break;
							case 2:
								$strBillState = '已下单';
								$strShowTime = $strSendOutTime;
								break;
							case 3:
								$strBillState = '已完成';
								$strShowTime = $strFinishTime;
								break;
							case 4:
								$strBillState = '交易取消';
								$strShowTime = $strFinishTime;
								break;
						}
						
						
					
						$intRowIndex = $intRowIndex + 1;
				?>
                <tr><td height="10" colspan="3"></td></tr>
                <tr>
					<td height="15" width="5"></td>
					<td height="15" align="left">
                    	
                        <div data-rel="back" onClick="bmtShowBill('<?php echo $strBillNo;?>')" style="width:100%;height:105px;border-radius:4px;border-top:1px solid #F2E2E2;border-bottom:1px solid #F2E2E2;border-left:1px solid #F2E2E2;border-right:1px solid #F2E2E2;">
                              <table width="100%" border="0" cellpadding="0" cellspacing="0">
                                  <tr>
                                      <td height="2" width="10"></td>
                                      <td height="2" align="left"></td>
                                      <td height="2" width="130"></td>
                                      <td height="2" width="10"></td>
                                  </tr>
                                                              
                                  <tr>
                                      <td height="30" width="10"></td>
                                      <td height="30" align="left" valign="middle">
	                                      <span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;">单号:</span>
										  <span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;"><?php echo $strBillNo;?></span>
                                      </td>
                                      <td height="30" width="130" align="right">
	                                      <span style="color: #009900;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;"><?php echo $strBillState;?></span>
                                      </td>
                                      
                                      <td height="30" width="10"></td>
                                  </tr>
                                  
                                  <tr>
                                      <td height="1" width="10"></td>
                                      <td height="1" align="left" colspan="2" bgcolor="#F2E2E2"></td>
                                      <td height="1" width="10"></td>
                                  </tr>
                                  
                                  <tr>
                                      <td height="4" colspan="4"></td>
                                  </tr>
                  
                                  <tr>
                                      <td height="20" width="10"></td>
                                      <td height="20" align="left" valign="middle">
                                          <span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:14px;">商品数量<?php echo ' '.number_format($intSumCount,0).' 件';?></span>
                                      </td>
                                      <td height="20" width="130" align="right">
                                          <span style="color: #00753A;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:15px;"><?php echo "￥".number_format($fltSumValue,1);?></span>
                                      </td>
                                      <td height="20" width="10"></td>
                                  </tr>
                                  
                                  
                                   <tr>
                                      <td height="20" width="10"></td>
                                      <td height="20" align="left" valign="middle">
	                                      <span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;">收件人：<?php echo $strReceiveMan;?></span>
                                      </td>
                                      <td height="20" width="130" align="right">
	                                      <span style="color: #009900;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;"><?php echo $strReceiveTel;?></span>
                                      </td>
                                      
                                      <td height="20" width="10"></td>
                                  </tr>
                                  
                                  <tr>
                                      <td height="20" width="10"></td>
                                      <td height="20" align="left" valign="middle">
	                                      <span style="color: #999999;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:12px;">创建:<?php echo $strTradeTime;?></span>
                                      </td>
                                      <td height="20" width="130" align="right">
	                                      <span style="color: #999999;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:11px;">支付:<?php echo $strPayForTime;?></span>
                                      </td>
                                                                           
                                      <td height="20" width="10"></td>
                                  </tr>
                                  
                                  
                                  
                                  <tr>
                                      <td height="3" width="10"></td>
                                      <td height="3" colspan="2" align="left"></td>
                                      <td height="3" width="10"></td>
                                  </tr>
                                  
                              </table>
                          </div>
                                    
						
					</td>
					<td height="15" width="5"></td>
				</tr>
				
                <tr><td height="1" colspan="3"></td></tr>
                              
                <?php	
						
					}
					freeResult($result);	//释放数据库
					closeDb();				//关闭数据库
				?>
                
                
			<tr>
				<td height="8" width="5"></td>
				<td height="8" align="left"></td>
				<td height="8" width="5"></td>
			</tr>
		</table>
	</article>
	   
	   
	<footer data-role="footer" data-position="fixed" data-tap-toggle="false" style="border-top:0px solid #F3EDED;border-bottom:0px solid #F6F5F2;border-left:0px solid #F6F5F2;border-right:0px solid #F6F5F2;">
		<table width="100%" height="45" border="0" cellpadding="0" cellspacing="0" bgcolor="#F6F6F6">
			<tr height="100%" valign="middle" align="center">
				<td width="25%" style="border-top:1px solid #F3EDED;">
					<div onClick="window.location='<?php echo $strIndexPage;?>';" style="width:100%;height:100%;padding-top:4px;">
						<div style="width:24px;height:20px;">
							<img src="images\p1_a.png" width="20" height="20" border="0">
						</div>
						<span style="color:#747474;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:11px;text-shadow:none;">首页</span>
					</div>
				</td>
				<td width="25%" style="border-top:1px solid #F3EDED;border-left:0px solid #F6F5F2;">
					<div onClick="window.location='cartlist.php';" style="width:100%;height:100%;padding-top:5px;">
						<div style="width:24px;height:20px;">
							<img src="images\p3_a.png" width="20" height="20" border="0">
						</div>
						<span style="color:#747474;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:11px;text-shadow:none;padding-left:4px;">已点单</span>
					</div>
				</td>
				<td width="25%" style="border-top:1px solid #F3EDED;border-left:0px solid #F6F5F2;">
					<div style="width:100%;height:100%;padding-top:5px;">
						<div style="width:24px;height:20px;">
							<img src="images\p2_b.png" width="20" height="20" border="0">
						</div>
						<span style="color:#747474;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:11px;text-shadow:none;">订单</span>
					</div>
				</td>
				<td width="25%" style="border-top:1px solid #F3EDED;border-left:0px solid #F6F5F2;">
					<div onClick="window.location='vipmain.php';" style="width:100%;height:100%;padding-top:5px;">
						<div style="width:24px;height:20px;">
							<img src="images\p4_a.png" width="20" height="20" border="0">
						</div>
						<span style="color:#747474;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:11px;text-shadow:none;">我的</span>
					</div>
				</td>
			</tr>
		</table>						
	</footer>
    
    
	 <script type="text/javascript">
				
		//相应提交按钮事件处理部分
		function bmtShowBill(strBillNo)
		{			
			//开始保存项目到购物车中
			window.location="ordermodify.php?selbillno=" + strBillNo;	
										
		}
		
	</script>
	
</section>

</body>
	
</html>