diff --git a/src/common/modules.js b/src/common/modules.js index 42db5edd..158672e2 100644 --- a/src/common/modules.js +++ b/src/common/modules.js @@ -55,7 +55,7 @@ export const config = { } }, getCode({state, dispatch}, tryAgentSign = false) { - let {corpid: corpId, suiteId} = state, url = location.href, REDIRECT_URI = encodeURIComponent(url), scope = "snsapi_privateinfo" + let {corpid: corpId, suiteId, agentid: agentId} = state, url = location.href, REDIRECT_URI = encodeURIComponent(url), scope = "snsapi_privateinfo" if (/\/AppForm\//.test(location.search)) { scope = "snsapi_userinfo" } else if (suiteId) { @@ -64,10 +64,11 @@ export const config = { } return new Promise((resolve, reject) => { if (corpId && scope) { - let oauthURL = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=SCOPE#wechat_redirect' + let oauthURL = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=SCOPE&agentid=AGENTID#wechat_redirect' .replace(/APPID/g, corpId) .replace(/REDIRECT_URI/g, REDIRECT_URI) .replace(/SCOPE/g, scope) + .replace(/AGENTID/g, agentId) location.replace(oauthURL) } else if (!tryAgentSign) { dispatch("agentSign", {corpId, suiteId}).then(() => dispatch("getCode", true)).then(() => resolve())