<?php
	session_start();
	
	//获取客户的微信ID号
	$strwxid=trim($_REQUEST['wxudid']);
	if(strlen($strwxid)>10)
	{
		$_SESSION["main_wxudid"]=$strwxid;
	}
	
	//判断是否有默认分店,如果有则直接进入默认分店界面
	$strlocalchainno=trim($_REQUEST['chidno']);
	if(strlen($strlocalchainno)>0)
	{
		$_SESSION["main_defhotelcode"]=$strlocalchainno;
		$_SESSION["main_defhotelsel"]="1";
	}
	
	//判断是否登录系统，散客固定为会员号"00000"
	if($_SESSION["main_viploginedsk"]!="1" |$_SESSION["main_vipnosk"]=="")
	{
		//没有登录开始启动登录
		require_once("logina.php");	
	}
	
	header("Content-type: text/html; charset=gb2312"); 
	
?>

<?php
	include "wechat.class.php";
	include 'errCode.php';
	
	require_once("db/db.php");	
	require_once("common/common.php");
	require_once("../Wx.Config.php");	//只加载一次
	
	$strMyTitle1=WxMainConfig::wxShareTitle;
	$strMyDesctxt1=WxMainConfig::wxShareDesc;
	
	$strMyTitle=iconv("UTF-8","GB2312",$strMyTitle1);
	$strMyDesctxt=iconv("UTF-8","GB2312",$strMyDesctxt);
	
	$_SESSION["main_nowpageishd"]="0";		//当前位优惠活动
	$_SESSION["main_strhdlistno"]="0";
		
	$opt = array(
		'appsecret'=>WxMainConfig::APPSECRET,//填写高级调用功能的密钥
		'appid'=>WxMainConfig::APPID	//填写高级调用功能的appid
	);
	$we = new Wechat($opt);
	$auth = $we->checkAuth();
	//var_dump($auth);
	$js_ticket = $we->getJsTicket();
	if (!$js_ticket) {
		echo "获取js_ticket失败！<br>";
		echo '错误码：'.$we->errCode;
		echo ' 错误原因：'.ErrCode::getErrText($we->errCode);
		//echo "dddddddddddddddd";
		exit;
	}
	$url = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
	//echo $url;
	$js_sign = $we->getJsSign($url);
	//var_dump($js_sign);
	//exit();
	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>
		//清空登录信息资料
		var ddt=<?php echo $_SESSION["main_defvipnoflagsk"]; ?>;
		if(ddt=="1")
		{	ddt=<?php echo $_SESSION["main_vipnosk"]; ?>;
			localStorage["main_defvipnosk"]=ddt;
		}
	</script>
	<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>


<script>
	wx.config({
		  debug: false,
		  appId: '<?php echo $js_sign['appid']; ?>', // 必填，公众号的唯一标识
		  timestamp: <?php echo $js_sign['timestamp']; ?>, // 必填，生成签名的时间戳，切记时间戳是整数型，别加引号
		  nonceStr: '<?php echo $js_sign['noncestr']; ?>', // 必填，生成签名的随机串
		  signature: '<?php echo $js_sign['signature']; ?>', // 必填，签名，见附录1
		  
		  jsApiList: [
			'checkJsApi',
			'onMenuShareTimeline',
			'onMenuShareAppMessage',
			'onMenuShareQQ',
			'onMenuShareWeibo',
			'hideMenuItems',
			'showMenuItems',
			'hideAllNonBaseMenuItem',
			'showAllNonBaseMenuItem',
			'translateVoice',
			'startRecord',
			'stopRecord',
			'onRecordEnd',
			'playVoice',
			'pauseVoice',
			'stopVoice',
			'uploadVoice',
			'downloadVoice',
			'chooseImage',
			'previewImage',
			'uploadImage',
			'downloadImage',
			'getNetworkType',
			'openLocation',
			'getLocation',
			'hideOptionMenu',
			'showOptionMenu',
			'closeWindow',
			'scanQRCode',
			'chooseWXPay',
			'openProductSpecificView',
			'addCard',
			'chooseCard',
			'openCard'
		  ]
	});
		
	wx.ready(function()
	{
		var mytitle = '<?php echo $strMyTitle;?>';
		var mydesctxt = '<?php echo $strMyDesctxt;?>';
		var surl='<?php echo WxMainConfig::ServerHttpPath;?>' + 'wxbook/login.php?wxvipno=' + '<?php echo $_SESSION["main_vipno"];?>';
		var imgUrl = '<?php echo WxMainConfig::ServerHttpPath;?>' + 'logo.jpg';
		
		//alert(surl);
		
		var sdata = {
			  title: mytitle,
			  desc: mydesctxt,
			  link: surl, // 分享链接
			  imgUrl: imgUrl,	//分享图标
			  success: function () {
			  //alert('用户确认分享后执行的回调函数');
			  },
			  cancel: function () {
			  //alert('用户取消分享后执行的回调函数');
			  }
		  };
		  wx.onMenuShareTimeline(sdata);
		  wx.onMenuShareAppMessage(sdata);
	});
	
</script>
	
<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="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;">酒店微信订房</span>
               	</td>
				<td height="50" width="30" valign="middle"></td>
		  	</tr>
		</table>
	</header>
		
	<article data-role="none">
		<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
			<?php		
				$inthotelindex=0;
				$selchainno="";
				$selchainname="";
				$seltelno="";
				$seladdress="";
				$selchainimg="";
				$strlocalchainno=$_SESSION["main_defhotelcode"];
				if(strlen($strlocalchainno)>0){
					$sql=sprintf("SELECT Chain_No,Chain_Name,Chain_Address,Chain_Tel FROM Chain_Infor WHERE Chain_No='%s' and wxflag>0;",$strlocalchainno);
				}
				else {
					$sql=sprintf("SELECT Chain_No,Chain_Name,Chain_Address,Chain_Tel FROM Chain_Infor WHERE wxflag>0;");	
				}
				
				$result = querySql($sql);
											
				while($row = fetch_array($result))
				{
					$inthotelindex=$inthotelindex+1;
					$selchainno = $row['Chain_No'];  
					$selchainname = $row['Chain_Name'];
					$seltelno = $row['Chain_Tel'];
					$seladdress = $row['Chain_Address'];
					
					$selchainimg="images/hotel_images/".$selchainno."/".$selchainno."_01.jpg";
			?>
				<!---------------------------------------------------------------------->
			<?php if($inthotelindex>1) { ?>
				<tr>
					<td height="1" width="5" bgcolor="#F2E2E2"></td>
					<td height="1" align="left" bgcolor="#F2E2E2"></td>
					<td height="1" width="5" bgcolor="#F2E2E2"></td>
				</tr>
				
				<tr>
					<td height="4" width="5" bgcolor="#66FFFF"></td>
					<td height="4" align="left" bgcolor="#66FFFF"></td>
					<td height="4" width="5" bgcolor="#66FFFF"></td>
				</tr>
				<tr>
					<td height="1" width="5" bgcolor="#F2E2E2"></td>
					<td height="1" align="left" bgcolor="#F2E2E2"></td>
					<td height="1" width="5" bgcolor="#F2E2E2"></td>
				</tr>
			<?php } ?>
			
				<tr>
					<td height="5" width="5"></td>
					<td height="5" align="left"></td>
					<td height="5" width="5"></td>
				</tr>
				<tr>
					<td height="15" width="5"></td>
					<td height="15" align="left">
						<div id="chain_suitid" onClick="window.location = 'hotelsel.php?chidno=<?php echo $selchainno; ?>&chsel=<?php echo $_SESSION["main_defhotelsel"];?>';">
							<table width="100%" border="0" cellspacing="0" cellpadding="0">
								<tr>
									<td width="130" height="90"><IMG style="border-radius:2px;" src="<?php echo $selchainimg; ?>" width="130" height="90" border="0"></td>
									<td width="10" height="90"></td>
									<td height="90">
										<!---显示分店资料 地址：电话：说明等-->
										<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
											<tr><td height="25" background-color="#55566"> <span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:14px;"><?php echo $selchainname; ?></span> </td></tr>
											<tr><td height="20"> <span style="color: #999999;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:11px;">电话:&nbsp;<?php echo $seltelno; ?></span> </td></tr>
											<tr><td height="45"> <span style="color: #999999;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:11px;">地址:&nbsp;<?php echo $seladdress; ?></span> </td></tr>
										</table>
									</td>
								</tr>
							</table>
						</div>
					</td>
					<td height="15" width="5"></td>
				</tr>
				
				<!---------------------------------------------------------------------->
			<?php
				}
				//释放数据库
				freeResult($result);
				closeDb();
			 ?>
				<tr>
					<td height="1" width="5" bgcolor="#F2E2E2"></td>
					<td height="1" align="left" bgcolor="#F2E2E2"></td>
					<td height="1" width="5" bgcolor="#F2E2E2"></td>
				</tr>
			<!---------------------------------------------------------------------->
			<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 #F2E2E2;border-bottom:1px solid #F2E2E2;border-left:1px solid #F2E2E2;border-right:1px solid #F2E2E2;">
		<table width="100%" height="10" border="0" cellpadding="0" cellspacing="0">
			<tr height="100%" valign="top">
				<td width="25%">					
					<a class="ui-btn ui-icon-home ui-btn-icon-top" data-transition="slide" href="index2.php" data-direction="reverse" style="width:100%;height:10px;margin:0px auto 0px auto;color:#666666">主页</a>
				</td>
				<td width="25%">					
					<a class="ui-btn ui-icon-shop ui-btn-icon-top" data-transition="slide" href="indexhd.php" data-direction="reverse" style="width:100%;height:10px;margin:0px auto 0px auto;color:#666666">优惠活动</a>
				</td>
				<td width="25%">
					<a class="ui-btn ui-icon-bullets ui-btn-icon-top" data-transition="slide" target="_blank" href="orderlist.php" style="width:100%;height:10px;margin:0px auto 0px auto;color:#666666">我的订单</a>
				</td>
				<td width="25%">
					<a class="ui-btn ui-icon-tag ui-btn-icon-top" data-transition="slide" target="_blank" href="roomlist.php" style="width:100%;height:10px;margin:0px auto 0px auto;color:#666666">我的住房</a>
				</td>
			</tr>
		</table>						
	</footer>
</section>

</body>
	
</html>