<?php
	session_start();
	header("Content-type:text/html;charset=gb2312");
	
	require_once("db/db.php");	
	require_once("common/common.php");
	require_once("../Wx.Config.php");	//只加载一次

	$price = trim($_REQUEST['price']);	 
	$orderno = trim($_REQUEST['orderno']);	
	
	$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_vipnosk"]);
	//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();
	/*
	
	
	//设置统一语言格式
	header("Content-type: text/html; charset=gb2312"); 
	
	$strroomtypeid=$_REQUEST['romtype'];				//入住房型ID
		
	$retval=0;

	$strchainno = $_SESSION["main_order_chainno"];
	$strsubno = $_SESSION["main_vipnosk"];
	$strcheckinday = $_SESSION["main_order_checkinday"];	//入住日期
	$strcheckoutday = $_SESSION["main_order_checkoutday"];	//入住日期
	$strroomcount = trim($_REQUEST['rmcount']);				//订房数量
	$strremarks = trim($_REQUEST['rmtxt']);					//预订说明
	$strmanname = trim($_REQUEST['rmname']);				//预订人
	$strmantelno = trim($_REQUEST['rmtelno']);				//联系电话
	$strkeeptime = trim($_REQUEST['rmkptime']);				//保留时间
	$strroomprice = trim($_REQUEST['rmprice']);				//价格
	$strbreakfast = "0";	//是否含早餐
	$strinvoice = "0";		//是否开发票
	$strneworderno = "";	//返回的单号
	
	//得到房型
	$sql=sprintf("SELECT Room_Type FROM TR_Room_Type WHERE ListNo=%s;",$strroomtypeid);
	$result = querySql($sql);
	$row = fetch_array($result);
	$strroomtype = trim($row['Room_Type']); //预订房型
	freeResult($result);
	
	
	//开始创建
	$sql = sprintf("EXECUTE TRS_CancelOrderNoBook '%s','APP预订取消订单'",$strorderno);
	
	$sql = sprintf("EXECUTE TRS_WebNewBookOrder '%s','%s','%s',%s,'%s','%s',%s,'%s','%s','%s','%s','2012-02-01 %s',0,0,'';",
				$strchainno,$strsubno,$strroomtype,$strroomprice,$strcheckinday,$strcheckoutday,$strroomcount,$strremarks,$strmanname,$strmanname,$strmantelno,$strkeeptime);

	$strRet=0;		//得到处理返回值
	$retval=0;
	
	$result = querySql($sql);
	if($row = fetch_array($result))
	{
		$strRet=$row['Res'];
		if($strRet=='1')
		{
			$retval=1;	
			//无此会员或已注销
		}
		elseif($strRet=='2')
		{
			$retval=2;
			//分店信息不正确
		}
		elseif($strRet=='3')
		{
			$retval=3;
			//可用房数不足
		}
		elseif($strRet=='4')
		{
			$retval=4;
			//保存订单失败
		}
	}
	freeResult($result);
	closeDb();
	
	if($retval<1)
	{	
		//header('Location: index.php');
		echo "<script>window.location.href='index.php#page1';</script>";
	}
	else
	{
		//重新编辑
		$strurl='ordernew.php?romtype='.$strroomtypeid.'&stext='.$retval;
		
		//header('Location: ' .$strurl);
		echo "<script>window.location.href='ordernew.php?romtype=".$strroomtypeid."&stext=".$retval."';</script>";		
	}*/
?>

<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="50" border="0" cellpadding="0" cellspacing="0" bgcolor="<?php echo WxMainConfig::colHeadBkColorBook;?>">
		   	<tr>
				<td height="50" width="30" align="center"></td>
				<td height="50" 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="50" width="30" valign="middle"></td>
		  	</tr>
		</table>
	</header>
<form name="f">
	<table width="100%" border=0 cellSpacing=0 cellPadding=0>
		<tr>
			<td height="50" width="20"></Td>
			<td height="50" width="50" valign="middle" align="center"><input type="radio" name="paytype" value="2" checked></td>
			<td height="50" valign="middle">微信支付</td>
		</tr>
		<tr height="1px"><td colspan="3" style="background:#F2E2E2"></td></tr>
	</table>
</form>


	<table width="100%" border=0 cellSpacing=0 cellPadding=0>
    	<tr>
			<td height="20" width="10"></td>
			<td height="20"></td>
            <td height="20" width="10"></td>
      	</tr>
        
		<tr>
			<td height="5" width="10"></td>
			<td height="5">
    
                <table width="100%" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                        <td width="48%">
								<div onClick="window.location = 'orderlist.php';" style="border-radius:5px;width:100%; height:40px; background-color:#D7AA28;">
                                    <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
                                        <tr><td width="100%" height="100%" align="center">
                                            <span style="color:#fff ;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:16px;text-shadow:none;">到店支付</span>                            	
                                        </td></tr>
                                    </table>
                                </div>				
                        </td>
                        <td width="4%"></td>
                        <td width="48%">
                            
                                <div onClick="pay();" style="border-radius:5px;width:100%; height:40px; background-color:#CD0013;">
                                    <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
                                        <tr><td width="100%" height="100%" align="center">
                                            <span style="color:#fff ;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:16px;text-shadow:none;">支 付</span>                            	
                                        </td></tr>
                                    </table>
                                </div>				
                        </td>
                    </tr>
                </table>
            </td>
			<td height="5" 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>


	<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>
</body>
</html>



