<?php
	session_start();
	require_once("../Wx.Config.php");	//只加载一次
	//判断是否登录系统		
	if($_SESSION["main_viplogined"]!="1" |$_SESSION["main_vipno"]=="")
	{
		//没有登录开始启动登录
		header('location:login.php?stext=');
		exit;
	}
	$_SESSION["main_vipwxpayforyd"]="0";
	$intIsDubgeModle = WxMainConfig::NowIsDubgeModle;
	
	header("Content-type:text/html;charset=gb2312");
?>
<!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 language="JavaScript"> 
		//不允许进行后退
		javascript:window.history.forward(0); 
	</script>
</head>

<script>	
	//隐藏维信右上角菜单
	function onBridgeReady(){
		WeixinJSBridge.call('hideOptionMenu');
	}

	if (typeof WeixinJSBridge == "undefined")
	{
		if( document.addEventListener )
		{
			document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
		}
		else if (document.attachEvent)
		{
			document.attachEvent('WeixinJSBridgeReady', onBridgeReady); 
			document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
		}
	}
	else
	{
		onBridgeReady();
	}
</script>


<body leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0">
<!--第一个页面的内容实现---------------------------->
<section data-role="page" id="mdipage1">
	<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;">会员帐户充值</span>
               	</td>
				<td height="45" width="30" valign="middle"></td>
		  	</tr>
		</table>
	</header>
	
	<article data-role="none">
					
		<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
			<tr>
				<td height="4" width="15"></td>
				<td height="4" align="left"></td>
				<td height="4" width="15"></td>
			</tr>
			
			<tr>
				<td height="25" width="15"></td>
				<td height="25" align="left">
					<form name="fvip">
						<table width="100%" border=0 cellSpacing=0 cellPadding=0>
							<?php 
								require_once("db/db.php");	
								require_once("common/common.php");
								$intRowIndex = 0;
								
								$intSelFlag=1;
								$intItemCount=0;
								$strSubNo = trim($_SESSION["main_vipno"]);
								//得到该会员号类型的方案项目
								$sql=sprintf("SELECT a.ListNo,a.ItemPayVal,a.ItemFreeVal,a.Send_IntegVal
											FROM VIP_PayForCaseItem a,VIP_PayForCase b,VIP_Type c,VIP_Main d,VIP_Item e 
											Where a.CListNo=b.ListNo And b.CaseName=c.PayForCase And c.Type_Name=d.VIP_Type And d.VIP_No=e.VIP_No And e.Sub_No='%s'
											Order By a.ItemPayVal ASC",$strSubNo);
							
								$result = querySql($sql);
											
								while($row = fetch_array($result))
								{
									$fltItemPayVal=$row['ItemPayVal'];
									$fltItemFreeVal=$row['ItemFreeVal'];
									$fltSendIntegVal=$row['Send_IntegVal'];
									$strSListNo=$row['ListNo'];
									
									if(empty($fltItemPayVal))
										$fltItemPayVal=0;
									if(empty($fltItemFreeVal))
										$fltItemFreeVal=0;
									if(empty($fltSendIntegVal))
										$fltSendIntegVal=0;
					
									if($fltItemPayVal>0)
									{
										$intItemCount = $intItemCount + 1;
										$strItemName = "充值".number_format($fltItemPayVal,0).'元';
										if($fltItemFreeVal>0)
											$strItemName = $strItemName.'，赠送'.number_format($fltItemFreeVal,0).'元';
										
										$strSendInteg = "";
										if($fltSendIntegVal>0)
										{
											$strSendInteg = '再赠送'.number_format($fltSendIntegVal,0).'积分';
										}
										
										$intRowIndex = $intRowIndex + 1;
							?>
							
							<tr>
								<td height="40" width="5"></td>
								<?php if($intSelFlag>0) {?>
									<td height="40" width="45" valign="top" align="center"><input type="radio" name="paytype" style="margin-top:2px;" value="<?php echo $intRowIndex;?>" checked></td>
								<?php } else { ?>
									<td height="40" width="45" valign="top" align="center"><input type="radio" name="paytype" style="margin-top:2px;" value="<?php echo $intRowIndex;?>"></td>
								<?php } ?>
																
								<input id="itmp<?php echo $intRowIndex;?>" name="itmp<?php echo $intRowIndex;?>" value="<?php echo number_format($fltItemPayVal,0,".","");?>" type="hidden" />
								<input id="itmf<?php echo $intRowIndex;?>" name="itmf<?php echo $intRowIndex;?>" value="<?php echo number_format($fltItemFreeVal,0,".","");?>" type="hidden" />
								
								<td height="40" valign="middle">
									<div style="width:100%;padding-top:6px;">
										<span style="color: #000000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:15px;"><?php echo $strItemName;?></span>
									</div>
									<div style="width:100%;padding-bottom:0px;">
										<span style="color: #E80015;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:12px;"><?php echo $strSendInteg;?></span>
									</div>
									<?php 
										//得到该充值项目的赠送电子券信息
										$sqlsub=sprintf("SELECT a.ListNo,b.Item_Value,a.Send_VoucherCount,dbo.WXF_GetChainName(b.Chain_No)As ChainName
											FROM VIP_PayForCaseItemSub a,TR_Vouchers_Type b Where a.VTListNo=b.ListNo And a.SListNo=%s Order By a.ListNo ASC",$strSListNo);	
							
										$resultsub = querySql($sqlsub);
											
										while($rowsub = fetch_array($resultsub))
										{
											$fltVoucherVal=$rowsub['Item_Value'];
											$intVoucherCount=$rowsub['Send_VoucherCount'];
											$strSubChainName =trim($rowsub['ChainName']);
											
											if(empty($fltVoucherVal))
												$fltVoucherVal=0;
											if(empty($intVoucherCount))
												$intVoucherCount=0;
																								
											if($intVoucherCount>0)
											{
												$strSendItem = '再送'.number_format($fltVoucherVal,0).'元电子券'.number_format($intVoucherCount,0).'张';
												if($strSubChainName<>'*')
												{
													$strSendItem = $strSendItem . '(仅限在'.$strSubChainName.'使用)';
												}
										
									?>
									<div style="width:100%;padding-bottom:0px;">
										<span style="color: #E80015;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:12px;"><?php echo $strSendItem;?></span>
									</div>
									<?php		
											}
										}
										freeResult($resultsub);
									?>
									<div style="width:100%;padding-bottom:5px;"></div>
								</td>
							</tr>
							<tr height="1px"><td colspan="3" style="background:#F2E2E2"></td></tr>
							
							<?php	
										$intSelFlag=0;
									}
								}
								//释放数据库
								freeResult($result);
								closeDb();
							?>
														
							<?php if($intItemCount<1) { ?>
							<tr>
								<td height="50" width="5"></Td>
								<td height="50" width="45" colspan="2" valign="middle" align="center">
									<table width="100%" border="0" cellpadding="0" cellspacing="0">
										<tr>
											<td width="80"><span style="color: #000000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:15px;">充值金额：</span></td>
											<td>
												<div style="float:left;width:100%;">
													<input id="mytext" name="mytext" value="" type="number" pattern="[0-9]*" placeholder='请输入充值金额' autocomplete="off" data-clear-btn="true" data-mini="true" />
												</div>	
											</td>
										</tr>
									</table>
								</td>
							</tr>
							<tr height="1px"><td colspan="3" style="background:#F2E2E2"></td></tr>
							<?php } ?>
						</table>
					</form>
				</td>
				<td height="25" width="15"></td>
			</tr>
				
			<tr>
				<td height="10" width="15"></td>
				<td height="10" align="left"></td>
				<td height="10" width="15"></td>
			</tr>
			
			<tr>
				<td height="40" width="15"></td>
				<td height="40" align="center">
					<table width="100%" border="0" cellpadding="0" cellspacing="0">
						<tr>
							<td width="50%" align="center">
								<div style="width:90%;height:40px;padding-top:6px;">	
									<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" href="#" style="color:#A6A600;" data-transition="slide" id="modifypost">提交充值</a>
									</span>
								</div>	
							</td>
							<td width="50%" align="center">
								<div style="width:90%;height:40px;padding-top:6px;">	
									<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" href="vipmain.php" style="color:#999933;" target="_blank" data-role="button">返回</a>
									</span>
								</div>
							</td>
						</tr>
					</table>
					
				</td>
				<td height="40" width="15"></td>
			</tr>

			<?php if($intIsDubgeModle=='1') { ?>
				 <tr width="100%">
					<td height="30" colspan="3"></td>
				</tr>
		
				 <tr width="100%">
					<td height="10" width="15"></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="15"></td>
				</tr>
			<?php } ?>
			
		</table>
		
		
		<script type="text/javascript">
						
		 	$("#modifypost").click(
				function()
		 		{
					var intRowPos = $("input[name='paytype']:checked").val();
					if(intRowPos == undefined)
					{
						intRowPos=1;
					}
					//得到付款金额和赠送金额
					var payvalue = $("#itmp" + intRowPos.toString()).val();
					var sendvalue = $("#itmf" + intRowPos.toString()).val();
				
					var selpayval="0";
					var selfreeval="0";
					//var payvalue = $("input[name='paytype']:checked").val();
					var intNextFlag=0;
					if (payvalue == undefined) 
					{
						payvalue=0;
					}
					if (sendvalue == undefined) 
					{
						sendvalue=0;
					}
					
					if(payvalue<1)
					{
						var strtemp = $("#mytext").val();
						if(strtemp.length<1)
						{	
							intNextFlag=1;
							alert("请输入充值金额！");
						}
						else
						{
							selpayval=strtemp;
						}
						
					}
					else
					{
						selpayval=payvalue;
						selfreeval = sendvalue;
					}
					//alert(selpayval);
					if(intNextFlag==0)
					{
						window.location.href="vipwxpay.php?pval=" + selpayval + '&fval=' + selfreeval;
					}
		 		}
			);
		</script>
		
		<script>
			//禁止页面上下滑动,整个页面都不能滑动了
			//document.addEventListener('touchmove', function(e) {
			//	e.preventDefault();
			//});
		</script>
	</article>
</section>

</body>
	
</html>