public function wx()
 {
     $wx_oauth_conf = C('WEIXIN');
     $wechat = new \Common\Lib\Wechat($wx_oauth_conf);
     //$_COOKIE['wxopenid'] = '2oeHfxwAIkN6fPscPnZRLssOtQsXw';
     if (!$_COOKIE['wxopenid']) {
         $req_path = explode('?', $_SERVER['REQUEST_URI']);
         $referrerUri = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
         $state = base64_encode($referrerUri);
         $redirectUri = 'http://wechat.vtshow.top/admin/data/login';
         $authorizeUrl = $wechat->getOauthRedirect($redirectUri, $state, 'snsapi_base');
         header('Location: ' . $authorizeUrl);
         exit;
     } elseif (isset($_COOKIE['wxopenid']) && $_COOKIE['wxopenid']) {
         $uid = $_COOKIE['wxopenid'];
         session('thirdparty_uid', $uid);
         session('thirdparty_type', 'wechat');
         //session('unionid', $_COOKIE['unionid']);
     }
 }
 public function oauth()
 {
     //$_GET['url'] = "http://m.action.wdwd.com?aaaxx=xxxx&bbbb=xxx";
     $referrerUri = $_GET['url'];
     if (!$referrerUri) {
         echo "参数错误";
         exit;
     }
     //$hosts = array('action.wdwd.com', 'm.action.wdwd.com');
     $hosts = array('action.wdwd.com', 'm.action.wdwd.com', 'action.sandbox.wdwd.com', 'm.action.sandbox.wdwd.com', '192.168.82.42', '192.168.82.74', 'action.dev.wdwd.com', 'm.action.dev.wdwd.com', 'action.test.wdwd.com', 'm.action.test.wdwd.com');
     $url = parse_url($referrerUri);
     if (!in_array($url['host'], $hosts)) {
         echo "非法请求";
         exit;
     }
     $state = base64_encode($referrerUri);
     #$redirectUri = 'http://www.sandbox.wdwd.com/admin/data/login';
     #$redirectUri = 'http://wdwd.com/admin/data/login';
     $redirectUri = 'http://wdwd.com/wechat/data/login';
     $wechat = new \Common\Lib\Wechat(C('WX_OAUTH'));
     $authorizeUrl = $wechat->getOauthRedirect($redirectUri, $state, 'snsapi_base');
     header('Location: ' . $authorizeUrl);
     exit;
 }