From 0d1538ad4d1c8292eab2484ba4d9c8c746011b19 Mon Sep 17 00:00:00 2001 From: Anyon Date: Tue, 3 Apr 2018 13:04:17 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=9B=B4=E6=96=B0]=E4=BF=AE=E6=94=B9=E5=85=AC?= =?UTF-8?q?=E4=BC=97=E5=8F=B7=E7=BD=91=E9=A1=B5=E7=AD=BE=E5=90=8D=E6=94=AF?= =?UTF-8?q?=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/wechat/controller/api/Script.php | 23 +++++--------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/application/wechat/controller/api/Script.php b/application/wechat/controller/api/Script.php index a8e03d5e6..298c2e3ad 100644 --- a/application/wechat/controller/api/Script.php +++ b/application/wechat/controller/api/Script.php @@ -14,12 +14,11 @@ namespace app\wechat\controller\api; -use service\ToolsService; use service\WechatService; use think\facade\Response; /** - * 微信公众号页面脚本 + * 公众号页面支持 * Class Script * @package app\wechat\controller\api */ @@ -32,28 +31,18 @@ class Script */ protected $request; - - /** - * Wechat constructor. - */ - public function __construct() - { - ToolsService::corsOptionsHandler(); - $this->request = app('request'); - } - /** * jsSign签名 * @throws \Exception */ public function index() { - $wechat = WechatService::webOauth($this->request->get('mode', 1)); - $url = $this->request->server('HTTP_REFERER', $this->request->url(true), null); + $result = app('request'); + $wechat = WechatService::webOauth($result->get('mode', 1)); + $url = $result->server('HTTP_REFERER', $result->url(true), null); $assign = [ - 'openid' => $wechat['openid'], - 'fansinfo' => $wechat['fansinfo'], - 'jssdk' => WechatService::webJsSDK($url), + 'jssdk' => json_encode(WechatService::webJsSDK($url), 256), + 'openid' => $wechat['openid'], 'fansinfo' => $wechat['fansinfo'], ]; return Response::create(env('APP_PATH') . 'wechat/view/api/script/index.js', 'view', 200, [ 'content-type' => 'application/x-javascript;charset=utf-8',