Commit 4249e5f4 by liwk

commit

1 parent 8066a4a3
const url = '/rop-scrm-sso/router'
const returnAll = false
const returnAll = true
export default {
/**OAuth2授权登陆 */
login(data) {
......
......@@ -45,6 +45,7 @@ fetchConfig(!isMock).then(res => {
// 从配置服务器获取动态配置
// 设置 js中可以访问 $cdn
Vue.use(cfg)
window.$baseUrl = res.request.baseURL
window.$HTTP = new Http({...res, alert: components.Notify })
/**登录过期 重新登录 */
......
......@@ -37,7 +37,7 @@ router.beforeEach((to, from, next) => {
/* 路由发生变化修改页面title */
store.dispatch('setPageMeta', to.meta)
/* 路由发生变化修改页面背景色 */
store.dispatch('setPageBackground', to.meta)
document.documentElement.style.backgroundColor = to.meta.backgroundColor || '#fff'
next()
})
......
......@@ -11,7 +11,7 @@ const pages = [{
meta: {
isTab: true,
keepAlive: true,
backgroundColor: '#eee'
backgroundColor: '#F7F7F7'
},
children: [
......
......@@ -12,7 +12,6 @@ import util from '@/utils/util'
const state = {
pageMeta: '',
keepAlives: [],
next: '',
lastPath: ''
}
const mutations = {
......@@ -32,9 +31,6 @@ const mutations = {
return arr
}, [])
},
SET_ROUTER_OBJECT(state, next) {
state.next = next
},
SET_LAST_PATH(state, path) {
state.lastPath = path
}
......@@ -65,12 +61,6 @@ const actions = {
removeKeep({ commit }, names) {
commit('REMOVE_KEEP', names)
},
setRouterObjext({ commit }, next) {
commit('SET_ROUTER_OBJECT', next)
},
setPageBackground({}, { backgroundColor }) {
document.documentElement.style.backgroundColor = backgroundColor || '#fff'
},
login() {
let [redirectUrl] = window.location.href.split('?')
const code = getParams('code')
......@@ -82,9 +72,8 @@ const actions = {
}).then(({ code, data, message }) => {
let url = `${redirectUrl.split('#')[0]}#/`
let route = state.lastPath == 'home' ? '' : state.lastPath
state.appFlag = true
state.showWindow = true
if (code == '0') {
console.log(data)
if (data.loginList.length) {
if (data.loginList.length > 1) {
util.setLocalStorage('dj_scrm_loginToken', data.loginToken)
......@@ -124,7 +113,7 @@ const actions = {
let accountList = util.getLocalStorage('dj_scrm_accountList')
if (!userInfo) {
if (loginToken && accountList) {
state.appFlag = true
state.showWindow = true
router.replace({ name: 'common.accountList' })
return
} else {
......@@ -132,7 +121,7 @@ const actions = {
return
}
}
state.appFlag = true
state.showWindow = true
}
}
const getParams = name => {
......
......@@ -59,13 +59,15 @@ export default {
this.hideLoading()
this.removeLocalStorage('dj_scrm_loginToken')
this.removeLocalStorage('dj_scrm_accountList')
if (code == '0') {
if (data) {
let { lastPath } = this.getQuery()
let { lastPath, redirect_uri } = this.getQuery()
this.setLocalStorage('dj_scrm_userInfo', data)
this.setLocalStorage('dj_scrm_session_id', data.sessionId)
this.showLoading('登录成功', () => {
this.$router.replace({ name: lastPath || 'home' })
if (redirect_uri) window.location.replace(decodeURIComponent(`${redirect_uri}?sessionId=${data.sessionId}`))
else this.$router.replace({ name: lastPath || 'home' })
})
}
} else {
......
<!-- home -->
<template>
<div class="container">
<template v-if="appFlag">
<template v-if="showWindow">
<transition name="fade">
<keep-alive v-if="$route.meta.keepAlive">
<router-view></router-view>
......@@ -30,21 +30,21 @@ export default {
name: 'workbench',
}
],
appFlag: false,
showWindow: false,
}
},
watch: {
watchFlag: {
immediate: true,
handler (newval) {
this.appFlag = newval
this.showWindow = newval
this.hideLoading()
}
}
},
computed: {
watchFlag () {
return this.$store.state.app.appFlag
return this.$store.state.app.showWindow
}
},
......
<template>
<div class="layout">
首页
我的待办
</div>
</template>
......
......@@ -17,6 +17,7 @@
<div
:key="index"
class="item"
@click="jump(i)"
>
<div :class="['sprite-icon',`icon-${index + 4}`]"></div>
{{i.name}}
......@@ -54,7 +55,7 @@ export default {
return {
utilsList: [
{
name: '核销卡券'
name: '核销卡券',
},
{
name: '批量打标签'
......@@ -68,13 +69,17 @@ export default {
],
list: [
{
name: '我要发券'
name: '我要发券',
link: '/dj-scrm-wx-work-attachment-activity/#/coupon'
},
{
name: '秒杀活动'
name: '秒杀活动',
link: '/dj-scrm-wx-work-attachment-activity/#/activity'
},
{
name: '直播活动'
name: '直播活动',
link: '/dj-scrm-wx-work-attachment-activity/#/activity',
params: 'tabIndex=1'
}
]
}
......@@ -82,6 +87,13 @@ export default {
mounted () {
},
methods: {
jump (e) {
let sessionId = this.getLocalStorage('dj_scrm_session_id')
let { link, params } = e
let url = `${window.$baseUrl}${link}?sessionId=${sessionId}`
if (params)`${url}&${params}`
window.location.replace(url)
}
}
}
</script>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!