Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
CivWeb
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ReactWeb5
CivWeb
Commits
ec22e5ce
Commit
ec22e5ce
authored
Dec 15, 2023
by
徐乐
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 新增单点登录第三方免密跳转
parent
50e58463
Pipeline
#83152
passed with stages
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
89 additions
and
4 deletions
+89
-4
index.js
src/api/index.js
+1
-0
base.js
src/api/service/base.js
+10
-4
login.js
src/pages/user/login/login.js
+78
-0
No files found.
src/api/index.js
View file @
ec22e5ce
...
...
@@ -14,6 +14,7 @@ instanceRequest.transformRequestURL = function(url) {
'/PandaEnergy/WaterSaving/download'
,
'/PandaOMS/OMS/WebSite/GetConfig'
,
'/PandaOMS/OMS/CheckFreeLogin'
,
'/PandaCore/GCK/BussinessAuth/HDAuthLogin'
,
];
if
(
excludeURL
.
includes
(
url
))
{
return
url
.
replace
(
/PandaCore
\/
GateWay
\/
/
,
''
);
...
...
src/api/service/base.js
View file @
ec22e5ce
...
...
@@ -20,6 +20,7 @@ export const API = {
GET_WEATHER
:
'/CityInterface/rest/services/CountyProduct.svc/GetWeather'
,
SEND_MESSAGE_CODE
:
'CityInterface/rest/services/portal.svc/SendMessVerificationCode'
,
CHANGE_PASSWORD
:
'cityinterface/rest/services.svc/changepassword'
,
HD_AUTH_LOGIN
:
'/PandaCore/GCK/BussinessAuth/HDAuthLogin'
,
IOT_CHANGE_PASSWORD
:
'CityInterface/rest/services/OMS.svc/U_UpdatePasswordQuickGCK'
,
FILE_DOWNLOAD
:
'/cityinterface/rest/services/filedownload.svc/download'
,
UPDATE_AVATAR
:
'/CityInterface/rest/services/OMs.svc/U_EditUser'
,
...
...
@@ -66,6 +67,11 @@ const services = {
method
:
constants
.
REQUEST_METHOD_GET
,
type
:
constants
.
REQUEST_HTTP
,
},
HDAuthLogin
:
{
url
:
API
.
HD_AUTH_LOGIN
,
method
:
constants
.
REQUEST_METHOD_GET
,
type
:
constants
.
REQUEST_HTTP
,
},
authorizationToken
:
{
url
:
API
.
AUTHORIZATION_TOKEN
,
method
:
constants
.
REQUEST_METHOD_GET
,
...
...
@@ -152,8 +158,8 @@ const services = {
generateToken
:
{
url
:
()
=>
window
.
globalConfig
&&
(
window
.
globalConfig
.
loginTemplate
===
'Dark - IOTMultiLogin.html'
||
window
.
globalConfig
.
loginTemplate
===
'新春 - 智联.html'
)
(
window
.
globalConfig
.
loginTemplate
===
'Dark - IOTMultiLogin.html'
||
window
.
globalConfig
.
loginTemplate
===
'新春 - 智联.html'
)
?
API
.
GENERATE_IOT_TOKEN
:
API
.
GENERATE_TOKEN
,
method
:
constants
.
REQUEST_METHOD_GET
,
...
...
@@ -162,8 +168,8 @@ const services = {
changePassword
:
{
url
:
()
=>
window
.
globalConfig
&&
(
window
.
globalConfig
.
loginTemplate
===
'Dark - IOTMultiLogin.html'
||
window
.
globalConfig
.
loginTemplate
===
'新春 - 智联.html'
)
(
window
.
globalConfig
.
loginTemplate
===
'Dark - IOTMultiLogin.html'
||
window
.
globalConfig
.
loginTemplate
===
'新春 - 智联.html'
)
?
API
.
IOT_CHANGE_PASSWORD
:
API
.
CHANGE_PASSWORD
,
method
:
constants
.
REQUEST_METHOD_GET
,
...
...
src/pages/user/login/login.js
View file @
ec22e5ce
...
...
@@ -31,6 +31,17 @@ class Login {
props
.
updateConfig
(
config
);
this
.
globalConfig
=
getGlobalConfig
();
};
//单点登录_xule_20231214
let
queryString
=
window
.
location
.
search
.
substring
(
1
);
let
params
=
queryString
.
split
(
"&"
);
let
paramsFind
=
params
&&
params
.
find
(
function
(
a
)
{
return
a
.
split
(
'='
)[
0
]
==
'uniwater_utoken'
});
this
.
uniwater_utoken
=
paramsFind
?.
split
(
'='
)[
1
]
??
''
;
if
(
this
.
uniwater_utoken
)
{
this
.
getTokenForThird
();
}
this
.
createContext
=
props
.
createContext
;
this
.
history
=
props
.
history
;
this
.
callback
=
callback
;
...
...
@@ -42,6 +53,73 @@ class Login {
}
}
//单点登录接口_xule_20231214
getTokenForThird
()
{
let
self
=
this
;
appService
.
HDAuthLogin
({
token
:
self
.
uniwater_utoken
,
ignoreSite
:
true
,
})
.
then
(
res
=>
{
if
(
res
.
success
===
'OK'
)
{
const
tk
=
res
.
token
;
self
.
globalConfig
.
token
=
tk
;
getUserInfo
(
{
token
:
tk
,
subOID
:
'subOID'
,
site
:
this
.
getLocalSiteBytoken
(
tk
),
ignoreSite
:
true
,
},
)
.
then
(
response
=>
{
try
{
if
(
response
&&
response
.
code
===
0
)
{
self
.
globalConfig
.
userInfo
=
window
?.
globalConfig
?.
transformUserInfo
?.(
response
.
data
)
??
{};
const
date
=
new
Date
();
date
.
setTime
(
date
.
getTime
()
+
24
*
60
*
60
*
1000
);
// date = date.toGMTString();
const
encodeSite
=
encode
(
encodeURIComponent
(
response
.
site
));
Cookies
.
set
(
'site'
,
encodeSite
,
{
expires
:
date
,
path
:
'/'
,
});
Cookies
.
set
(
'token'
,
tk
,
{
expires
:
date
,
path
:
'/'
,
});
self
.
isSignIn
=
true
;
self
.
updateConfig
&&
self
.
updateConfig
(
self
.
globalConfig
);
const
loginSite
=
{};
loginSite
[
tk
]
=
response
.
site
;
localStorage
.
setItem
(
'loginSite'
,
JSON
.
stringify
(
loginSite
));
self
.
writeLogs
();
self
.
getIndustry
(
false
,
tk
);
}
else
{
message
.
error
(
response
.
errMsg
);
if
(
self
.
goLogin
())
{
return
false
;
}
}
self
.
updateConfig
&&
self
.
updateConfig
(
self
.
globalConfig
);
}
catch
(
error
)
{
message
.
error
(
'登录失败'
);
if
(
self
.
goLogin
())
{
return
false
;
}
}
})
.
catch
(
error
=>
{
this
.
handleLoginError
();
Logger
.
log
(
'获取用户配置失败'
);
});
}
})
}
gzlogin
(
userPhone
)
{
this
.
login
(
userPhone
,
''
,
userPhone
,
false
,
SERVICE_APP_LOGIN_MODE
.
phone
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment