public function addOrderIndex() { //微信授权(如果是微信浏览器) $user_agent = $_SERVER['HTTP_USER_AGENT']; if (strpos($user_agent, 'MicroMessenger') != false) { $url = '/user/addOrderIndex'; $_SESSION['wx_url'] = $url; $Wechat = new WechatAction(); $Wechat->wechat(); if (!isset($_SESSION['openid'])) { exit; } //p($_SESSION); } if ($_SESSION['user']) { //获取地址 $address = $this->getAddress(); //如果还为设置地址,先添加地址 if (!$address) { $this->addAddressIndex(); exit; } //获取餐馆列表 $restaurant = $this->getRestaurant(); //获取配置项 $condition['type'] = 'service'; $option = M('options')->where($condition)->select(); $this->address = $address; $this->restaurant = $restaurant; $this->option = $option; $this->display(order); } else { $this->display('login'); } //p($address); //p($option); }
public function wechat() { if (!isset($_SESSION['openid'])) { //获取access_token过程中的跳转uri,通过跳转将code传入jsapi支付页面 $url = 'http://goalfriend.duapp.com/mobile/users/wechat'; $Wechat = new WechatAction(); //=========步骤1:网页授权获取用户openid============ //通过code获得openid if (!isset($_GET['code'])) { //触发微信返回code码 $url = $Wechat->createOauthUrlForCode($url); Header("Location: {$url}"); } else { //获取code码,以获取openid $code = $_GET['code']; $Wechat->setCode($code); $openid = $Wechat->getOpenId(); //赋值openid $_SESSION['openid'] = $openid; //通过openid 登入 $this->getUserInfoByOpenid($openid); //回调原来的页面 //Header("Location: selectcombo"); $this->redirect('Mobile/Users/index'); } exit; } }
public function wechat() { if (!isset($_SESSION['openid'])) { //获取access_token过程中的跳转uri,通过跳转将code传入jsapi支付页面 $url = 'http://wellcn.duapp.com/index.php/userwx/wechat'; $Wechat = new WechatAction(); //=========步骤1:网页授权获取用户openid============ //通过code获得openid if (!isset($_GET['code'])) { //触发微信返回code码 $url = $Wechat->createOauthUrlForCode($url); Header("Location: {$url}"); } else { //获取code码,以获取openid $code = $_GET['code']; $Wechat->setCode($code); $openid = $Wechat->getOpenId(); //赋值openid $_SESSION['openid'] = $openid; //通过openid 登入 $this->LoginByOpenid($openid); //回调原来的页面 //Header("Location: selectcombo"); $redirect_url = web_root . "/" . $redirect_url; //$url =web_root.'/index/index'; $this->redirect($redirect_url); } } }