Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
traceSourceMb
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
yanyanhong
traceSourceMb
Commits
b20d4dbd
Commit
b20d4dbd
authored
Jan 04, 2021
by
chenqikuai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 充值成功返回后,展示是否充值成功的检查
parent
670ae6db
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
13 deletions
+79
-13
Recharge.vue
src/views/userCenter/Recharge.vue
+75
-13
types.ts
src/views/userCenter/types.ts
+4
-0
No files found.
src/views/userCenter/Recharge.vue
View file @
b20d4dbd
...
@@ -112,6 +112,7 @@ export default class Recharge extends Vue {
...
@@ -112,6 +112,7 @@ export default class Recharge extends Vue {
// method: 1,
// method: 1,
// },
// },
// };
// };
@
Prop
()
private
isCallback
!
:
boolean
;
private
payMethods
:
IMethod
[]
=
[];
private
payMethods
:
IMethod
[]
=
[];
private
planList
:
any
[]
=
[];
private
planList
:
any
[]
=
[];
private
selectedPlan
:
any
=
{
private
selectedPlan
:
any
=
{
...
@@ -180,17 +181,42 @@ export default class Recharge extends Vue {
...
@@ -180,17 +181,42 @@ export default class Recharge extends Vue {
});
});
}
}
private
async
recharge
()
{
private
async
recharge
()
{
const
{
id
}
=
await
this
.
$api
.
order
.
add
(
this
.
selectedPlan
.
id
);
try
{
const
{
id
}
=
await
this
.
$api
.
order
.
add
(
this
.
selectedPlan
.
id
,
this
.
method
);
this
.
confirm
=
true
;
this
.
confirm
=
true
;
this
.
orderId
=
id
;
this
.
orderId
=
id
;
}
catch
(
err
)
{
if
(
err
.
code
===
10603
)
{
this
.
$dialog
.
confirm
({
title
:
'提示'
,
message
:
'您的账户还很充足请剩余少量余额时进行充值'
,
confirmButtonText
:
'确定'
,
cancelButtonText
:
'取消'
,
});
}
}
}
}
private
goToQrPayPage
(
pay_url
:
string
,
coin
:
string
,
downloadUrl
:
string
){
this
.
$router
.
push
({
name
:
'ViewCode'
,
query
:
{
locationUrl
:
pay_url
,
payment
:
JSON
.
stringify
(
true
),
coin
,
downloadUrl
}
})
}
private
async
payHandler
()
{
private
async
payHandler
()
{
const
{
protocol
,
host
}
=
location
;
const
{
protocol
,
host
}
=
location
;
localStorage
.
setItem
(
'orderId'
,
this
.
orderId
);
localStorage
.
setItem
(
'methodId'
,
JSON
.
stringify
(
this
.
selectedMethodId
));
const
params
:
any
=
{};
const
params
:
any
=
{};
if
(
this
.
getSelectedPayMethodType
===
EPayMethod
.
biqianbaopay
)
params
.
coin
=
this
.
getSelectedPayMethod
().
coin
;
if
(
this
.
getSelectedPayMethodType
===
EPayMethod
.
biqianbaopay
)
params
.
coin
=
this
.
getSelectedPayMethod
().
coin
;
const
{
pay_url
}
=
await
this
.
$api
.
order
.
pay
(
this
.
orderId
,
this
.
getSelectedPayMethodType
,
params
);
const
{
pay_url
}
=
await
this
.
$api
.
order
.
pay
(
this
.
orderId
,
this
.
getSelectedPayMethodType
,
params
);
const
redirectUrl
=
encodeURIComponent
(
`
${
protocol
}
//
${
host
}
/#/recharge
Success
`
);
const
redirectUrl
=
encodeURIComponent
(
`
${
protocol
}
//
${
host
}
/#/recharge
?isCallback=true
`
);
if
(
this
.
getSelectedPayMethodType
===
EPayMethod
.
biqianbaopay
){
if
(
this
.
getSelectedPayMethodType
===
EPayMethod
.
biqianbaopay
){
// 币钱包 需要展示二维码
// 币钱包 需要展示二维码
...
@@ -198,19 +224,55 @@ export default class Recharge extends Vue {
...
@@ -198,19 +224,55 @@ export default class Recharge extends Vue {
const
coin
=
method
.
coin
;
const
coin
=
method
.
coin
;
const
downloadUrl
=
method
.
download_url
;
const
downloadUrl
=
method
.
download_url
;
this
.
$router
.
push
({
localStorage
.
setItem
(
'payUrl'
,
pay_url
);
name
:
'ViewCode'
,
query
:
{
this
.
goToQrPayPage
(
pay_url
,
coin
,
downloadUrl
)
locationUrl
:
pay_url
,
payment
:
JSON
.
stringify
(
true
),
coin
,
downloadUrl
}
})
}
else
{
}
else
{
// 支付宝和微信支付走👇流程
// 支付宝和微信支付走👇流程
location
.
href
=
this
.
getSelectedPayMethodType
===
EPayMethod
.
alipay
?
pay_url
:
`
${
pay_url
}
&redirect_url=
${
redirectUrl
}
`
;
const
url
=
this
.
getSelectedPayMethodType
===
EPayMethod
.
alipay
?
pay_url
:
`
${
pay_url
}
&redirect_url=
${
redirectUrl
}
`
;
localStorage
.
setItem
(
'payUrl'
,
url
);
location
.
href
=
url
;
}
}
private
async
confrimPayed
()
{
const
{
protocol
,
host
}
=
location
;
this
.
orderId
=
String
(
localStorage
.
getItem
(
'orderId'
));
const
redirectUrl
=
String
(
localStorage
.
getItem
(
'payUrl'
));
if
(
!
this
.
orderId
||
!
redirectUrl
)
{
return
this
.
redirectToRecharge
();
}
}
const
{
status
}
=
await
this
.
$api
.
order
.
get
(
this
.
orderId
);
if
(
status
===
2
)
{
// 0:未支付 1:支付中 2:支付成功 3:支付失败
this
.
$router
.
replace
({
name
:
'RechargeSuccess'
});
}
else
{
this
.
$dialog
.
confirm
({
title
:
'提示'
,
message
:
'您当前还没有完成付款,请点击[继续付款]进行支付'
,
confirmButtonText
:
'继续付款'
,
cancelButtonText
:
'取消'
,
}).
then
(()
=>
{
const
methodId
:
number
=
JSON
.
parse
(
localStorage
.
getItem
(
'methodId'
)
||
''
)
const
payMethod
=
this
.
payMethods
.
find
(
method
=>
method
.
id
===
methodId
)
if
(
payMethod
?.
type
===
EPayMethod
.
biqianbaopay
){
this
.
goToQrPayPage
(
redirectUrl
,
payMethod
.
coin
,
payMethod
.
download_url
);
}
else
{
location
.
href
=
redirectUrl
;
}
}).
catch
((
err
)
=>
{
this
.
$router
.
push
({
path
:
'/userCenter/index'
});
});
}
}
private
redirectToRecharge
()
{
localStorage
.
setItem
(
'orderId'
,
''
);
localStorage
.
setItem
(
'payUrl'
,
''
);
this
.
$router
.
replace
({
name
:
'Recharge'
});
}
private
rePay
()
{
this
.
redirectToRecharge
();
}
}
}
}
</
script
>
</
script
>
...
...
src/views/userCenter/types.ts
View file @
b20d4dbd
import
{
EPayMethod
}
from
'./const'
;
export
interface
IMethod
{
export
interface
IMethod
{
id
:
number
;
coin
:
string
;
coin
:
string
;
download_url
:
string
;
download_url
:
string
;
type
:
EPayMethod
;
[
props
:
string
]:
any
;
[
props
:
string
]:
any
;
}
}
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