public function newOrder() { $userInfo = session('userInfo'); $this->assign('userInfo', $userInfo); $cart = session('cart'); if (!$cart['address']) { $cart['address'] = array('name' => '', 'tel' => ''); } $this->assign('cart', $cart); if ($this->is_mobile()) { $weObj = new TPWechat(array('appid' => 'wx043fe26d7171dc76', 'appsecret' => '9075a78a413ea5f12999e0fddcc2a60c')); $auth = $weObj->checkAuth(); $api_ticket = $weObj->getJsTicket(); $url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $js_sign = $weObj->getJsSign($url); $time = time(); $card_id = 'pk0Ius992-phYJGSJLG2dJfBuFvw'; $this->assign('card_id', $card_id); $signature = new Signature(); $signature->add_data($api_ticket); $signature->add_data($card_id); $signature->add_data(strval($time)); $this->assign('card_signature', $signature->get_signature()); $this->assign('js_sign', $js_sign); $this->assign('tm', $time); $this->assign('api_ticket', $api_ticket); $this->theme('mobile')->display(); } else { $this->display(); } }
public function invitationGet() { $openid = I('get.u'); $companyInfo = $this->getCompanyInfo(); $options = array('token' => 'tokenaccesskey', 'appid' => $companyInfo['weixin_AppId'], 'appsecret' => $companyInfo['weixin_AppSecret']); $weixin = new TPWechat($options); if (!$openid) { $oauthToken = $weixin->getOauthAccessToken(); if (!$oauthToken) { $url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING']; //$url = urlencode($url); $redirctUrl = $weixin->getOauthRedirect($url, '', 'snsapi_base'); header("Location: {$redirctUrl}"); } $openid = $oauthToken['openid']; } $this->assign('openid', $openid); $auth = $weixin->checkAuth(); $api_ticket = $weixin->getJsTicket(); $url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $js_sign = $weixin->getJsSign($url); $time = time(); $card_id = 'pk0Ius992-phYJGSJLG2dJfBuFvw'; $this->assign('card_id', $card_id); $signature = new Signature(); $signature->add_data($api_ticket); $signature->add_data($card_id); $signature->add_data(strval($time)); $this->assign('card_signature', $signature->get_signature()); $this->assign('js_sign', $js_sign); $this->assign('tm', $time); $this->assign('api_ticket', $api_ticket); $this->display(); }