Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
glsx
/
dj-scrm-wx-work-attachment-customer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit ca7f4783
authored
Nov 11, 2021
by
liwk
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
commit
1 parent
ddedb36e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
66 deletions
src/main.js
src/router/routes.js
src/store/modules/app.js
src/main.js
View file @
ca7f478
...
...
@@ -50,8 +50,8 @@ fetchConfig(!isMock).then(res => {
/**登录过期 重新登录 */
window
.
reLogin
=
()
=>
{
console
.
log
(
'重新登录'
)
util
.
clearSessionId
()
store
.
dispatch
(
'navigation'
)
//
util.clearSessionId()
//
store.dispatch('navigation')
}
window
.
vm
=
new
Vue
({
el
:
'#app'
,
...
...
src/router/routes.js
View file @
ca7f478
const
pages
=
[{
name
:
'customerGroup'
,
},
{
name
:
'activity'
,
meta
:
{
isTab
:
true
,
keepAlive
:
true
},
children
:
[
]
},
]
const
pages
=
{
customerGroup
:
[{
name
:
'index'
,
}],
}
const
redirect
=
'customerGroup'
let
routes
=
[]
const
keepAlives
=
[]
const
setChildren
=
(
e
,
parent
)
=>
{
let
arr
=
[]
e
.
children
.
map
(
child
=>
{
const
{
children
,
meta
}
=
child
let
url
=
`
${
parent
}
/
${
child
.
name
}
`
let
name
=
url
.
replace
(
/
\/
/g
,
'.'
)
let
route
=
{
path
:
`/
${
url
}
`
,
name
,
meta
:
meta
||
{},
component
:
resolve
=>
require
([
`views/
${
url
}
.vue`
],
resolve
)
}
Object
.
keys
(
pages
).
map
(
parent
=>
{
pages
[
parent
].
map
(
val
=>
{
const
isIndex
=
parent
==
redirect
&&
val
.
name
==
'index'
let
childrenPath
=
`
${
parent
}
/
${
val
.
name
}
`
let
meta
=
val
const
path
=
isIndex
?
'/'
:
`/
${
val
.
name
==
'index'
?
parent
:
childrenPath
}
`
const
name
=
val
.
name
==
'index'
?
parent
:
childrenPath
.
replace
(
'/'
,
'.'
)
delete
meta
.
name
if
(
meta
&&
meta
.
keepAlive
)
keepAlives
.
push
(
name
)
if
(
children
)
route
.
children
=
setChildren
(
child
,
url
)
arr
.
push
(
route
)
})
return
arr
}
const
getPages
=
_
=>
{
let
router
=
{
path
:
'/'
,
name
:
'home'
,
redirect
:
'/customerGroup'
,
component
:
resolve
=>
require
([
`views/home.vue`
],
resolve
),
}
router
.
children
=
pages
.
map
(
e
=>
{
let
name
=
`
${
e
.
name
}
`
let
route
=
{
path
:
`/
${
name
}
`
,
component
:
resolve
=>
require
([
`views/
${
childrenPath
}
.vue`
],
resolve
),
path
,
name
,
meta
:
e
.
meta
||
{},
component
:
resolve
=>
require
([
`views/
${
name
}
/index.vue`
],
resolve
)
meta
}
if
(
e
.
children
)
route
.
children
=
setChildren
(
e
,
name
)
if
(
e
.
meta
&&
e
.
meta
.
keepAlive
)
keepAlives
.
push
(
name
)
return
route
routes
.
push
(
route
)
})
return
[
router
]
}
console
.
log
(
getPages
()
)
})
console
.
log
(
routes
)
export
const
keeps
=
keepAlives
export
default
getPages
()
\ No newline at end of file
export
default
routes
\ No newline at end of file
src/store/modules/app.js
View file @
ca7f478
...
...
@@ -72,8 +72,11 @@ const actions = {
code
,
corpId
}).
then
(({
code
,
data
,
message
})
=>
{
let
url
=
`
${
window
.
$baseUrl
}
/dj-scrm-wx-work-main/#/`
let
route
=
state
.
lastPath
==
'home'
?
''
:
state
.
lastPath
// const { baseURL } = window.$fetchConfig.request
const
[
baseURL
]
=
redirectUrl
.
split
(
'/dj-scrm-wx-work-main/'
)
let
url
=
`
${
baseURL
}
/dj-scrm-wx-work-main/#/`
let
route
=
state
.
lastPath
==
'coupon'
?
''
:
state
.
lastPath
||
''
route
=
route
.
replace
(
'.'
,
'/'
)
state
.
showWindow
=
true
if
(
code
==
'0'
)
{
if
(
data
.
loginList
.
length
)
{
...
...
@@ -81,9 +84,11 @@ const actions = {
util
.
setLocalStorage
(
'dj_scrm_loginToken'
,
data
.
loginToken
)
util
.
setLocalStorage
(
'dj_scrm_accountList'
,
data
.
loginList
)
let
redirect_uri
=
encodeURI
(
`
${
redirectUrl
}${
route
}
`
)
// window.location.replace(`${url}common/accountList?redirect_uri=${redirect_uri}`)
//以下是 本地调试
let
[
userInfo
]
=
data
.
loginList
// 先注释
console
.
log
(
'回调'
,
`
${
url
}
common/accountList?redirect_uri=
${
redirect_uri
}
`
)
// window.location.href = `${url}common/accountList?redirect_uri=${redirect_uri}`
// 以下是 本地调试多账号
let
userInfo
=
data
.
loginList
[
0
]
let
{
merchantId
,
accountName
}
=
userInfo
let
loginAccount
=
accountName
ssoApi
.
selectAccount
({
...
...
@@ -98,13 +103,13 @@ const actions = {
util
.
setLocalStorage
(
'dj_scrm_userInfo'
,
res
.
data
)
util
.
setSessionId
(
res
.
data
.
sessionId
)
dispatch
(
'registerHttp'
,
res
.
data
.
sessionId
)
window
.
location
.
replace
(
`
${
redirectU
rl
}${
route
}
`
)
window
.
location
.
replace
(
`
${
u
rl
}${
route
}
`
)
})
}
else
{
let
[
userInfo
]
=
data
.
loginList
util
.
setLocalStorage
(
'dj_scrm_userInfo'
,
userInfo
)
util
.
setSessionId
(
userInfo
.
sessionId
)
registerHttp
(
userInfo
.
sessionId
)
dispatch
(
'registerHttp'
,
userInfo
.
sessionId
)
// 只有一个账号 history.back()
console
.
log
(
`
${
redirectUrl
}${
route
}
`
)
window
.
location
.
replace
(
`
${
redirectUrl
}${
route
}
`
)
...
...
@@ -124,6 +129,7 @@ const actions = {
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'
...
...
@@ -131,25 +137,24 @@ const actions = {
}
},
navigation
({
dispatch
})
{
util
.
showLoading
()
const
sessionId
=
getParams
(
'sessionId'
)
const
storage_sessionId
=
util
.
getSessionId
()
if
(
sessionId
||
storage_sessionId
)
{
state
.
showWindow
=
true
util
.
setSessionId
(
sessionId
||
storage_sessionId
)
registerHttp
(
sessionId
||
storage_sessionId
)
dispatch
(
'registerHttp'
,
sessionId
||
storage_sessionId
)
}
else
{
registerHttp
()
util
.
showLoading
()
dispatch
(
'registerHttp'
)
dispatch
(
'login'
)
return
}
state
.
showWindow
=
true
},
registerHttp
({},
sessionId
=
''
)
{
window
.
$HTTP
=
new
Http
({...
window
.
$fetchConfig
,
alert
:
Notify
,
headers
:
{
token
:
sessionId
}
})
}
}
const
registerHttp
=
sessionId
=>
{
window
.
$HTTP
=
new
Http
({...
window
.
$fetchConfig
,
alert
:
Notify
,
headers
:
{
token
:
sessionId
}
})
console
.
log
(
window
.
$HTTP
)
}
const
getParams
=
name
=>
{
let
[
url
,
paramsList
]
=
window
.
location
.
href
.
split
(
'?'
)
if
(
!
paramsList
)
return
name
?
null
:
{}
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment