<?php
	session_start();	
	
	ini_set('session.gc_maxlifetime', 99999999); //设置时间 永不过期

	$strwxid=trim($_SESSION["main_wxudid"]);
		
	require_once("db/db.php");	
	require_once("common/common.php");
	
	if(strlen($strwxid)>10)
	{
		//根据微信号登陆
		$intNextFlag=0;
		
		$_SESSION["main_vipno"]="";
		$_SESSION["main_vipname"]="";
		$_SESSION["main_vipsex"]="";
		$_SESSION["main_vippswd"]="";
		$_SESSION["main_viptype"]="";
		$_SESSION["main_vipstate"]="";
		$_SESSION["main_viptelno"]="";
		$_SESSION["main_vipborth"]="1900-01-01";
		$_SESSION["main_vipidtype"]="";
		$_SESSION["main_vipidno"]="";
		$_SESSION["main_vipVIPNo"]="";
		$_SESSION["main_vipVIPState"]="";
		$_SESSION["main_viplogined"]="0";	//登录成功
		$_SESSION["main_defvipnoflag"]="0";
		$_SESSION["main_vipwxudid"]="";	//微信号
		
		$sql = sprintf("SELECT a.VIP_No,a.Sub_No,a.Sub_Name,a.Sub_Sex,a.Sub_Pswd,a.Sub_State,b.VIP_Type,b.VIP_State,a.Sub_TelNo,convert(varchar(10),Sub_Borth,120) as VIPBorth,
					a.Sub_IDType,a.Sub_IDNo,a.wx_no FROM VIP_Item a,VIP_Main b WHERE a.VIP_No=b.VIP_No AND a.wx_no='%s'",$strwxid);
	
		$result = querySql($sql);
		if($row = fetch_array($result))
		{
			//如果有会员号
			$strsubno=trim($row['Sub_No']);
			//判断密码是否一样
			if(strlen($row['Sub_No'])>0)
			{
				//如果密码正确 VIP_No    VIP_State
				//=============================================================//
				$_SESSION["main_vipno"]=$row['Sub_No'];
				$_SESSION["main_vipname"]=$row['Sub_Name'];
				$_SESSION["main_vipsex"]=$row['Sub_Sex'];
				$_SESSION["main_vippswd"]=$row['Sub_Pswd'];
				$_SESSION["main_viptype"]=$row['VIP_Type'];
				$_SESSION["main_vipstate"]=$row['Sub_State'];
				$_SESSION["main_viptelno"]=$row['Sub_TelNo'];
				$_SESSION["main_vipborth"]=$row['VIPBorth'];
				$_SESSION["main_vipidtype"]=$row['Sub_IDType'];
				$_SESSION["main_vipidno"]=$row['Sub_IDNo'];
				$_SESSION["main_vipVIPNo"]=$row['VIP_No'];
				$_SESSION["main_vipVIPState"]=$row['VIP_State'];
				$_SESSION["main_viplogined"]="1";	//登录成功
				$_SESSION["main_defvipnoflag"]="1";
				$_SESSION["main_vipwxudid"]=trim($row['wx_no']);
			}
		}
		//释放数据库
		freeResult($result);	
	}
	closeDb();
?>
