<?php
	session_start();
			
	ini_set('session.gc_maxlifetime', 99999999); //设置时间 永不过期
		
	$strSelGDSID=trim($_REQUEST['doSelGDSID']);
	
	$strwxfwflag=trim($_REQUEST['wxfw']);
		
	//微信号
	$strwxudid=$_REQUEST['wxudid'];
	
	//1.根据微信号获取工号和姓名等资料
	$strDefCustomID='';
	$strDefUserNo='';
	$strDefHotelURL='';
	$strDefUListNo=0;
	
	if(strlen($strwxudid)>20)
	{
		require_once("db/db.php");	
		require_once("common/common.php");
	
		$sql=sprintf("SELECT a.CustomID,a.HotelURL,b.ListNo,b.UserNo FROM WX_Hotel_List a,WX_Hotel_User b WHERE a.CustomID=b.CustomID And b.UserWXID='%s' And a.WXEnabled>0",$strwxudid);
		$result = querySql($sql);
		
		if($row = fetch_array($result))
		{
			$strDefCustomID = $row['CustomID'];
			$strDefUserNo = $row['UserNo'];
			$strDefHotelURL = $row['HotelURL'];
			$strDefUListNo = $row['ListNo'];
		}
		freeResult($result);
		closeDb();
	}
	
	$strAutoLongCustomID=$strDefCustomID;
	
	//根据微信号获取是否登陆过，如果登陆过则自动进入页面
	if($strSelGDSID=='1')
	{
		//手动设置
		$strAutoLongCustomID='';
	}
	
	
?>
<!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="jsp4/jquery.mobile-1.4.3.min.css">
	<script src="jsp4/jquery.js"></script>
	<script src="jsp4/jquery.mobile-1.4.3.min.js"></script>
	<script src="jsp4/jquery.placeholder.min.js"></script>

	<script language="JavaScript"> 
		//不允许进行后退
		javascript:window.history.forward(1); 
	</script>
	
	<script>
		//禁止页面上下滑动,整个页面都不能滑动了
		document.addEventListener('touchmove', function(e) {
			e.preventDefault();
		});
	</script>
		
</head>

<script type="text/javascript">
		
		$().ready(function()
		{
			var strDefSoftCustomID='<?php echo $strAutoLongCustomID;?>';
			//alert(strDefSoftCustomID);
			
			if (typeof (strDefSoftCustomID) == "undefined") 
			{
				strDefSoftCustomID="";
			}
			
			//alert(strDefSoftCustomID);
									
			var intSelGDSID='<?php echo $strSelGDSID;?>';
			if(intSelGDSID=='1')
			{
				return;
			}
			
			//如果已经存在识别号 strDefSoftCustomID
			if(strDefSoftCustomID.length>4)
			{
				bmtStartToWeb();
			}
			
		});

		//隐藏维信右上角菜单
		/*
		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="page1">
	<header data-role="header" data-position="fixed" data-tap-toggle="false" style="border-top-width:0px;border-bottom-width:0px;bkc">
        <table width="100%" height="45" border="0" cellpadding="0" cellspacing="0" >
		   	<tr bgcolor="#3595f5">
				<td height="45" align="center" valign="middle">
	                <span id="MsgTxt" style="color:#fff;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:19px;text-shadow:none;">微信云点通</span>
               	</td>
		  	</tr>
			
		</table>
	</header>
		
	<article data-role="none">
		<table width="100%" border="0" cellpadding="0" cellspacing="0">		
			<tr><td height="20" colspan="3"></tr>
			
			<tr>
				<td height="50" width="10"></td>
				<td height="50" align="left" valign="top">
					<table width="100%" border="0" cellpadding="0" cellspacing="0" bordercolor="#E9DFDF" style="border-top:0px solid #FBF3EA;border-collapse:collapse;">
						<tr>
							<td height="55" width="120" align="right" valign="middle">
								<span style="color:#000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:16px;text-shadow:none;">客户识别号：</span>
							</td>
							<td height="55" align="left" valign="middle">
								<input id="mytext1" name="mytext1" value='<?php echo $strDefCustomID;?>' type="text" placeholder="客户识别号" autocomplete="off" data-mini="true"/>								
							</td>
							<td height="55" width="15" align="right" valign="middle"></td>
						</tr>
						
						
					</table>
				
				</td>
				<td height="50" width="30"></td>
			</tr>
			
			<tr><td height="20" colspan="3"></tr>
			
			<tr>
				<td height="50" width="10"></td>
				<td height="50" align="left" valign="top">
					<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
						<tr>
							<td height="50" width="35"></td>
							<td height="50" >
							
								<div onClick="bmtStartToWeb();" style="border-radius:18px;width:98%; height:36px; border:1px solid #B10010;  ">   <!--background-color:#245fec;-->
									<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
										<tr><td width="100%" height="100%" align="center">
											<span style="color:#B10010 ;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:15px;text-shadow:none;">验证识别</span>
										</td></tr>
									</table>
								</div>				
							</td>
							<td height="50" width="8"></td>
						</tr>
					</table>
				</td>
				<td height="50" width="30"></td>
			</tr>
			
			<tr><td height="100" colspan="3"></tr>
		
	</article>

	
	<script type="text/javascript">
		function bmtStartToWeb()
		{	
			var strSoftID=$("#mytext1").val();
			
			if(strSoftID=='yx2025')
			{
				//查询所有客户资料
				window.location="hotellist.php?wxudid=<?php echo $strwxudid;?>";
				return;
			}
			
			if(strSoftID.length>3)
			{
				//1.获取客户档案ID号
				var strurl="cmpid/getcmpid.php?softid=" + strSoftID + "&wxudid=<?php echo $strwxudid;?>&wxfw=<?php echo $strwxfwflag;?>";
				var strret="";
				//用ajax的“同步方式”调用一般处理程序
				$.ajax({
					url: strurl ,
					async: false,//改为同步方式
					type: "POST",
					//data: {doid:1, rmid: "strRoomNo" },
					success: function (RetData) 
					{
						strret = RetData;
					}
				});

				//alert(strret);
				//return;
				if(strret.substr(0,1)=='0')
				{
					alert("客户识别号不正确!");
					return;
				}
				
				//alert(strret);
				
				if(strret.length >0)
				{
					if(strret.length<80)
					{
						//自动记录上次的客户识别号
						var strRet=strret.substr(0,1);
						if(strRet=='1')
						{
							var strCmpUrl=strret.substr(1);
							if(strCmpUrl.length>10)
							{
								window.location=strCmpUrl + "?wxudid=<?php echo $strwxudid;?>";
							}
						}
					}
				}
			}
			else
			{
				alert("请正确输入客户识别号！");
			}
		}
	</script>
	
</section>

</body>

</html>
