<?php
//外部调用第一个页面后,自动调转到该页面,由该页面实际完成调用应用的起始页面
include "wxid/wechat.class.php";
include 'wxid/errCode.php';
require_once("../Wx.Config.php");
$httppath = WxMainConfig::ServerHttpPath;

$strselchid=trim($_REQUEST['chidno']);
//$chsel=trim($_REQUEST['chsel']);
$scope = 'snsapi_base';
$darpid=trim($_REQUEST['dpid']);
$seldoid=trim($_REQUEST['doidt']);

$opt = array(
	'appsecret'=>WxMainConfig::APPSECRET,//填写高级调用功能的密钥
	'appid'=>WxMainConfig::APPID	//填写高级调用功能的appid
);

$we = new Wechat($opt);
$auth = $we->checkAuth();
$arr = $we->getOauthAccessToken();

if($seldoid=='1')
{
	$bqurl=$httppath.'wxpos/vipmain.php?wxudid='.$arr["openid"].'&wxtoken='.$arr["access_token"].'&chid='.$strselchid.'&dpid='.$darpid;
}
else
{
	$bqurl=$httppath.'wxpos/loadpage.php?wxudid='.$arr["openid"].'&chid='.$strselchid.'&dpid='.$darpid;
}

header('Location: ' . $bqurl);

?>