Commit d5765a1d authored by gaodapeng's avatar gaodapeng

删除重复内容,优化界面和代码

parent 0c9d686c
......@@ -14,12 +14,21 @@ page{
color: #ffffff;
position:relative;
margin-top: 91rpx;
font-size:34rpx;
font-family:PingFangSC-Medium,PingFang SC;
font-weight:500;
color:rgba(255,255,255,1);
line-height:38rpx;
}
.payPrice{
color: #ffffff;
font-size: 94rpx;
margin-top: 8rpx;
font-family:PingFangSC-Semibold,PingFang SC;
font-weight:600;
color:rgba(255,255,255,1);
line-height:113rpx;
}
.priceDetailRow{
display: flex;
......
<view class="page">
<image mode="aspectFit" src="/images/bg_balance.png" style="width:750rpx;height:504rpx"/>
<view style="position:absolute;width:100%;height:auto;left:0rpx;top:0rpx;display:flex;flex-direction:column;align-items:center">
<view class="goodsRemind">共计{{goodsNum}}件商品,应付总额</view>
<view class="payPrice">¥{{payPrice}}</view>
......@@ -14,7 +13,7 @@
</view>
</view>
<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="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;margin-top:579rpx">请选择支付方式</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" onTap="startPay">
......
......@@ -17,6 +17,9 @@ Page({
var totalQuantity = options.totalQuantity
var totalPrice = options.totalPrice
var totalDisc = options.totalDisc
this.setData({
list:options.goods,
});
if (totalQuantity != null) {
this.setData({
......@@ -29,6 +32,7 @@ Page({
this.setData({
payPrice: totalPrice,
totalPrice: totalPrice,
couponPrice: totalDisc,
})
}
......@@ -50,24 +54,6 @@ Page({
},
/**
* 保存最近支付成功的相关信息,每次支付成功都需刷新
* @param paySuccessGoodsList 支付成功的商品列表信息
* @param paySuccessResponse 支付成功响应,即云中台返回响应中的data信息
*/
saveData(paySuccessGoodsList, paySuccessResponse) {
my.setStorageSync({
key: 'paySuccessGoodsList',
data: paySuccessGoodsList
});
my.setStorageSync({
key: 'paySuccessResponse',
data: paySuccessResponse
});
},
/**
* @todo 支付结果的获取
......@@ -78,7 +64,8 @@ Page({
my.showLoading({});
//获取order
payUtils.getOrder(/*this.data.payPrice*/1,this.data.list, function(res){
var payAmount = payUtils.yuan2Fen(this.data.payPrice);
payUtils.getOrder(/*payAmount*/1,this.data.list, function(res){
if(res != null){
console.log("callback调用,res=" + JSON.stringify(res));
......@@ -92,41 +79,6 @@ Page({
}.bind(this));
},
//调用收款接口
doPay(orderNo, payCode) {
console.log("doPay调用"+orderNo);
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.resultCode == 1){
//成功
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("支付回调失败 ===》 "+res.message);
my.ix.offCashierEventReceive();
my.showToast({
type: 'fail',
content: res.message,
duration: 2000
});
}
}.bind(this));
},
/**
* 打开收银台,进行扫码收款
*/
......@@ -196,12 +148,14 @@ Page({
},
//调用收款接口
//调用收款接口
doPay(orderNo, payCode) {
console.log("doPay调用");
this.setData({isPaying:true});
//使用barCode来当面付
payUtils.startPay(orderNo, payCode, 1, this.data.list, function(res){
var payAmount = payUtils.yuan2Fen(this.data.payPrice);
payUtils.startPay(orderNo, payCode, /*payAmount*/1, this.data.list, function(res){
my.hideLoading();
console.log("支付回调 ===>" + JSON.stringify(res));
this.setData({isPaying:false});
......@@ -215,7 +169,7 @@ Page({
my.ix.offCashierEventReceive();
this.saveData(this.data.list, res);
my.redirectTo({
url: '/pages/paysuccess/paysuccess?orderPrice=' + this.data.totalPrice + "&couponPrice=" + this.data.couponPrice + "&payPrice=" + this.data.payPrice+"&totalCount="+this.data.totalCount,
url: '/pages/paysuccess/paysuccess',
});
// }
} else {
......@@ -230,6 +184,7 @@ Page({
}.bind(this));
},
/**
* 保存最近支付成功的相关信息,每次支付成功都需刷新
* @param paySuccessGoodsList 支付成功的商品列表信息
......
......@@ -331,5 +331,16 @@ function queryPayState(tradeNo, callback){
});
}
function fen2Yuan(num) {
if (typeof num !== "number" || isNaN(num)) return null;
return (num / 100).toFixed(2);
}
function yuan2Fen(yuan) {
return parseInt(yuan * 100);
}
module.exports.startPay = startPay;
module.exports.getOrder = getOrder;
\ No newline at end of file
module.exports.getOrder = getOrder;
module.exports.fen2Yuan = fen2Yuan;
module.exports.yuan2Fen = yuan2Fen;
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment