<?php
	session_start();

	require_once("db/db.php");	
	require_once("common/common.php");
	require_once("../Wx.Config.php");	//只加载一次

	$price = trim($_REQUEST['price']);	 
	$orderno = trim($_REQUEST['orderno']);	
	$payerror= trim($_REQUEST['payer']);
	
	$price=str_replace(',','',$price);
	$pricewx = $price;
	$intIsDubgeModle = WxMainConfig::NowIsDubgeModle;
	if($intIsDubgeModle=='1')
	{
		$pricewx = '0.01';
	}
	
	$sql = sprintf("SELECT a.VIP_LiftSum,a.VIP_IntegVal,a.VIP_UsedSum,b.Sub_State,a.VIP_State FROM VIP_Main a,VIP_Item b WHERE a.VIP_NO=b.VIP_NO AND b.Sub_No='%s'", $_SESSION["main_vipno"]);
	//echo $sql;
	//exit();
	$result = querySql($sql);
	$row = fetch_array($result);
	$VIP_LiftSum = trim($row['VIP_LiftSum']); //预订房型
	freeResult($result);
	
	//判断是否已经支付过
	$sql = sprintf("SELECT Sum(PayFor_Value)AS SumPayFor FROM TR_Consume_List WHERE order_no='%s'",$orderno);
	$result = querySql($sql);
	$row = fetch_array($result);
	$havepayfor = trim($row['SumPayFor']); //预订房型
	
	freeResult($result);
	closeDb();
?>

<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>
	<script src="jsp4/jquery.js"></script>
	<link rel="stylesheet" href="css/mycss.css"> 
	
	<!--<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 language="JavaScript"> 
		//不允许进行后退
		javascript:window.history.forward(0); 
	</script>
</head>

<body leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0">
	<header data-role="header" data-position="fixed" data-tap-toggle="false" style="border-top-width:0px;border-bottom-width:0px;">
        <table width="100%" height="45" border="0" cellpadding="0" cellspacing="0" bgcolor="<?php echo WxMainConfig::colHeadBkColorBook;?>">
		   	<tr>
				<td height="45" width="30" align="center"></td>
				<td height="45" align="center" valign="middle">
	                <span id="MsgTxt" style="color:<?php echo WxMainConfig::colHeadTextColorBook;?>;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:19px;text-shadow:none;">预付款金额:￥<?php echo $price;?></span>
               	</td>
				<td height="45" width="30" valign="middle"></td>
		  	</tr>
		</table>
	</header>

<form name="f">
<table width="100%" border=0 cellSpacing=0 cellPadding=0>
	<tr height="50px">
		<td width="10"></td>
		<Td align="center" valign="center" width="50px" style="padding-bottom:7px"><input type="radio" name="paytype" value="1" checked></td>
		<Td>会员余额支付</td>
		<Td align="right">￥<?php echo $VIP_LiftSum;?>&nbsp;&nbsp;</td>
		<td width="10"></td>
	</tr>
	<tr height="1px">
		<td width="10"></td>
		<Td colspan="3" style="background:#ccc"></td>
		<td width="10"></td>
	</tr>
	<tr height="50px">
		<td width="10"></td>
		<Td align="center" valign="center" width="50px" style="padding-bottom:7px"><input type="radio" name="paytype" value="2"></td>
		<Td>微信支付</td>
		<Td align="right"></Td>
		<td width="10"></td>
	</tr>
	<tr height="1px">
		<Td colspan="5" style="background:#ccc"></td>
	</tr>
	
	<tr height="20px">
		<Td colspan="5" ></td>
	</tr>
</table>
<table width="100%" border=0 cellSpacing=0 cellPadding=0>
	<tr height="50px" width="100%">
		<td width="10"></td>
		<td>
			<?php 
				if($havepayfor<=0)
				{
			?>
				<span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:14px;text-shadow:none;">
					<a class="ui-btn ui-corner-all" style="color:#A6A600;" target="_blank" href="javascript:pay()">支付</a>
				</span>

			<span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:14px;text-shadow:none;">
				<a class="ui-btn ui-corner-all" style="color:#A6A600;" target="_blank" href="orderlist.php">到店付款</a>
			</span>
			<?php } ?>

			
		</td>
		<td width="10"></td>
	</tr>
	
	<?php if($intIsDubgeModle=='1') { ?>
				 <tr width="100%">
					<td height="30" colspan="3"></td>
				</tr>
		
				 <tr width="100%">
					<td height="10" width="10"></td>
					<td height="10" align="center">
						<span style="color:#D12023 ;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;text-shadow:none;">演示模式，在微信支付页面时自动按0.01支付</span> 
					</td>
					<td height="10" width="10"></td>
				</tr>
		<?php } ?>
		
</table>

</form>

<?php 
				if(strlen($payerror)>0)
				{
			?>
<span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:14px;">
	<table width="100%" border=0 cellSpacing=0 cellPadding=0>
		<tr height="50px">
			<Td align="center" valign="center" width="50px" style="padding-bottom:7px"><?php echo $payerror;?></td>
		</tr>
		<tr height="1px">
			<Td style="background:#ccc"></td>
		</tr>
	</table>
</span>
<?php
	}
?>


	<script>
		var VIP_LiftSum = <?php echo $VIP_LiftSum;?>;
		var price = <?php echo $price;?>;
		function pay()
		{
			var paytype = $("input[name='paytype']:checked").val();
			if(paytype == 1)//余额
			{
				if(VIP_LiftSum < price)
				{
					alert("余额不足!");
				}
				else
				{
					window.location = "liftsumpay.php?price=<?php echo $price;?>&orderno=<?php echo $orderno;?>";
				}
			}
			else if(paytype == 2)//微信
			{
				window.location = "wxpay.php?price=<?php echo $price;?>&orderno=<?php echo $orderno;?>";
			}
		}
	</script>
	
	<script>
				//禁止页面上下滑动,整个页面都不能滑动了
				document.addEventListener('touchmove', function(e) {
					e.preventDefault();
				});
		</script>
</body>
</html>



