From 3130479d397d450edeb14cdbebeccab4e9c391cf Mon Sep 17 00:00:00 2001 From: aixianling Date: Thu, 29 Dec 2022 15:24:40 +0800 Subject: [PATCH] =?UTF-8?q?=E9=98=B2=E6=AD=A2=E5=9B=9E=E8=B0=83=E5=9C=B0?= =?UTF-8?q?=E7=8B=B1,=E5=AF=BC=E8=87=B4code=E6=97=A0=E9=99=90=E5=8F=A0?= =?UTF-8?q?=E5=8A=A0=E4=BA=A7=E7=94=9F=E9=89=B4=E6=9D=83=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/modules.js | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/common/modules.js b/src/common/modules.js index 771ec369..f9ea1266 100644 --- a/src/common/modules.js +++ b/src/common/modules.js @@ -202,15 +202,19 @@ let timer = {} * https://open.weixin.qq.com/connect/oauth2/authorize?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=SCOPE&agentid=AGENTID#wechat_redirect * @param params */ -const oauth2Weixin = params => qs.stringifyUrl({ - url: "https://open.weixin.qq.com/connect/oauth2/authorize", - query: { - response_type: 'code', - redirect_uri: encodeURIComponent(location.href), - ...params - }, - fragmentIdentifier: "wechat_redirect" -}) +const oauth2Weixin = params => { + const redirect = qs.parseUrl(location.href) + delete redirect.query.code + return qs.stringifyUrl({ + url: "https://open.weixin.qq.com/connect/oauth2/authorize", + query: { + response_type: 'code', + redirect_uri: qs.stringifyUrl(redirect), + ...params + }, + fragmentIdentifier: "wechat_redirect" + }) +} export const wxwork = { state: () => ({ agentSignURL: "", @@ -287,12 +291,9 @@ export const wxwork = { dispatch("agentSign", {corpId, suiteId}).then(() => excute(true)).then(() => resolve()) } else reject("URL缺少必要参数(corpId)") }) - } else new Promise((resolve, reject) => { - const {appid} = params - if (!!appid) { - const oauthURL = oauth2Weixin(params) - location.replace(oauthURL) - } else reject("URL缺少必要参数(appid)") + } else new Promise(() => { + const oauthURL = oauth2Weixin(params) + location.replace(oauthURL) }) } return excute()