Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
glsx
/
dj-scrm-wx-work-main
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 b101b417
authored
Nov 06, 2021
by
liwk
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
commit
1 parent
4249e5f4
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
28 additions
and
16 deletions
src/main.js
src/store/modules/app.js
src/utils/index.js
src/utils/util.js
src/views/common/accountList.vue
src/views/workbench/index.vue
src/main.js
View file @
b101b41
...
...
@@ -21,7 +21,6 @@ import { bus, tools, store as local } from './utils'
import
'./utils/util'
import
'components'
import
{
components
}
from
'@/plugins/vant'
import
{
Http
}
from
'glsx-common'
components
.
forEach
(
component
=>
Vue
.
use
(
component
))
Vue
.
prototype
.
api
=
api
Vue
.
prototype
.
bus
=
bus
...
...
@@ -45,10 +44,8 @@ fetchConfig(!isMock).then(res => {
// 从配置服务器获取动态配置
// 设置 js中可以访问 $cdn
Vue
.
use
(
cfg
)
window
.
$baseUrl
=
res
.
request
.
baseURL
window
.
$HTTP
=
new
Http
({...
res
,
alert
:
components
.
Notify
})
/**登录过期 重新登录 */
window
.
$fetchConfig
=
res
/**登录过期 重新登录 */
window
.
reLogin
=
()
=>
{
console
.
log
(
123
)
}
...
...
src/store/modules/app.js
View file @
b101b41
...
...
@@ -7,8 +7,9 @@
* @LastEditTime: 2021-07-06 12:02:21
*/
import
{
ssoApi
}
from
'@/api'
import
{
store
}
from
'utils'
import
util
from
'@/utils/util'
import
{
store
,
util
}
from
'utils'
import
{
Http
}
from
'glsx-common'
import
{
Notify
}
from
'vant'
const
state
=
{
pageMeta
:
''
,
keepAlives
:
[],
...
...
@@ -61,11 +62,14 @@ const actions = {
removeKeep
({
commit
},
names
)
{
commit
(
'REMOVE_KEEP'
,
names
)
},
registerHttp
({},
sessionId
=
''
)
{
window
.
$HTTP
=
new
Http
({...
window
.
$fetchConfig
,
alert
:
Notify
,
headers
:
{
token
:
sessionId
}
})
},
login
()
{
let
[
redirectUrl
]
=
window
.
location
.
href
.
split
(
'?'
)
const
code
=
getParams
(
'code'
)
if
(
code
)
{
const
corpId
=
util
.
getLocalStorage
(
'dj_scrm_corpId'
)
const
{
corpId
}
=
util
.
getLocalStorage
(
'dj_scrm_corpId'
)
ssoApi
.
login
({
code
,
corpId
...
...
@@ -82,7 +86,8 @@ const actions = {
}
else
{
let
[
userInfo
]
=
data
.
loginList
util
.
setLocalStorage
(
'dj_scrm_userInfo'
,
userInfo
)
util
.
setLocalStorage
(
'dj_scrm_session_id'
,
userInfo
.
sessionId
)
util
.
setSessionId
(
userInfo
.
sessionId
)
dispatch
(
'registerHttp'
,
userInfo
.
sessionId
)
// 只有一个账号 history.back()
window
.
location
.
replace
(
`
${
url
}${
route
}
`
)
}
...
...
@@ -100,7 +105,7 @@ const actions = {
util
.
showLoading
()
let
corpId
=
getParams
(
'corpId'
)
//从链接获取
if
(
!
corpId
)
corpId
=
'ww7ee69c648ae1b7e6'
util
.
setLocalStorage
(
'dj_scrm_corpId'
,
corpId
)
util
.
setLocalStorage
(
'dj_scrm_corpId'
,
{
corpId
}
)
// 'ww657a2d4ae89a4424'
const
wxUrl
=
'https://open.weixin.qq.com/connect/oauth2/authorize'
window
.
location
.
replace
(
`
${
wxUrl
}
?appid=
${
corpId
}
&redirect_uri=
${
encodeURIComponent
(
redirectUrl
)}
&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect`
)
...
...
@@ -111,6 +116,7 @@ const actions = {
let
loginToken
=
util
.
getLocalStorage
(
'dj_scrm_loginToken'
)
let
userInfo
=
util
.
getLocalStorage
(
'dj_scrm_userInfo'
)
let
accountList
=
util
.
getLocalStorage
(
'dj_scrm_accountList'
)
dispatch
(
'registerHttp'
)
if
(
!
userInfo
)
{
if
(
loginToken
&&
accountList
)
{
state
.
showWindow
=
true
...
...
src/utils/index.js
View file @
b101b41
...
...
@@ -7,8 +7,9 @@
* @LastEditTime: 2021-06-20 12:49:11
*/
import
bus
from
'./eventBus'
import
util
from
'./util'
import
*
as
tool
from
'./tools'
const
{
debounce
,
throttle
,
...
tools
}
=
tool
import
*
as
constants
from
'./constants'
import
store
from
'./store'
export
{
bus
,
tools
,
debounce
,
throttle
,
constants
,
store
}
\ No newline at end of file
export
{
bus
,
tools
,
debounce
,
throttle
,
constants
,
store
,
util
}
\ No newline at end of file
src/utils/util.js
View file @
b101b41
...
...
@@ -83,6 +83,12 @@ const touchstart = e => {
const
touchend
=
e
=>
{
e
.
target
.
classList
.
remove
(
'btn-on-leave'
)
}
const
setSessionId
=
val
=>
{
window
.
localStorage
.
setItem
(
'dj_scrm_session_id'
,
val
)
}
const
getSessionId
=
()
=>
{
return
window
.
localStorage
.
getItem
(
'dj_scrm_session_id'
)
}
const
setLocalStorage
=
(
key
,
item
)
=>
{
window
.
localStorage
.
setItem
(
key
,
JSON
.
stringify
(
item
))
// sessionStorage.setItem(key, JSON.stringify(item))
...
...
@@ -166,6 +172,8 @@ const utils = {
getLocalStorage
,
makePhoneCall
,
isFullSucreen
,
setSessionId
,
getSessionId
,
showLoading
,
hideLoading
,
refreshPage
,
...
...
src/views/common/accountList.vue
View file @
b101b41
...
...
@@ -59,12 +59,12 @@ export default {
this
.
hideLoading
()
this
.
removeLocalStorage
(
'dj_scrm_loginToken'
)
this
.
removeLocalStorage
(
'dj_scrm_accountList'
)
if
(
code
==
'0'
)
{
if
(
data
)
{
let
{
lastPath
,
redirect_uri
}
=
this
.
getQuery
()
this
.
setLocalStorage
(
'dj_scrm_userInfo'
,
data
)
this
.
setLocalStorage
(
'dj_scrm_session_id'
,
data
.
sessionId
)
this
.
setSessionId
(
data
.
sessionId
)
store
.
dispatch
(
'registerHttp'
,
data
.
sessionId
)
this
.
showLoading
(
'登录成功'
,
()
=>
{
if
(
redirect_uri
)
window
.
location
.
replace
(
decodeURIComponent
(
`
${
redirect_uri
}
?sessionId=
${
data
.
sessionId
}
`
))
else
this
.
$router
.
replace
({
name
:
lastPath
||
'home'
})
...
...
src/views/workbench/index.vue
View file @
b101b41
...
...
@@ -70,7 +70,7 @@ export default {
list
:
[
{
name
:
'我要发券'
,
link
:
'/dj-scrm-wx-work-attachment-activity/#/coupon'
link
:
'/dj-scrm-wx-work-
main/
attachment-activity/#/coupon'
},
{
name
:
'秒杀活动'
,
...
...
@@ -88,9 +88,9 @@ export default {
},
methods
:
{
jump
(
e
)
{
let
sessionId
=
this
.
get
LocalStorage
(
'dj_scrm_session_id'
)
let
sessionId
=
this
.
get
SessionId
(
)
let
{
link
,
params
}
=
e
let
url
=
`
${
window
.
$baseUrl
}${
link
}
?sessionId=
${
sessionId
}
`
let
url
=
`
${
link
}
?sessionId=
${
sessionId
}
`
if
(
params
)
`
${
url
}
&
${
params
}
`
window
.
location
.
replace
(
url
)
}
...
...
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