From 3beeed5a413a45a94e4a64c5f29a78578d774fec Mon Sep 17 00:00:00 2001 From: Anyon Date: Tue, 3 Apr 2018 13:13:23 +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=E9=A1=B5=E9=9D=A2=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/wechat/controller/api/Script.php | 13 +++-------- application/wechat/view/api/script/index.js | 24 ++++++++------------ 2 files changed, 13 insertions(+), 24 deletions(-) diff --git a/application/wechat/controller/api/Script.php b/application/wechat/controller/api/Script.php index 298c2e3ad..028241284 100644 --- a/application/wechat/controller/api/Script.php +++ b/application/wechat/controller/api/Script.php @@ -24,13 +24,6 @@ use think\facade\Response; */ class Script { - - /** - * 当前请求对象 - * @var \think\Request - */ - protected $request; - /** * jsSign签名 * @throws \Exception @@ -41,12 +34,12 @@ class Script $wechat = WechatService::webOauth($result->get('mode', 1)); $url = $result->server('HTTP_REFERER', $result->url(true), null); $assign = [ - 'jssdk' => json_encode(WechatService::webJsSDK($url), 256), + 'jssdk' => WechatService::webJsSDK($url), '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', - 'cache-control' => 'no-cache', 'pragma' => 'no-cache', 'expires' => '0', + 'Content-Type' => 'application/x-javascript;charset=utf-8', + 'Cache-Control' => 'no-cache', 'Pragma' => 'no-cache', 'Expires' => '0', ])->assign($assign); } } \ No newline at end of file diff --git a/application/wechat/view/api/script/index.js b/application/wechat/view/api/script/index.js index 317f87ad5..d9c003067 100644 --- a/application/wechat/view/api/script/index.js +++ b/application/wechat/view/api/script/index.js @@ -1,14 +1,10 @@ -!(function () { - if (typeof wx === 'object') { - wx.openid = '{$fansinfo.openid|default=""}'; - wx.unionid = '{$fansinfo.unionid|default=""}'; - wx.getUserInfo = function () { - return eval('{$fansinfo|default=[]|json_encode=###,256|raw}'); - }; - wx.config(eval('({$jssdk|default=[]|json_encode=###,256|raw})')); - wx.ready(function () { - wx.hideOptionMenu(); - wx.hideAllNonBaseMenuItem(); - }); - } -})(); \ No newline at end of file +if (typeof wx === 'object') { + wx.openid = '{$fansinfo.openid|default=""}'; + wx.unionid = '{$fansinfo.unionid|default=""}'; + wx.fansinfo = eval('{$fansinfo|default=[]|json_encode=###,256|raw}'); + wx.config(eval('{$jssdk|default=[]|json_encode=###,256|raw}')); + wx.ready(function () { + wx.hideOptionMenu(); + wx.hideAllNonBaseMenuItem(); + }); +}