Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
CFFP-HB
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chao Sun
CFFP-HB
Commits
af0f6fd9
Commit
af0f6fd9
authored
Mar 02, 2023
by
wenyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化H5用支付宝支付时跳转浏览器打开的Token问题
parent
4d691bd4
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
6 deletions
+31
-6
api/api.ts
+6
-1
pages/orderConfirm/orderConfirm.vue
+16
-2
util/interceptor.ts
+9
-3
No files found.
api/api.ts
View file @
af0f6fd9
...
...
@@ -13,7 +13,12 @@ export default {
// 获取token
obtainToken
(){
const
params
=
{
ticket
:
'uni-app'
ticket
:
'uni-app'
,
loginId
:
null
}
let
h5userId
=
uni
.
getStorageSync
(
'cffp_userId'
);
if
(
h5userId
)
{
params
.
loginId
=
h5userId
;
}
return
request
(
`
${
baseURL
}
/api/authorize/obtainToken`
,
"POST"
,
params
)
},
...
...
pages/orderConfirm/orderConfirm.vue
View file @
af0f6fd9
...
...
@@ -452,7 +452,22 @@
this
.
fileId
=
option
.
fileId
;
this
.
orderId
=
option
.
orderId
;
if
(
option
.
userId
)
{
this
.
userId
=
option
.
userId
this
.
userId
=
option
.
userId
;
}
this
.
isRedirect
=
option
.
isRedirect
;
if
(
this
.
isRedirect
==
1
&&
uni
.
getStorageSync
(
'cffp_userId'
))
{
uni
.
request
({
url
:
'/api/authorize/obtainToken'
,
method
:
'POST'
,
data
:
{
ticket
:
'uni-app'
,
loginId
:
uni
.
getStorageSync
(
'cffp_userId'
)},
success
:
(
res
)
=>
{
if
(
res
.
statusCode
===
200
)
{
uni
.
setStorageSync
(
'uni-token'
,
res
.
data
[
'data'
][
'token'
]);
uni
.
setStorageSync
(
'isLogin'
,
'1'
);
uni
.
setStorageSync
(
'isH5'
,
1
);
}
}
});
}
this
.
courseDetail
();
this
.
queryByUserIdFortuneStatistic
()
...
...
@@ -460,7 +475,6 @@
if
(
this
.
deviceType
==
3
)
{
this
.
paymentMethod
=
1
;
}
this
.
isRedirect
=
option
.
isRedirect
;
if
(
this
.
isRedirect
==
1
)
{
this
.
deductionCore
=
option
.
deductionCore
;
this
.
amount
=
Number
(
option
.
amount
);
...
...
util/interceptor.ts
View file @
af0f6fd9
...
...
@@ -15,19 +15,25 @@ export const interceptor = () => {
// 当本地没有token,并且接口地址没在白名单内,需要重新获取token
if
(
!
uni
.
getStorageSync
(
'uni-token'
)
&&
!
whiteApiList
.
includes
(
args
.
url
))
{
const
params
=
{
ticket
:
'uni-app'
,
loginId
:
null
}
let
h5userId
=
uni
.
getStorageSync
(
'cffp_userId'
);
if
(
h5userId
)
{
params
.
loginId
=
h5userId
;
}
uni
.
request
({
url
:
'/api/authorize/obtainToken'
,
method
:
'POST'
,
data
:
{
ticket
:
'uni-app'
},
data
:
params
,
success
:
(
res
)
=>
{
if
(
res
.
statusCode
===
200
)
{
uni
.
setStorageSync
(
'uni-token'
,
res
.
data
[
'data'
][
'token'
]);
window
.
location
.
href
=
window
.
location
.
href
+
'?'
+
't_reload='
+
new
Date
().
getTime
();
}
// console.log(res)
}
})
// uni.hideLoading();
}
// request 触发前拼接 url
...
...
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