Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
hrs_app_h5
/
bill
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
71241a28
authored
May 06, 2020
by
展昭
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
update
parent
54790a15
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
41 deletions
src/api/Bill/index.js
src/api/index.js
src/router/index.js
src/store/index.js
src/views/OidcCallback.vue
src/api/Bill/index.js
View file @
71241a28
...
@@ -5,7 +5,6 @@ export default {
...
@@ -5,7 +5,6 @@ export default {
// get数据
// get数据
getPeriod
()
{
getPeriod
()
{
let
url
=
urls
.
getPeriod
();
let
url
=
urls
.
getPeriod
();
console
.
log
(
'url='
,
url
);
return
AjaxRequest
.
get
(
url
);
return
AjaxRequest
.
get
(
url
);
},
},
getBillSummary
(
accountId
)
{
getBillSummary
(
accountId
)
{
...
...
src/api/index.js
View file @
71241a28
...
@@ -57,7 +57,8 @@ const api = {
...
@@ -57,7 +57,8 @@ const api = {
function
defineHeader
()
{
function
defineHeader
()
{
//const token = store.state.oidc.access_token;
//const token = store.state.oidc.access_token;
const
token
=
store
.
getters
.
getToken
;
const
token
=
store
.
getters
.
getToken
;
console
.
log
(
'token='
,
token
);
headers
.
Authorization
=
"Bearer "
+
token
;
headers
.
Authorization
=
"Bearer "
+
token
;
return
Promise
.
resolve
(
headers
);
return
Promise
.
resolve
(
headers
);
}
}
...
...
src/router/index.js
View file @
71241a28
...
@@ -68,6 +68,7 @@ router.beforeEach((to, from, next) => {
...
@@ -68,6 +68,7 @@ router.beforeEach((to, from, next) => {
const
authcode
=
to
.
query
.
authCode
||
to
.
query
.
authcode
;
const
authcode
=
to
.
query
.
authCode
||
to
.
query
.
authcode
;
const
appid
=
to
.
query
.
appId
||
to
.
query
.
appid
;
const
appid
=
to
.
query
.
appId
||
to
.
query
.
appid
;
if
(
!!
authcode
&&
!!
appid
)
{
if
(
!!
authcode
&&
!!
appid
)
{
localStorage
.
setItem
(
'appid'
,
appid
);
var
toPath
=
to
.
path
||
"/"
;
var
toPath
=
to
.
path
||
"/"
;
for
(
let
key
in
to
.
query
)
{
for
(
let
key
in
to
.
query
)
{
if
(
key
==
'authcode'
)
{
if
(
key
==
'authcode'
)
{
...
@@ -81,7 +82,6 @@ router.beforeEach((to, from, next) => {
...
@@ -81,7 +82,6 @@ router.beforeEach((to, from, next) => {
if
(
oidcUser
)
{
if
(
oidcUser
)
{
//如果登录用户与当前登录用户不匹配,则保存登录参数,退出
//如果登录用户与当前登录用户不匹配,则保存登录参数,退出
if
(
oidcUser
.
profile
.
sub
!=
userId
)
{
if
(
oidcUser
.
profile
.
sub
!=
userId
)
{
setAutoLogin
({
autoCode
:
authcode
,
redirectPath
:
toPath
})
setAutoLogin
({
autoCode
:
authcode
,
redirectPath
:
toPath
})
store
.
dispatch
(
"signOutOidc"
)
store
.
dispatch
(
"signOutOidc"
)
}
else
{
}
else
{
...
...
src/store/index.js
View file @
71241a28
import
Vue
from
'vue'
import
axios
from
"axios"
;
import
Vuex
from
'vuex'
import
qs
from
"qs"
;
import
Vue
from
'vue'
;
import
Vuex
from
'vuex'
;
import
{
vuexOidcCreateStoreModule
}
from
'vuex-oidc'
;
import
{
vuexOidcCreateStoreModule
}
from
'vuex-oidc'
;
import
{
GetCommonPms
}
from
"../assets/js/CommonPms.js"
;
import
oidcSettings
from
"../utils/oidcSettings"
;
import
oidcSettings
from
"../utils/oidcSettings"
;
import
bill
from
'./modules/bill'
import
any
from
'./modules/any'
;
import
token
from
'./modules/token'
import
bill
from
'./modules/bill'
;
import
any
from
'./modules/any'
import
more
from
'./modules/more'
;
import
more
from
'./modules/more'
;
import
api
from
'../api/index'
import
token
from
'./modules/token'
;
import
{
GetCommonPms
}
from
"../assets/js/CommonPms.js"
;
import
qs
from
"qs"
;
import
axios
from
"axios"
;
Vue
.
use
(
Vuex
)
Vue
.
use
(
Vuex
)
...
@@ -32,7 +31,6 @@ async function getToken(access_token, appid) {
...
@@ -32,7 +31,6 @@ async function getToken(access_token, appid) {
.
post
(
url
,
qs
.
stringify
(
pms
))
.
post
(
url
,
qs
.
stringify
(
pms
))
.
then
(
.
then
(
res
=>
{
res
=>
{
console
.
log
(
"res="
,
res
);
if
(
res
.
status
==
200
)
{
if
(
res
.
status
==
200
)
{
const
accessToken
=
res
.
data
.
access_token
;
const
accessToken
=
res
.
data
.
access_token
;
localStorage
.
setItem
(
"token"
,
accessToken
);
localStorage
.
setItem
(
"token"
,
accessToken
);
...
@@ -59,10 +57,12 @@ export default new Vuex.Store({
...
@@ -59,10 +57,12 @@ export default new Vuex.Store({
isAuthenticatedBy
:
'access_token'
,
isAuthenticatedBy
:
'access_token'
,
dispatchEventsOnWindow
:
true
dispatchEventsOnWindow
:
true
},
{
},
{
userLoaded
:
(
user
)
=>
{
userLoaded
:
async
(
user
)
=>
{
console
.
log
(
"userLoaded=>"
,
user
);
// console.log("userLoaded=>", user);
const
appid
=
66853
;
const
appid
=
localStorage
.
getItem
(
'appid'
);
getToken
(
user
.
access_token
,
appid
);
console
.
log
(
'appid='
,
appid
);
await
getToken
(
user
.
access_token
,
appid
);
console
.
log
(
'appid2222222='
,
appid
);
}
}
})
})
}
}
...
...
src/views/OidcCallback.vue
View file @
71241a28
...
@@ -17,15 +17,6 @@ export default {
...
@@ -17,15 +17,6 @@ export default {
name
:
"OidcCallback"
,
name
:
"OidcCallback"
,
methods
:
{
methods
:
{
...
mapActions
([
"oidcSignInCallback"
,
"getOidcUser"
]),
...
mapActions
([
"oidcSignInCallback"
,
"getOidcUser"
]),
getQueryString
(
urlsearch
,
name
)
{
if
(
!
urlsearch
)
{
return
null
;
}
var
reg
=
new
RegExp
(
"(^|&)"
+
name
+
"=([^&]*)(&|$)"
);
var
r
=
urlsearch
.
match
(
reg
);
if
(
r
!=
null
)
return
unescape
(
r
[
2
]);
return
null
;
},
async
getToken
(
access_token
,
appid
,
redirectPath
)
{
async
getToken
(
access_token
,
appid
,
redirectPath
)
{
let
pms
=
{
let
pms
=
{
client_id
:
oidc_config
.
client_id
,
client_id
:
oidc_config
.
client_id
,
...
@@ -63,22 +54,9 @@ export default {
...
@@ -63,22 +54,9 @@ export default {
mounted
()
{
mounted
()
{
this
.
oidcSignInCallback
()
this
.
oidcSignInCallback
()
.
then
(
redirectPath
=>
{
.
then
(
redirectPath
=>
{
this
.
getOidcUser
(
user
=>
{
console
.
log
(
"redirectPath="
,
redirectPath
);
});
const
urlsearch
=
redirectPath
.
split
(
"?"
)[
1
];
console
.
log
(
"urlsearch="
,
urlsearch
);
const
appid
=
this
.
getQueryString
(
urlsearch
,
"appId"
);
console
.
log
(
"appid="
,
appid
);
// this.getOidcUser()
// .then(user => {
// let urlsearch = redirectPath.split("?")[1];
// let appid = this.getQueryString(urlsearch, "appid");
// this.getToken(user.access_token, appid, redirectPath);
// })
// .catch(err => {
// console.log("err=", err);
// });
this
.
$router
.
push
(
redirectPath
);
this
.
$router
.
push
(
redirectPath
);
})
})
.
catch
(
err
=>
{
.
catch
(
err
=>
{
...
...
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