Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
D
doublescreen-front
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
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
pengguangpu
doublescreen-front
Commits
922c93bf
Commit
922c93bf
authored
Feb 13, 2020
by
gaodapeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改了支付内容
parent
90227f26
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
10 deletions
+27
-10
balance.js
pages/balance/balance.js
+19
-2
payUtils.js
utils/payUtils.js
+8
-8
No files found.
pages/balance/balance.js
View file @
922c93bf
...
...
@@ -32,6 +32,7 @@ Page({
}
},
/**
...
...
@@ -155,16 +156,17 @@ Page({
if
(
res
==
null
){
return
;
}
if
(
res
.
code
>
0
){
if
(
res
.
resultCode
==
1
){
//成功
console
.
log
(
"支付回调成功,跳转 "
);
// if(data.isCashierClosed == true){
my
.
ix
.
offCashierEventReceive
();
saveData
(
list
,
res
);
my
.
redirectTo
({
url
:
'/pages/paysuccess/paysuccess?orderPrice='
+
this
.
data
.
totalPrice
+
"&couponPrice="
+
this
.
data
.
couponPrice
+
"&payPrice="
+
this
.
data
.
payPrice
+
"&totalCount="
+
this
.
data
.
totalCount
,
});
// }
}
else
{
}
else
{
console
.
log
(
"支付回调失败,toast提示 "
);
my
.
ix
.
offCashierEventReceive
();
my
.
showToast
({
...
...
@@ -176,6 +178,21 @@ Page({
}.
bind
(
this
));
},
/**
* 保存最近支付成功的相关信息,每次支付成功都需刷新
* @param paySuccessGoodsList 支付成功的商品列表信息
* @param paySuccessResponse 支付成功响应,即云中台返回响应中的data信息
*/
saveData
(
paySuccessGoodsList
,
paySuccessResponse
)
{
my
.
setStorageSync
({
key
:
'paySuccessGoodsList'
,
data
:
paySuccessGoodsList
});
my
.
setStorageSync
({
key
:
'paySuccessResponse'
,
data
:
paySuccessResponse
});
},
});
utils/payUtils.js
View file @
922c93bf
...
...
@@ -194,16 +194,16 @@ function pay(tradeNo, payCode, payPrice, list, callback, retryCount){
success
:
(
res
)
=>
{
//增加数据判断,增加重试
console
.
log
(
"支付接口回调 ==>"
+
JSON
.
stringify
(
res
));
if
(
res
==
null
||
res
.
data
==
null
||
res
.
data
.
success
!=
true
/*||res.data.data == null*/
)
{
if
(
res
==
null
||
res
.
data
==
null
||
res
.
data
.
success
!=
true
||
res
.
data
.
data
==
null
)
{
console
.
log
(
"支付未成功 ==>"
+
JSON
.
stringify
(
res
.
data
.
message
));
retryOrFailed
(
tradeNo
,
payCode
,
payPrice
,
list
,
callback
,
retryCount
);
}
else
{
console
.
log
(
"支付返回值 ==>"
+
JSON
.
stringify
(
res
.
data
));
console
.
log
(
"支付返回值 ==>"
+
JSON
.
stringify
(
res
.
data
));
if
(
res
.
data
.
data
.
tradeStatus
==
"3"
){
onPaySuccess
(
res
.
data
.
data
,
callback
);
onPaySuccess
(
res
.
data
.
data
,
callback
);
}
else
if
(
res
.
data
.
data
.
tradeStatus
==
"1"
){
//需要查询结果
//轮询查询,最多12次
queryPayStateWithRetry
(
tradeNo
,
callback
,
0
);
queryPayStateWithRetry
(
tradeNo
,
callback
,
0
);
}
else
{
//查询一次
queryPayState
(
tradeNo
,
callback
);
...
...
@@ -249,7 +249,6 @@ function queryPayStateWithRetry(tradeNo, callback, retryCount){
callback
(
response
);
return
;
}
retryCount
++
;
var
queryStateRequest
=
api
.
createCommonRequest
();
queryStateRequest
.
tradeNo
=
tradeNo
;
queryStateRequest
.
batchNo
=
""
+
Date
.
parse
(
new
Date
());
...
...
@@ -264,6 +263,7 @@ function queryPayStateWithRetry(tradeNo, callback, retryCount){
data
:
queryStateRequest
,
success
:
(
res
)
=>
{
//增加数据判断,增加重试
console
.
log
(
"查询结果"
+
JSON
.
stringify
(
res
));
if
(
res
==
null
||
res
.
data
==
null
||
res
.
data
.
success
!=
true
||
res
.
data
.
data
==
null
)
{
//不知名原因导致失败,直接报失败
console
.
log
(
"查询失败,支付失败"
);
var
response
=
{
resultCode
:
-
1
,
message
:
"支付失败"
};
...
...
@@ -272,9 +272,9 @@ function queryPayStateWithRetry(tradeNo, callback, retryCount){
if
(
res
.
data
.
data
.
tradeStatus
==
"3"
){
//成功直接报成功
onPaySuccess
(
res
.
data
.
data
,
callback
);
}
else
if
(
res
.
data
.
data
.
tradeStatus
==
"1"
){
//需要查询结果,继续轮询
console
.
log
(
"查询结果显示支付未成功
==>"
+
res
.
data
.
message
);
console
.
log
(
"查询结果显示支付未成功
,重试 "
);
sleep
(
5000
);
queryPayStateWithRetry
(
tradeNo
,
callback
,
retryCount
);
queryPayStateWithRetry
(
tradeNo
,
callback
,
++
retryCount
);
}
else
{
//其他状况直接报失败
var
response
=
{
resultCode
:
-
1
,
message
:
"支付失败"
};
callback
(
response
);
...
...
@@ -284,7 +284,7 @@ function queryPayStateWithRetry(tradeNo, callback, retryCount){
fail
:
(
res
)
=>
{
//接口访问失败,继续轮询
console
.
log
(
"查询失败 ==>"
+
JSON
.
stringify
(
res
));
sleep
(
5000
);
queryPayStateWithRetry
(
tradeNo
,
callback
,
retryCount
);
queryPayStateWithRetry
(
tradeNo
,
callback
,
++
retryCount
);
}
});
}
...
...
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