From 35c7b12e02877f626bfad17f427598cb8292be67 Mon Sep 17 00:00:00 2001
From: humeng93 <354678192@qq.com>
Date: Mon, 25 Oct 2021 22:08:29 +0800
Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E6=8C=87=E5=AE=9Ajs?=
 =?UTF-8?q?ApiList?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 WeChat/Script.php | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/WeChat/Script.php b/WeChat/Script.php
index c04be36..1a748b9 100644
--- a/WeChat/Script.php
+++ b/WeChat/Script.php
@@ -70,15 +70,23 @@ class Script extends BasicWeChat
      * @param string $url 网页的URL
      * @param string $appid 用于多个appid时使用(可空)
      * @param string $ticket 强制指定ticket
+     * @param array $jsApiList 需初始化的 jsApiList
      * @return array
      * @throws Exceptions\LocalCacheException
      * @throws InvalidResponseException
      */
-    public function getJsSign($url, $appid = null, $ticket = null)
+    public function getJsSign($url, $appid = null, $ticket = null, $jsApiList = null)
     {
         list($url,) = explode('#', $url);
         is_null($ticket) && $ticket = $this->getTicket('jsapi');
         is_null($appid) && $appid = $this->config->get('appid');
+        is_null($jsApiList) && $jsApiList = [
+            'updateAppMessageShareData', 'updateTimelineShareData', 'onMenuShareTimeline', 'onMenuShareAppMessage', 'onMenuShareQQ', 'onMenuShareWeibo', 'onMenuShareQZone',
+            'startRecord', 'stopRecord', 'onVoiceRecordEnd', 'playVoice', 'pauseVoice', 'stopVoice', 'onVoicePlayEnd', 'uploadVoice', 'downloadVoice',
+            'chooseImage', 'previewImage', 'uploadImage', 'downloadImage', 'translateVoice', 'getNetworkType', 'openLocation', 'getLocation',
+            'hideOptionMenu', 'showOptionMenu', 'hideMenuItems', 'showMenuItems', 'hideAllNonBaseMenuItem', 'showAllNonBaseMenuItem',
+            'closeWindow', 'scanQRCode', 'chooseWXPay', 'openProductSpecificView', 'addCard', 'chooseCard', 'openCard',
+        ];
         $data = ["url" => $url, "timestamp" => '' . time(), "jsapi_ticket" => $ticket, "noncestr" => Tools::createNoncestr(16)];
         return [
             'debug'     => false,
@@ -86,13 +94,7 @@ class Script extends BasicWeChat
             "nonceStr"  => $data['noncestr'],
             "timestamp" => $data['timestamp'],
             "signature" => $this->getSignature($data, 'sha1'),
-            'jsApiList' => [
-                'updateAppMessageShareData', 'updateTimelineShareData', 'onMenuShareTimeline', 'onMenuShareAppMessage', 'onMenuShareQQ', 'onMenuShareWeibo', 'onMenuShareQZone',
-                'startRecord', 'stopRecord', 'onVoiceRecordEnd', 'playVoice', 'pauseVoice', 'stopVoice', 'onVoicePlayEnd', 'uploadVoice', 'downloadVoice',
-                'chooseImage', 'previewImage', 'uploadImage', 'downloadImage', 'translateVoice', 'getNetworkType', 'openLocation', 'getLocation',
-                'hideOptionMenu', 'showOptionMenu', 'hideMenuItems', 'showMenuItems', 'hideAllNonBaseMenuItem', 'showAllNonBaseMenuItem',
-                'closeWindow', 'scanQRCode', 'chooseWXPay', 'openProductSpecificView', 'addCard', 'chooseCard', 'openCard',
-            ],
+            'jsApiList' => $jsApiList,
         ];
     }