<?php
	session_start();
	//判断是否登录系统		
	if($_SESSION["main_viplogined"]!="1" |$_SESSION["main_vipno"]=="")
	{
		//没有登录开始启动登录
		header('location:login.php?stext=');
		exit;
	}
?>
<!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>

	<script src="jsp4/jquery.js"></script>
	<link rel="stylesheet" href="css/mycss.css"> 

	<script src="jsp5/jquery.mobile-1.4.5.min.js"></script>
	<link rel="stylesheet" href="jsp5/jquery.mobile-1.4.5.min.css">
	<link rel="stylesheet" href="jsp4/jquery.mobile.datepicker.css">
	
	<script src="jsp4/jquery.ui.datepicker.js"></script>
	<script id="mobile-datepicker" src="jsp4/jquery.mobile.datepicker.js"></script>
	<script src="jsp5/jquery-1.7.min.js"></script>
	
	<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>

	<script>
		//禁止页面上下滑动,整个页面都不能滑动了
		document.addEventListener('touchmove', function(e) {
			e.preventDefault();
		});
	</script>
<?php
	require_once("db/db.php");	
	require_once("common/common.php");
	
	//设置统一语言格式
	//header("Content-type: text/html; charset=gb2312"); 
	$strblistno=trim($_REQUEST['blno']);
	if(strlen($strblistno)==0)
	{
		$strblistno=0;
	}
	$strroomno='';
	$strchainname='';
	$strorderno='';
	$strcheckin='';
	$strcheckout='';
	
	//得到住房信息
	$sql = sprintf("select c.Chain_Name,a.Order_No,a.Room_No,convert(varchar(16),a.SelectRoomTime,120)as SelectRoomTime,
						convert(varchar(16),a.Cancel_Date,120)as Cancel_Date from tr_order_room_list a,tr_order_inform b,chain_infor c
						where a.Order_No=b.Order_No and b.order_state<2 and a.room_billstate=2 and c.chain_no=b.chain_no and a.ListNo=%s",$strblistno);
	$result = querySql($sql);
	$row = fetch_array($result);
	
	$strroomno = trim($row['Room_No']);
	$strchainname = trim($row['Chain_Name']);
	$strorderno = trim($row['Order_No']);
	$strcheckin = trim($row['SelectRoomTime']);
	$strcheckout = trim($row['Cancel_Date']);
	
	freeResult($result);
	closeDb();
		
?>

<body leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0">
<!--第一个页面的内容实现---------------------------->
<section data-role="page" id="roomview1">
	<!--底层图，设置高度为150!-->
	<div style="width:100%;height:165px;z-Index:-2;">
		<table width="100%" border="0" cellpadding="0" cellspacing="0">
			<tr><td height="10" width="%100">
				<img style="width:100%;height:180px;border:0px;" src="images/temp/rvb1.png" />
			</td></tr>
			
		</table>
	</div>
	
	<!--设置背景按钮图和当前房号，高度设置为10px---------->
	<div style="width:100%;height:45px;z-Index:-1;">
		<table width="100%" border="0" cellpadding="0" cellspacing="0">
			<tr><td height="10" width="%100" align="center">
				<span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:13px;">当前房号 <?php echo $strroomno;?></span>
			</td></tr>
			<tr><td height="10" width="%100"></td></tr>
			<tr><td height="10" width="%100" align="center">
				<img style="width:277px;height:277px;border:0px;" src="images/temp/rvb2.png" />
			</td></tr>
		</table>
	</div>
		
	<!--设置按钮执行动作的图标和对象-->
	<div style="width:100%;height:100%;">
		<table width="100%" border="0" cellpadding="0" cellspacing="0">
			<tr><td height="10" width="%100" align="center">
				<table width="300" border="0" cellpadding="0" cellspacing="0">
					<tr>
						<td height="52" width="80" align="right">
							
						</td>
						
						<td height="52" width="140" align="center">
							<!--开门-->
							<div style="width:100%;height:40px;">
								<img id="cmd_wxopen" style="width:32px;height:52px;border:0px;" src="images/temp/lock.png" />
							</div>
						</td>
						
						<td height="52" width="80" align="left">
						
						</td>
					</tr>
															
					<tr>
						<td height="38" width="80" align="right">
							<!--早餐-->
							<div style="width:100%;height:30px;">
								<!--<img id="cmd_wxbreak" style="width:35px;height:53px;border:0px;" src="images/temp/breakfast.png" />-->
								
								<div data-demo-html="true">
									<a href="#popupParis1" data-rel="popup" data-position-to="window" data-transition="fade">
										<img id="cmd_wxbreak" style="width:35px;height:53px;border:0px;" src="images/temp/breakfast.png" />
									</a>
									
									<div data-role="popup" id="popupParis1" data-overlay-theme="b" data-theme="b" data-corners="false">
										<a href="#" data-rel="back" class="ui-btn ui-corner-all ui-shadow ui-btn-a ui-icon-delete ui-btn-icon-notext ui-btn-right">Close</a>
										
										<table width="270" height="330" border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffff">
											<tr><td height ="20" align="center"></td></tr>
											<tr><td height ="40" align="center"><span style="color: #808000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:25px;">早餐识别码</span></td></tr>
											<tr><td height ="270"><img class="popphoto" src="barcode.php?tbno=<?php echo $strblistno;?>&doid=1" style="width:270px;height:270px;max-height:512px;" alt="Paris, France"></td></tr>
										</table>
									</div>
								</div>
							
							</div>
								
						</td>
						
						<td height="38" width="140" align="center">
						
						</td>
						
						<td height="38" width="80" align="left">
							<!--房控-->
							<div style="width:100%;height:30px;">
								<img id="cmd_wxroomkz" style="width:36px;height:53px;border:0px;" src="images/temp/roomfk.png" />
							</div>	
						</td>
					</tr>
					
					<tr><td height="30" colspan="3" align="center">
							<div style="width:100%;height:30px;padding-top:8px;">
								<img id="wx_state" style="width:50px;height:50px;border:0px;" src="images/temp/free.png" />
							</div>
					</td></tr>
					
					<tr>
						<td height="53" width="80" align="right">
							<!--停车-->
							<div style="width:100%;height:54px;">
								<div data-demo-html="true">
									<a href="#popupParis2" data-rel="popup" data-position-to="window" data-transition="fade">
										<img id="cmd_wxcar" style="width:35px;height:53px;border:0px;padding-top:10px;" src="images/temp/car.png" />
									</a>
									
									<div data-role="popup" id="popupParis2" data-overlay-theme="b" data-theme="b" data-corners="false">
										<a href="#" data-rel="back" class="ui-btn ui-corner-all ui-shadow ui-btn-a ui-icon-delete ui-btn-icon-notext ui-btn-right">Close</a>
										<table width="270" height="330" border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffff">
											<tr><td height ="20" align="center"></td></tr>
											<tr><td height ="40" align="center"><span style="color: #808000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:25px;">停车识别码</span></td></tr>
											<tr><td height ="270"><img class="popphoto" src="barcode.php?tbno=<?php echo $strblistno;?>&doid=2" style="width:270px;height:270px;max-height:512px;" alt="Paris, France"></td></tr>
										</table>
									</div>
								</div>
							</div>
						</td>
						
						<td height="53" width="140" align="center">
						
						</td>
						
						<td height="53" width="80" align="left">
							<!--梯控-->
							<div style="width:100%;height:54px;">
								<img id="cmd_wxlift" style="width:36px;height:53px;border:0px;padding-top:10px;" src="images/temp/lift.png" />
							</div>
						</td>
					</tr>
					
					
					<tr>
						<td height="52" width="80" align="right">
							
						</td>
						
						<td height="52" width="140" align="center">
							<!--服务-->
							<img id="cmd_wxoserver" style="width:33px;height:52px;border:0px;padding-top:10px;" src="images/temp/server.png" />
						</td>
						
						<td height="52" width="80" align="left">
						
						</td>
					</tr>
					
				</table>
			</td></tr>
		</table>		
	</div>	
	
		<script type="text/javascript">
			var timerid1,timerid2;	//定时器句柄，用来结束定时器是用
			var havesendcmd;
			var cmdtimes=0;
			$("#cmd_wxopen").click(
				function()
				{	
					if(havesendcmd==1)
					{
						//已执行过，再点不执行
						//alert("正在提交开门指令");
					}
					else
					{
						havesendcmd=1;
						cmdtimes=0;
						var img = document.getElementById('wx_state');
						img.src="images/temp/ap.png";
						//setTimeout(setDefImg(),1000);
						//alert("正在提交开门指令");
						//img.src="images/lock3.png";
						timerid1=setInterval("setDefImg()",2000);
						var blistno="<?php echo $strblistno;?>";						
						//提交开门指令
						//window.location="wxopen.php?blistno=" + blistno;
						//return;
						var strret;
						strret=$.get("wxopen.php?blistno=" + blistno,function(result){});
						
						//alert(strret);
								//维信开门相关
								///alert("请选择订房数！");
								//$("wxdoorimg").attr("src","images/lock1.png");
						/*
								var code="2EC86502004B1200";
								var licenseKey="fe01ce2a7fbac8fafaed7c982a04e229";
								alert("请选择订房数1！");
								
								ArrayList<BusCurrentStopBean> stopBeans = new ArrayList<BusCurrentStopBean>();
								
								try {
									HttpClient client = HttpClientUtils.getInstance();
									Map<String, String> params = new HashMap<String, String>();
									params.put("code", code);
									params.put("licenseKey", licenseKey);
									String xml = SoapXmlParser.toXml("OpenLock", params);
									HttpPost post = new HttpPost("http://demo.zigbeei.com/LockService.asmx");
									post.addHeader("Host", "demo.zigbeei.com");
									post.addHeader("Content-type", "application/soap+xml; charset=utf-8");
									byte[] b = xml.getBytes("utf-8");
									InputStream is = new ByteArrayInputStream(b,0,b.length);
									post.setEntity(new InputStreamEntity(is, b.length));
									HttpResponse response = client.execute(post);
									HttpEntity entity = response.getEntity();
									parserCurrentStop(stopBeans, SoapXmlParser.getResult(EntityUtils.toString(entity), "OpenLock"));
								} catch (Exception e) 
								{
									e.printStackTrace();
								}
								//alert("请选择订房数2！");
							*/
					}
				}
			);
			//cmd_wxbreak
			//cmd_wxroomkz
			//cmd_wxcar
			//cmd_wxlift
			//cmd_wxoserver
			
			//每1秒刷新下指令执行状态
			function setDefImg()
			{	
				//判断执行开门的结果
				var intopendoor=0;
				intopendoor=1;
				
				//SHOW
				var img = document.getElementById('wx_state');
				if(intopendoor==1)	//已经开门
				{
					img.src="images/temp/open.png";
					//设置6秒后自动更改为关门状态
					timerid2=setInterval("setDefImgClosed()",4000);
					
					cmdtimes=13;	//设置为结束
				}
				else
				{
					//img.src="images/lock1.png";
					cmdtimes=cmdtimes+1;
				}							
				
				if(cmdtimes>10)
				{
					clearInterval(timerid1);	//结束定时器 
					//更新指令为已执行，未有发送的指令，可以相应点击
					if(cmdtimes<13)
					{
						havesendcmd=0;
					}
				}
			};
			
			//设置6秒后自动更改为关门状态
			function setDefImgClosed()
			{	
				//还原成原来的图片
				clearInterval(timerid2);	//结束定时器 
				
				var img = document.getElementById('wx_state');
				img.src="images/temp/free.png";
				
				//更新指令为已执行，未有发送的指令，可以相应点击
				havesendcmd=0;
			};
		</script>
		

</section>

</body>
	
</html>