Commit 5ad258d9 by liwk

commit

1 parent ba093a59
...@@ -55,76 +55,76 @@ const actions = { ...@@ -55,76 +55,76 @@ const actions = {
commit('REMOVE_KEEP', names) commit('REMOVE_KEEP', names)
}, },
login({ dispatch }) { login({ dispatch }) {
let [redirectUrl] = window.location.href.split('?') // 以下是 本地调试多账号
const code = getParams('code') if (process.env.NODE_ENV == 'development') {
if (code) { let [redirectUrl] = window.location.href.split('?')
const { corpId } = util.getLocalStorage('dj_scrm_corpId') const code = getParams('code')
ssoApi.login({ if (code) {
code, const { corpId } = util.getLocalStorage('dj_scrm_corpId')
corpId ssoApi.login({
}).then(({ code, data, message }) => { code,
const { baseURL } = window.$fetchConfig.request corpId
// const [baseURL] = redirectUrl.split('/dj-scrm-wx-work-main/') }).then(({ code, data, message }) => {
let url = `${baseURL}/dj-scrm-wx-work-main/#/` state.showWindow = true
let route = state.lastPath == 'coupon' ? '' : state.lastPath || '' if (code == '0') {
route = route.replace('.', '/') if (data.loginList.length) {
state.showWindow = true if (data.loginList.length > 1) {
if (code == '0') { util.setLocalStorage('dj_scrm_loginToken', data.loginToken)
if (data.loginList.length) { util.setLocalStorage('dj_scrm_accountList', data.loginList)
if (data.loginList.length > 1) { let userInfo = data.loginList[1]
util.setLocalStorage('dj_scrm_loginToken', data.loginToken) let { merchantId, accountName } = userInfo
util.setLocalStorage('dj_scrm_accountList', data.loginList) let loginAccount = accountName
let redirect_uri = encodeURI(`${redirectUrl}`) ssoApi.selectAccount({
// 先注释 loginAccount,
console.log('回调', `${url}common/accountList?redirect_uri=${redirect_uri}&router=${route}`) merchantId,
window.location.href = `${url}common/accountList?redirect_uri=${redirect_uri}&router=${route}` loginToken: data.loginToken,
//以下是 本地调试多账号 loginSource: 'WW',
// let userInfo = data.loginList[1] loginType: 3
// let { merchantId, accountName } = userInfo }).then(res => {
// let loginAccount = accountName util.removeLocalStorage('dj_scrm_loginToken')
// ssoApi.selectAccount({ util.removeLocalStorage('dj_scrm_accountList')
// loginAccount, util.setLocalStorage('dj_scrm_userInfo', res.data)
// merchantId, util.setSessionId(res.data.sessionId)
// loginToken: data.loginToken, dispatch('registerHttp', res.data.sessionId)
// loginSource: 'WW', window.location.replace(`${redirectUrl}${route}`)
// loginType: 3 })
// }).then(res => { } else {
// util.removeLocalStorage('dj_scrm_loginToken') let [userInfo] = data.loginList
// util.removeLocalStorage('dj_scrm_accountList') util.setLocalStorage('dj_scrm_userInfo', userInfo)
// util.setLocalStorage('dj_scrm_userInfo', res.data) util.setSessionId(userInfo.sessionId)
// util.setSessionId(res.data.sessionId) dispatch('registerHttp', userInfo.sessionId)
// dispatch('registerHttp', res.data.sessionId) // 只有一个账号 history.back()
// window.location.replace(`${url}${route}`) console.log(`${redirectUrl}${route}`)
// }) window.location.replace(`${redirectUrl}${route}`)
}
} else { } else {
let [userInfo] = data.loginList /**没有账号 */
util.setLocalStorage('dj_scrm_userInfo', userInfo) window.location.href = `${url}common/nothing`
util.setSessionId(userInfo.sessionId)
dispatch('registerHttp', userInfo.sessionId)
// 只有一个账号 history.back()
console.log(`${redirectUrl}${route}`)
window.location.replace(`${redirectUrl}${route}`)
} }
} else { } else {
/**没有账号 */ /**账号过期 (暂时没有字段判断是否过期) */
window.location.href = `${url}common/nothing` Notify(message)
window.location.href = `${url}common/overdue`
} }
} else { })
/**账号过期 (暂时没有字段判断是否过期) */ } else {
Notify(message) util.showLoading()
window.location.href = `${url}common/overdue` let appid = getParams('corpId') //从链接获取
} let dj_scrm = util.getLocalStorage('dj_scrm_corpId')
}) if (!appid) appid = dj_scrm && dj_scrm.corpId || 'ww7ee69c648ae1b7e6'
//
util.setLocalStorage('dj_scrm_corpId', { corpId: appid })
// 'ww657a2d4ae89a4424'
const wxUrl = 'https://open.weixin.qq.com/connect/oauth2/authorize'
window.location.href = `${wxUrl}?appid=${appid}&redirect_uri=${encodeURIComponent(redirectUrl)}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect`
}
} else { } else {
util.showLoading() const { baseURL } = window.$fetchConfig.request
let appid = getParams('corpId') //从链接获取 // const [baseURL] = redirectUrl.split('/dj-scrm-wx-work-main/')
let dj_scrm = util.getLocalStorage('dj_scrm_corpId') let url = `${baseURL}/dj-scrm-wx-work-main/#/`
if (!appid) appid = dj_scrm && dj_scrm.corpId || 'ww7ee69c648ae1b7e6' let route = state.lastPath == 'coupon' ? '' : state.lastPath || ''
// route = route.replace('.', '/')
util.setLocalStorage('dj_scrm_corpId', { corpId: appid }) window.location.href = `${url}?redirect_uri=${redirect_uri}&router=${route}`
// 'ww657a2d4ae89a4424'
const wxUrl = 'https://open.weixin.qq.com/connect/oauth2/authorize'
window.location.href = `${wxUrl}?appid=${appid}&redirect_uri=${encodeURIComponent(redirectUrl)}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect`
} }
}, },
navigation({ dispatch }) { navigation({ dispatch }) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!