Commit da180228 by 李伟康

企微敏感信息获取授权同步

1 parent f34b54d5
......@@ -16,15 +16,15 @@ const state = {
lastPath: ''
}
const mutations = {
SET_PAGE_META(state, meta) {
SET_PAGE_META (state, meta) {
state.pageMeta = meta
},
PUSH_KEEP(state, name) {
PUSH_KEEP (state, name) {
if (!state.keepAlives.includes(name)) {
state.keepAlives.push(name)
}
},
REMOVE_KEEP(state, names) {
REMOVE_KEEP (state, names) {
state.keepAlives = state.keepAlives.reduce((arr, name) => {
if (!names.includes(name)) {
return arr.push(name)
......@@ -32,28 +32,28 @@ const mutations = {
return arr
}, [])
},
SET_LAST_PATH(state, path) {
SET_LAST_PATH (state, path) {
state.lastPath = path
}
}
const actions = {
setPageMeta({ commit }, meta) {
setPageMeta ({ commit }, meta) {
document.title = meta.title
commit('SET_PAGE_META', meta)
},
setLoginToken({ commit }, val) {
setLoginToken ({ commit }, val) {
commit('SET_LOGIN_TOKEN', val)
},
setAccountList({ commit }, list) {
setAccountList ({ commit }, list) {
commit('SET_ACCOUNT_LIST', list)
},
pushKeep({ commit }, name) {
pushKeep ({ commit }, name) {
commit('PUSH_KEEP', name)
},
removeKeep({ commit }, names) {
removeKeep ({ commit }, names) {
commit('REMOVE_KEEP', names)
},
login({ dispatch }) {
login ({ dispatch }) {
let [redirectUrl] = window.location.href.split('?')
// 以下是 本地调试
if (process.env.NODE_ENV == 'development') {
......@@ -121,14 +121,14 @@ const actions = {
window.location.href = `${wxUrl}?appid=${appid}&redirect_uri=${encodeURIComponent(redirectUrl)}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect`
}
} else {
const storage_corpId = util.getLocalStorage('dj_scrm_corpId')
const { corpId, agentId } = util.getLocalStorage('dj_scrm_corpId')
const { baseURL } = window.$fetchConfig.request
let url = `${baseURL}/dj-scrm-wx-work-main/#/`
window.location.href = `${url}?redirect_uri=${redirectUrl}&corpId=${storage_corpId.corpId}`
window.location.href = `${url}?redirect_uri=${encodeURIComponent(redirectUrl)}&corpId=${corpId}&agentId=${agentId}`
}
},
navigation({ dispatch }) {
let { sessionId, corpId, taskId } = getParams()
navigation ({ dispatch }) {
let { sessionId, corpId, taskId, agentId } = getParams()
const storage_corpId = util.getLocalStorage('dj_scrm_corpId')
if (!corpId) corpId = storage_corpId && storage_corpId.corpId
if (corpId && storage_corpId) {
......@@ -137,7 +137,9 @@ const actions = {
util.clearSessionId()
}
}
util.setLocalStorage('dj_scrm_corpId', { corpId })
let dj_scrm_storage = { corpId }
if (agentId) dj_scrm_storage.agentId = agentId
util.setLocalStorage('dj_scrm_corpId', dj_scrm_storage)
if (taskId) {
util.setLocalStorage('dj_scrm_taskId', { taskId })
}
......@@ -154,7 +156,7 @@ const actions = {
}
state.showWindow = true
},
registerHttp({}, sessionId = '') {
registerHttp ({ }, sessionId = '') {
window.$HTTP = new Http({ ...window.$fetchConfig, alert: Notify, headers: { token: sessionId } })
}
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!