diff --git a/lib/client.js b/lib/client.js index 78ab1a5..bf6c5de 100644 --- a/lib/client.js +++ b/lib/client.js @@ -12,6 +12,9 @@ let defaultScriptUrl = '//res.wx.qq.com/open/js/jweixin-1.4.0.js'; //default apis with share-on-moment and share-on-chat const defaultApiList = ['onMenuShareTimeline', 'onMenuShareAppMessage']; +// default opentags wx-open-subscribe and wx-open-audio +const defaultopenTagList = ['wx-open-subscribe', 'wx-open-audio']; + class WechatJSSDK { /** * Initialize the WechatJSSDK instance @@ -36,6 +39,7 @@ class WechatJSSDK { this.sdkUrl = this.config.customUrl; } let apiList = this.config.jsApiList; + let tagList = this.config.openTagList; //add more apis if passed in if (!apiList || apiList.length <= 0) { this.config.jsApiList = defaultApiList; @@ -49,6 +53,19 @@ class WechatJSSDK { } } } + //add more tags if passed in + if (!tagList || tagList.length <= 0) { + this.config.openTagList = defaultopenTagList; + } else { + let i = 0; + const length = defaultopenTagList.length; + for (; i < length; i++) { + const defaultItem = defaultopenTagList[i]; + if (tagList.indexOf(defaultItem) < 0) { + tagList.push(defaultItem); + } + } + } this.debug = !!this.config.debug; return this; } @@ -79,6 +96,10 @@ class WechatJSSDK { nonceStr: config.nonceStr || selfConfig.nonceStr, signature: config.signature || selfConfig.signature, jsApiList: selfConfig.jsApiList.slice(0, selfConfig.jsApiList.length), + openTagList: selfConfig.openTagList.slice( + 0, + selfConfig.openTagList.length + ), }; const debug = this.debug; return new Promise((resolve, reject) => { diff --git a/package.json b/package.json index b6d030e..9f9e03c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wechat-jssdk", - "version": "5.0.6", + "version": "5.0.7", "description": "Next-Generation WeChat JS-SDK integration with NodeJS", "main": "./lib/index.js", "source": "./lib/client.js",