Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
dj-simple
/
dj-admin
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 f5ebea61
authored
Mar 21, 2025
by
张立顺
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat 登录功能开发
1 parent
ac123335
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
86 additions
and
12 deletions
src/api/request.js
src/api/sys.account.js
src/store/modules/d2admin/modules/user.js
src/views/system/login/index.vue
src/api/request.js
View file @
f5ebea6
...
...
@@ -24,10 +24,15 @@ const request = (
apiName
=
"dj"
}
else
{
apiName
=
params
.
method
.
split
(
".api"
)[
0
]
if
(
apiName
==
"scrm"
)
{
// 使用split方法分割字符串
const
parts
=
params
.
method
.
split
(
"."
)
// 提取服务字段 索引3对应服务字段
apiName
=
parts
[
2
]
}
}
// console.log("params.method", params.method)
// console.log("apiName", apiName)
console
.
log
(
"params.method"
,
params
.
method
)
console
.
log
(
"apiName"
,
apiName
)
// 为空报错
if
(
!
apiName
)
{
throw
new
Error
(
"apiName is null"
)
...
...
@@ -35,19 +40,22 @@ const request = (
const
mappingName
=
{
"dj.smartcarlife"
:
"axios"
,
dj
:
"axios"
,
s
crm
:
"axios2"
,
s
hopmall
:
"axios2"
,
merchants
:
"axios3"
,
reportExport
:
"axios4"
,
"glsx.accounts.biz.common.pictureUpload"
:
"common"
,
clue
:
'axios5'
clue
:
"axios5"
,
sso
:
"axios6"
,
ssoCenter
:
"axios7"
}
const
baseApiName
=
mappingName
[
apiName
]
// console.log(baseApiName
, "baseApiName")
console
.
log
(
baseApiName
,
baseConfig
,
"baseApiName"
)
// params.appKey = baseConfig[baseApiName].appkey
if
(
baseApiName
==
"common"
)
{
params
.
app_key
=
baseConfig
[
baseApiName
].
appkey
}
else
{
params
.
appKey
=
baseConfig
[
baseApiName
].
appkey
params
.
appKey
=
baseConfig
[
baseApiName
].
appkey
||
""
}
// console.log("params.appKey", params.appKey)
params
.
timestamp
=
new
Date
().
getTime
()
...
...
@@ -72,10 +80,10 @@ const request = (
scrm
:
"sha1"
,
glsx
:
"md5"
,
"glsx.accounts.biz.common.pictureUpload"
:
"md5"
,
clue
:
'sha1'
clue
:
"sha1"
}
// console.log(signWay[apiName], "baseApiName")
const
secret
=
baseConfig
[
baseApiName
].
secret
const
secret
=
baseConfig
[
baseApiName
].
secret
||
""
const
CancelToken
=
axiosPackage
.
CancelToken
var
reqData
=
method
===
RequestMethods
.
POST
...
...
src/api/sys.account.js
View file @
f5ebea6
...
...
@@ -209,3 +209,11 @@ export function scrmLogin(data = {}) {
data
.
method
=
`scrm.api.sso.user.loginCode`
return
request
(
data
,
RequestMethods
.
POST
)
}
/**
* 账户中心账号登录
* @param {*} data 参数
*/
export
function
ssoLogin
(
data
=
{})
{
data
.
method
=
`ssoCenter.api.cas.api.login`
return
request
(
data
,
RequestMethods
.
POST
)
}
src/store/modules/d2admin/modules/user.js
View file @
f5ebea6
...
...
@@ -49,7 +49,11 @@ export default {
// labelText: '成功上传0条, 导入失败1条'
// }
],
updateRefesh
:
false
updateRefesh
:
false
,
scrmInfo
:
{},
SSOInfo
:
{
t
:
"TGT-57-yM93hs2pNJGpm4hloOInTVPRxoSHgwBvkkFdBCQAzP5eJPm7s2-qc36.glsx.com"
}
},
mutations
:
{
setDownloadList
(
state
,
{
list
,
type
})
{
...
...
@@ -63,6 +67,12 @@ export default {
},
setUpdateRefesh
(
state
,
data
)
{
state
.
updateRefesh
=
data
},
setScrmInfo
(
state
,
data
)
{
state
.
scrmInfo
=
data
},
setSSOInfo
(
state
,
data
)
{
state
.
SSOInfo
=
data
}
},
actions
:
{
...
...
src/views/system/login/index.vue
View file @
f5ebea6
...
...
@@ -145,8 +145,13 @@
<
script
>
import
util
from
"@/libs/util.js"
import
dayjs
from
"dayjs"
import
{
mapActions
}
from
"vuex"
import
{
selectAccount
,
getUserInfo
}
from
"@api/sys.account"
import
{
mapActions
,
mapState
}
from
"vuex"
import
{
selectAccount
,
getUserInfo
,
scrmLogin
,
ssoLogin
}
from
"@api/sys.account"
import
{
baseConfig
}
from
"@/main"
export
default
{
components
:
{
...
...
@@ -220,6 +225,8 @@ export default {
mounted
()
{
this
.
timeInterval
=
setInterval
(()
=>
this
.
refreshTime
(),
1000
)
this
.
$event
.
$on
(
"e-reg-dialog"
,
(
res
)
=>
(
this
.
registerDialogVisible
=
res
))
this
.
scrmLogin
()
this
.
ssoLogin
()
},
beforeDestroy
()
{
clearInterval
(
this
.
timeInterval
)
...
...
@@ -231,6 +238,45 @@ export default {
current
:
"d2admin/page/currentGet"
,
initBaseData
:
"d2admin/base/init"
}),
...
mapActions
(
"d2admin/user"
,
[
"setScrmInfo"
]),
scrmLogin
()
{
// scrm 登录
scrmLogin
({
source
:
"scrm-base"
,
loginSource
:
"SCRM"
,
productCode
:
"PC00000"
,
userName
:
"glsadmin"
,
password
:
"e10adc3949ba59abbe56e057f20f883e"
,
code
:
"1"
,
codeToken
:
"88af245d-5a3e-4692-9f55-6d7ea3cb9848"
})
.
then
((
res
)
=>
{
const
{
sessionId
,
merchantId
}
=
res
.
loginList
[
0
]
this
.
setScrmInfo
({
sessionId
,
merchantId
})
console
.
log
(
res
)
})
.
catch
((
err
)
=>
{
console
.
log
(
err
)
})
},
ssoLogin
()
{
// 账户中心 登录
ssoLogin
({
username
:
"admin"
,
password
:
"1f0a748dbb065d4f"
,
code
:
"8888"
,
lt
:
"LT-24330-yMjzGZjMu1tyW29hjqCRU2zcEnsKJq"
,
j_captcha_response
:
"8888"
})
.
then
((
res
)
=>
{
// const { sessionId, merchantId } = res.loginList[0]
// this.setScrmInfo({ sessionId, merchantId })
console
.
log
(
res
)
})
.
catch
((
err
)
=>
{
console
.
log
(
err
)
})
},
refreshTime
()
{
this
.
time
=
dayjs
().
format
(
"HH:mm:ss"
)
},
...
...
@@ -323,6 +369,8 @@ export default {
}
}
)
// 账户中心登录
}
})
}
...
...
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