Commit 4249e5f4 by liwk

commit

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