Commit 2e52e763 by 李伟康

commit

1 parent f5fcf8db
...@@ -70,11 +70,12 @@ const actions = { ...@@ -70,11 +70,12 @@ const actions = {
let [redirectUrl] = window.location.href.split('?') let [redirectUrl] = window.location.href.split('?')
const code = getParams('code') const code = getParams('code')
if (code) { if (code) {
const { corpId } = util.getLocalStorage('dj_scrm_corpId') const { corpId, agentId } = util.getLocalStorage('dj_scrm_corpId')
ssoApi ssoApi
.login({ .login({
code, code,
corpId corpId,
getUserInfoFlag: agentId ? true : false
}) })
.then(({ code, data }) => { .then(({ code, data }) => {
let url = `${redirectUrl.split('#')[0]}#/` let url = `${redirectUrl.split('#')[0]}#/`
...@@ -121,13 +122,13 @@ const actions = { ...@@ -121,13 +122,13 @@ const actions = {
} else { } else {
util.showLoading() util.showLoading()
let appid = getParams('corpId') //从链接获取 let appid = getParams('corpId') //从链接获取
let agentid = getParams('agentid') //从链接获取 let agentid = getParams('agentId') //从链接获取
let dj_scrm = util.getLocalStorage('dj_scrm_corpId') let dj_scrm = util.getLocalStorage('dj_scrm_corpId')
const IS_PROD = ['production', 'prod'].includes(process.env.NODE_ENV) const IS_PROD = ['production', 'prod'].includes(process.env.NODE_ENV)
if (!appid) { if (!appid) {
if (dj_scrm) { if (dj_scrm) {
appid = dj_scrm.corpId appid = dj_scrm.corpId
agentid = dj_scrm.agentid agentid = dj_scrm.agentId
} else { } else {
if (IS_PROD) { if (IS_PROD) {
Notify({ Notify({
...@@ -137,16 +138,21 @@ const actions = { ...@@ -137,16 +138,21 @@ const actions = {
return return
} else { } else {
appid = 'ww7ee69c648ae1b7e6' appid = 'ww7ee69c648ae1b7e6'
agentid = 1000003 agentid = 1000035
// appid = 'wwc1fefc2a3f70bd0b'
// agentid = 1000002
} }
} }
} }
util.setLocalStorage('dj_scrm_corpId', { corpId: appid, agentid }) let dj_scrm_storage = { corpId: appid }
let wxUrl = 'https://open.weixin.qq.com/connect/oauth2/authorize' let wxUrl = 'https://open.weixin.qq.com/connect/oauth2/authorize'
wxUrl = `${wxUrl}?appid=${appid}&redirect_uri=${encodeURIComponent(redirectUrl)}&response_type=code&scope=snsapi_privateinfo&state=STATE` wxUrl = `${wxUrl}?appid=${appid}&redirect_uri=${encodeURIComponent(redirectUrl)}&response_type=code&scope=snsapi_privateinfo`
if (agentid) wxUrl = `${wxUrl}&agentid=${agentid}` if (agentid) {
console.log(`${wxUrl}#wechat_redirect`) wxUrl = `${wxUrl}&agentid=${agentid}`
window.location.href = `${wxUrl}#wechat_redirect` dj_scrm_storage.agentId = agentid
}
util.setLocalStorage('dj_scrm_corpId', dj_scrm_storage)
window.location.href = `${wxUrl}&state=STATE#wechat_redirect`
} }
}, },
navigation ({ dispatch }, to) { navigation ({ dispatch }, to) {
......
...@@ -83,7 +83,7 @@ export default { ...@@ -83,7 +83,7 @@ export default {
let redirect_uri = this.getLocalStorage('dj_scrm_redirect_uri') let redirect_uri = this.getLocalStorage('dj_scrm_redirect_uri')
this.setLocalStorage('dj_scrm_userInfo', data) this.setLocalStorage('dj_scrm_userInfo', data)
this.setSessionId(data.sessionId) this.setSessionId(data.sessionId)
let { corpId } = this.getLocalStorage('dj_scrm_corpId') let { corpId, agentId } = this.getLocalStorage('dj_scrm_corpId')
store.dispatch('registerHttp', data.sessionId) store.dispatch('registerHttp', data.sessionId)
this.removeLocalStorage('dj_scrm_redirect_uri') this.removeLocalStorage('dj_scrm_redirect_uri')
this.showLoading('登录成功', () => { this.showLoading('登录成功', () => {
...@@ -91,6 +91,7 @@ export default { ...@@ -91,6 +91,7 @@ export default {
if (redirect_uri) { if (redirect_uri) {
let [URL, query] = decodeURIComponent(redirect_uri).split('?') let [URL, query] = decodeURIComponent(redirect_uri).split('?')
URL = `${URL}?sessionId=${data.sessionId}&corpId=${corpId}` URL = `${URL}?sessionId=${data.sessionId}&corpId=${corpId}`
if(agentId) URL = `${URL}&agentId=${agentId}`
if (query) URL = `${URL}&${query}` if (query) URL = `${URL}&${query}`
window.location.href = URL window.location.href = URL
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!