Commit 09d50f8b by 李伟康

commit

1 parent fe39c4eb
...@@ -61,9 +61,11 @@ export default { ...@@ -61,9 +61,11 @@ export default {
let options = this.tools.deepClone(staticOptions) let options = this.tools.deepClone(staticOptions)
if (apiName == 'couponApi' || apiName == 'boutiquecouponApi' || apiName == 'equityApi') { if (apiName == 'couponApi' || apiName == 'boutiquecouponApi' || apiName == 'equityApi') {
options[1].className = 'disabled' options[1].className = 'disabled'
this.options = options
this.showShare = true this.showShare = true
return return
} }
console.log(options)
this.options = options this.options = options
if (apiName == 'activityApi' || apiName == 'liveApi') { if (apiName == 'activityApi' || apiName == 'liveApi') {
this.showLoading() this.showLoading()
......
...@@ -35,7 +35,6 @@ const mutations = { ...@@ -35,7 +35,6 @@ const mutations = {
SET_LAST_PATH(state, path) { SET_LAST_PATH(state, path) {
state.lastPath = path state.lastPath = path
} }
} }
const actions = { const actions = {
setPageMeta({ commit }, meta) { setPageMeta({ commit }, meta) {
...@@ -56,68 +55,68 @@ const actions = { ...@@ -56,68 +55,68 @@ const actions = {
}, },
login({ dispatch }) { login({ dispatch }) {
let [redirectUrl] = window.location.href.split('?') let [redirectUrl] = window.location.href.split('?')
// 以下是 本地调试 // 以下是 本地调试
if (process.env.NODE_ENV == 'development') { if (process.env.NODE_ENV == 'development') {
const code = getParams('code') const code = getParams('code')
if (code) { if (code) {
const { corpId } = util.getLocalStorage('dj_scrm_corpId') const { corpId } = util.getLocalStorage('dj_scrm_corpId')
ssoApi.login({ ssoApi
code, .login({
corpId code,
}).then(({ code, data, message }) => { corpId
let route = state.lastPath == 'coupon' ? '' : state.lastPath || '' })
route = route.replace('.', '/') .then(({ code, data, message }) => {
state.showWindow = true let route = state.lastPath == 'coupon' ? '' : state.lastPath || ''
if (code == '0') { route = route.replace('.', '/')
if (data.loginList.length) { if (code == '0') {
if (data.loginList.length > 1) { if (data.loginList.length) {
util.setLocalStorage('dj_scrm_loginToken', data.loginToken) if (data.loginList.length > 1) {
util.setLocalStorage('dj_scrm_accountList', data.loginList) let userInfo = data.loginList[2]
let userInfo = data.loginList[2] let { merchantId, accountName } = userInfo
let { merchantId, accountName } = userInfo let loginAccount = accountName
let loginAccount = accountName ssoApi
ssoApi.selectAccount({ .selectAccount({
loginAccount, loginAccount,
merchantId, merchantId,
loginToken: data.loginToken, loginToken: data.loginToken,
loginSource: 'WW', loginSource: 'WW',
loginType: 3 loginType: 3
}).then(res => { })
util.removeLocalStorage('dj_scrm_loginToken') .then(res => {
util.removeLocalStorage('dj_scrm_accountList') util.setLocalStorage('dj_scrm_userInfo', res.data)
util.setLocalStorage('dj_scrm_userInfo', res.data) util.setSessionId(res.data.sessionId)
util.setSessionId(res.data.sessionId) dispatch('registerHttp', res.data.sessionId)
dispatch('registerHttp', res.data.sessionId) state.showWindow = true
window.location.replace(`${redirectUrl}#/${route}`)
})
} else {
let [userInfo] = data.loginList
util.setLocalStorage('dj_scrm_userInfo', userInfo)
util.setSessionId(userInfo.sessionId)
dispatch('registerHttp', userInfo.sessionId)
// 只有一个账号 history.back()
console.log(`${redirectUrl}${route}`)
state.showWindow = true
window.location.replace(`${redirectUrl}#/${route}`) window.location.replace(`${redirectUrl}#/${route}`)
}) }
} else { } else {
let [userInfo] = data.loginList /**没有账号 */
util.setLocalStorage('dj_scrm_userInfo', userInfo) Notify('没有账号')
util.setSessionId(userInfo.sessionId) // window.location.href = `${url}common/nothing`
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)
}
} else {
/**账号过期 (暂时没有字段判断是否过期) */
Notify(message)
// window.location.href = `${url}common/overdue` // window.location.href = `${url}common/overdue`
} }
}) })
} else { } else {
util.showLoading() util.showLoading()
let appid = getParams('corpId') //从链接获取 let appid = getParams('corpId') //从链接获取
let dj_scrm = util.getLocalStorage('dj_scrm_corpId') let dj_scrm = util.getLocalStorage('dj_scrm_corpId')
if (!appid) appid = dj_scrm && dj_scrm.corpId || 'ww7ee69c648ae1b7e6' if (!appid) appid = (dj_scrm && dj_scrm.corpId) || 'ww7ee69c648ae1b7e6'
//
util.setLocalStorage('dj_scrm_corpId', { corpId: appid }) util.setLocalStorage('dj_scrm_corpId', { corpId: appid })
// 'ww657a2d4ae89a4424' // 'ww657a2d4ae89a4424'
const wxUrl = 'https://open.weixin.qq.com/connect/oauth2/authorize' 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` window.location.href = `${wxUrl}?appid=${appid}&redirect_uri=${encodeURIComponent(redirectUrl)}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect`
} }
...@@ -132,7 +131,7 @@ const actions = { ...@@ -132,7 +131,7 @@ const actions = {
let { sessionId, corpId } = getParams() let { sessionId, corpId } = getParams()
const storage_sessionId = util.getSessionId() const storage_sessionId = util.getSessionId()
const storage_corpId = util.getLocalStorage('dj_scrm_corpId') const storage_corpId = util.getLocalStorage('dj_scrm_corpId')
if (!corpId) corpId = storage_corpId && storage_corpId.corpId || 'ww7ee69c648ae1b7e6' if (!corpId) corpId = (storage_corpId && storage_corpId.corpId) || 'ww7ee69c648ae1b7e6'
util.setLocalStorage('dj_scrm_corpId', { corpId }) util.setLocalStorage('dj_scrm_corpId', { corpId })
if (sessionId || storage_sessionId) { if (sessionId || storage_sessionId) {
state.showWindow = true state.showWindow = true
...@@ -147,7 +146,7 @@ const actions = { ...@@ -147,7 +146,7 @@ const actions = {
state.showWindow = true state.showWindow = true
}, },
registerHttp({}, sessionId = '') { registerHttp({}, sessionId = '') {
window.$HTTP = new Http({...window.$fetchConfig, alert: Notify, headers: { token: sessionId } }) window.$HTTP = new Http({ ...window.$fetchConfig, alert: Notify, headers: { token: sessionId } })
} }
} }
const getParams = name => { const getParams = name => {
...@@ -165,4 +164,4 @@ export default { ...@@ -165,4 +164,4 @@ export default {
state, state,
mutations, mutations,
actions actions
}
\ No newline at end of file \ No newline at end of file
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!