Commit 09d50f8b by 李伟康

commit

1 parent fe39c4eb
......@@ -61,9 +61,11 @@ export default {
let options = this.tools.deepClone(staticOptions)
if (apiName == 'couponApi' || apiName == 'boutiquecouponApi' || apiName == 'equityApi') {
options[1].className = 'disabled'
this.options = options
this.showShare = true
return
}
console.log(options)
this.options = options
if (apiName == 'activityApi' || apiName == 'liveApi') {
this.showLoading()
......
......@@ -35,7 +35,6 @@ const mutations = {
SET_LAST_PATH(state, path) {
state.lastPath = path
}
}
const actions = {
setPageMeta({ commit }, meta) {
......@@ -56,68 +55,68 @@ const actions = {
},
login({ dispatch }) {
let [redirectUrl] = window.location.href.split('?')
// 以下是 本地调试
// 以下是 本地调试
if (process.env.NODE_ENV == 'development') {
const code = getParams('code')
if (code) {
const { corpId } = util.getLocalStorage('dj_scrm_corpId')
ssoApi.login({
code,
corpId
}).then(({ code, data, message }) => {
let route = state.lastPath == 'coupon' ? '' : state.lastPath || ''
route = route.replace('.', '/')
state.showWindow = true
if (code == '0') {
if (data.loginList.length) {
if (data.loginList.length > 1) {
util.setLocalStorage('dj_scrm_loginToken', data.loginToken)
util.setLocalStorage('dj_scrm_accountList', data.loginList)
let userInfo = data.loginList[2]
let { merchantId, accountName } = userInfo
let loginAccount = accountName
ssoApi.selectAccount({
loginAccount,
merchantId,
loginToken: data.loginToken,
loginSource: 'WW',
loginType: 3
}).then(res => {
util.removeLocalStorage('dj_scrm_loginToken')
util.removeLocalStorage('dj_scrm_accountList')
util.setLocalStorage('dj_scrm_userInfo', res.data)
util.setSessionId(res.data.sessionId)
dispatch('registerHttp', res.data.sessionId)
ssoApi
.login({
code,
corpId
})
.then(({ code, data, message }) => {
let route = state.lastPath == 'coupon' ? '' : state.lastPath || ''
route = route.replace('.', '/')
if (code == '0') {
if (data.loginList.length) {
if (data.loginList.length > 1) {
let userInfo = data.loginList[2]
let { merchantId, accountName } = userInfo
let loginAccount = accountName
ssoApi
.selectAccount({
loginAccount,
merchantId,
loginToken: data.loginToken,
loginSource: 'WW',
loginType: 3
})
.then(res => {
util.setLocalStorage('dj_scrm_userInfo', res.data)
util.setSessionId(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}`)
})
}
} 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}`)
window.location.replace(`${redirectUrl}#/${route}`)
/**没有账号 */
Notify('没有账号')
// window.location.href = `${url}common/nothing`
}
} else {
/**没有账号 */
// window.location.href = `${url}common/nothing`
}
} else {
/**账号过期 (暂时没有字段判断是否过期) */
Notify(message)
/**账号过期 (暂时没有字段判断是否过期) */
Notify(message)
// window.location.href = `${url}common/overdue`
}
})
}
})
} else {
util.showLoading()
let appid = getParams('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 })
// 'ww657a2d4ae89a4424'
// '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`
}
......@@ -132,7 +131,7 @@ const actions = {
let { sessionId, corpId } = getParams()
const storage_sessionId = util.getSessionId()
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 })
if (sessionId || storage_sessionId) {
state.showWindow = true
......@@ -147,7 +146,7 @@ const actions = {
state.showWindow = true
},
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 => {
......@@ -165,4 +164,4 @@ export default {
state,
mutations,
actions
}
\ 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!