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
a0041802
Commit
a0041802
authored
Feb 12, 2020
by
gaodapeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加支付模块
parent
cec1724d
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
467 additions
and
9 deletions
+467
-9
apiurl.js
const/apiurl.js
+6
-0
balance.axml
pages/balance/balance.axml
+2
-2
balance.js
pages/balance/balance.js
+127
-7
payUtils.js
utils/payUtils.js
+332
-0
No files found.
const/apiurl.js
View file @
a0041802
...
...
@@ -4,3 +4,9 @@ export const API_LOGIN = "store/cashier/login";
export
const
API_SCAN
=
"market/barcodeQuery"
;
//核销券
export
const
API_USE_COUPON
=
"coupon/use"
;
//创建订单
export
const
API_CREATE_ORDER
=
"order/create"
;
//支付接口
export
const
API_PAY
=
"pay/micropay"
;
//查询支付结果
export
const
API_QUERY
=
"order/query"
;
\ No newline at end of file
pages/balance/balance.axml
View file @
a0041802
...
...
@@ -17,11 +17,11 @@
<view style="font-size:38rpx;width:300rpx;color:rgba(0,0,0,0.85);font-weight:500;font-family:PingFangSC-Medium,PingFang SC;opacity:0.85;margin:75rpx auto;">请选择支付方式</view>
<view style="width:750rpx;margin-top:78rpx;justify-content:space-between;display:flex;flex-direction:row;box-sizing:border-box;padding-left:96rpx;padding-right:96rpx;">
<view class="payWayContainer">
<view class="payWayContainer"
onTap="startPay"
>
<image mode="aspectFit" src="/images/icon_facepay.png" style="width:134rpx;height:131rpx;margin:10rpx 10rpx 10rpx 10rpx;"/>
<view class="payWayText">刷脸支付</view>
</view>
<view class="payWayContainer">
<view class="payWayContainer"
onTap="startPay"
>
<image mode="aspectFit" src="/images/icon_qrpay.png" style="width:134rpx;height:131rpx;margin:10rpx 10rpx 10rpx 10rpx;"/>
<view class="payWayText">扫码支付</view>
</view>
...
...
pages/balance/balance.js
View file @
a0041802
var
payUtils
=
require
(
"../../utils/payUtils.js"
);
Page
({
data
:
{
goodsNum
:
0
,
...
...
@@ -5,6 +7,10 @@ Page({
totalPrice
:
0.00
,
couponPrice
:
0.00
,
qrPayShow
:
false
,
list
:[],
orderNo
:
""
,
isCashierClosed
:
false
,
isPaying
:
false
,
},
onLoad
(
options
)
{
var
totalQuantity
=
options
.
totalQuantity
...
...
@@ -27,16 +33,130 @@ Page({
},
facePay
(){
/**
* @todo 支付结果的获取
* @todo 跳转数据的保存
*/
startPay
(){
//开始loading
my
.
showLoading
({});
//获取order
payUtils
.
getOrder
(
/*this.data.payPrice*/
1
,
this
.
data
.
list
,
function
(
res
){
if
(
res
!=
null
){
console
.
log
(
"callback调用,res="
+
JSON
.
stringify
(
res
));
if
(
res
.
resultCode
==
1
){
this
.
setData
({
orderNo
:
res
.
data
});
this
.
payWithOpenCashier
();
}
}
}.
bind
(
this
));
},
qrPay
(){
//todo 这里增加唤起弹窗的逻辑
this
.
setData
({
qrPayShow
:
true
});
//调用收款接口
doPay
(
orderNo
,
payCode
)
{
console
.
log
(
"doPay调用"
);
this
.
setData
({
isPaying
:
true
});
//使用barCode来当面付
payUtils
.
startPay
(
orderNo
,
payCode
,
1
,
this
.
data
.
list
,
function
(
res
){
my
.
hideLoading
();
console
.
log
(
"支付回调 ===>"
+
JSON
.
stringify
(
res
));
this
.
setData
({
isPaying
:
false
});
if
(
res
==
null
){
return
;
}
if
(
res
.
code
>
0
){
//成功
console
.
log
(
"支付回调成功,跳转 "
);
// if(data.isCashierClosed == true){
my
.
ix
.
offCashierEventReceive
();
my
.
redirectTo
({
url
:
'/pages/paysuccess/paysuccess?orderPrice='
+
this
.
data
.
totalPrice
+
"&couponPrice="
+
this
.
data
.
couponPrice
+
"&payPrice="
+
this
.
data
.
payPrice
+
"&totalCount="
+
this
.
data
.
totalCount
,
});
// }
}
else
{
console
.
log
(
"支付回调失败,toast提示 "
);
my
.
ix
.
offCashierEventReceive
();
my
.
showToast
({
type
:
'fail'
,
content
:
res
.
data
,
duration
:
2000
});
}
}.
bind
(
this
));
},
/**
* 打开收银台,进行扫码收款
*/
payWithOpenCashier
(
orderNo
){
try
{
console
.
info
(
"收银台版本"
+
my
.
ix
.
getVersionSync
({
packageName
:
'zoloz.phone.android.alipay.com.dragonfly'
}).
versionName
);
//开启收银台监听
my
.
ix
.
startApp
({
appName
:
"cashier"
,
bizNo
:
this
.
data
.
orderNo
,
totalAmount
:
this
.
data
.
payPrice
,
success
:
(
res
)
=>
{
console
.
log
(
"收银台启动回调 success==>"
+
JSON
.
stringify
(
res
));
if
(
res
.
codeType
==
"F"
)
{
this
.
doPay
(
orderNo
,
res
.
barCode
);
}
else
{
this
.
data
.
isCashierClosed
=
true
;
this
.
doPay
(
orderNo
,
res
.
barCode
);
}
},
fail
:(
res
)
=>
{
my
.
showToast
({
type
:
'exception'
,
content
:
api
.
decodeErrorMessage
(
res
.
error
),
duration
:
2000
});
}
});
//收银台回调
my
.
ix
.
onCashierEventReceive
((
res
)
=>
{
console
.
log
(
"onCashierEventReceive==>"
+
JSON
.
stringify
(
res
));
if
(
res
.
bizType
==
'RESULT_CLOSED'
||
res
.
status
==
"RESULT_CLOSE"
)
{
console
.
log
(
"收银台关闭"
);
this
.
data
.
isCashierClosed
=
true
;
//关闭监听
my
.
ix
.
offCashierEventReceive
();
if
(
this
.
data
.
isPaying
==
true
)
{
//如果正在支付中,则等待支付结果返回
}
else
{
//跳转支付结果页面,说明支付已完成,无论取消支付还是支付成功等都跳转支付结果页
// if (this.data.actualPayPriceYuan != null) {
// my.redirectTo({
// //payPrice和couponPrice需要考虑支付宝优惠
// url: '/pages/paysuccess/paysuccess?orderPrice=' + this.data.totalPrice + "&couponPrice=" + this.data.couponPrice + "&payPrice=" + this.data.payPrice+"&totalCount="+this.data.totalCount,
// });
// } else {
// //说明用户取消了支付
// my.redirectTo({
// url: '/pages/paysuccess/paysuccess?payFailedMsg=' + "用户取消" + "&payPriceYuan=" + this.data.payPriceYuan,
// });
// }
}
}
else
if
(
res
.
bizType
==
'RESULT_BTN_FUNCTION'
)
console
.
log
(
"收银台自定义按钮按下"
);
else
if
(
res
.
bizType
==
'RESULT_MEMBER'
)
console
.
log
(
"支付结果页会员开卡"
);
else
console
.
log
(
'RESULT: '
+
res
.
bizType
);
});
}
catch
{
console
.
log
(
"收银台启动回调 异常==>"
+
JSON
.
stringify
(
err
));
}
},
});
utils/payUtils.js
0 → 100644
View file @
a0041802
This diff is collapsed.
Click to expand it.
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