Commit 3f0efb0d authored by pengguangpu's avatar pengguangpu

合并远程分支;

parents e8b9d858 3f54ae30
......@@ -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">
......
......@@ -3,20 +3,23 @@ var payUtils = require("../../utils/payUtils.js");
Page({
data: {
goodsNum: 0,
payPrice: 0.00,
totalPrice: 0.00,
couponPrice: 0.00,
qrPayShow: false,
list: [],
orderNo: "",
isCashierClosed: false,
goodsNum:0,
payPrice:0.00,
totalPrice:0.00,
couponPrice:0.00,
qrPayShow:false,
list:[],
orderNo:"",
isCashierClosed:false,
isPaying: false,
},
onLoad(options) {
var totalQuantity = options.totalQuantity
var totalPrice = options.totalPrice
var totalDisc = options.totalDisc
this.setData({
list:options.goods,
});
if (totalQuantity != null) {
this.setData({
......@@ -29,112 +32,60 @@ Page({
this.setData({
payPrice: totalPrice,
totalPrice: totalPrice,
couponPrice: totalDisc,
})
}
//商品数据
let context = this;
my.getStorage({
key: 'goods',
success: function (res) {
console.log("商品信息 ===》 " + JSON.stringify(res));
context.setData({
list: res.data
})
},
fail: function (res) {
console.log("商品信息 ===》 " + JSON.stringify(res));
}
});
//商品数据
let context = this;
my.getStorage({
key: 'goods',
success: function (res) {
console.log("商品信息 ===》 " + JSON.stringify(res));
context.setData({
list:res.data
})
},
fail: function (res) {
console.log("商品信息 ===》 " + JSON.stringify(res));
}
});
},
/**
* 保存最近支付成功的相关信息,每次支付成功都需刷新
* @param paySuccessGoodsList 支付成功的商品列表信息
* @param paySuccessResponse 支付成功响应,即云中台返回响应中的data信息
*/
saveData(paySuccessGoodsList, paySuccessResponse) {
my.setStorageSync({
key: 'paySuccessGoodsList',
data: paySuccessGoodsList
});
my.setStorageSync({
key: 'paySuccessResponse',
data: paySuccessResponse
});
},
/**
* @todo 支付结果的获取
* @todo 跳转数据的保存
*/
startPay() {
startPay(){
//开始loading
my.showLoading({});
//获取order
payUtils.getOrder(/*this.data.payPrice*/1, this.data.list, function (res) {
if (res != null) {
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));
if (res.resultCode == 1) {
if(res.resultCode ==1){
this.setData({
orderNo: res.data
orderNo:res.data
});
this.payWithOpenCashier(res.data);
this.payWithOpenCashier(res.data);
}
}
}.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){
this.saveData(this.data.list, res.data);
my.ix.offCashierEventReceive();
my.redirectTo({
url: '/pages/paysuccess/paysuccess?totalGoodsNum='+this.data.goodsNum+'&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));
},
/**
* 打开收银台,进行扫码收款
*/
payWithOpenCashier() {
try {
payWithOpenCashier(){
try{
console.info("收银台版本" + my.ix.getVersionSync({
packageName: 'zoloz.phone.android.alipay.com.dragonfly'
packageName: 'zoloz.phone.android.alipay.com.dragonfly'
}).versionName);
//开启收银台监听
......@@ -150,7 +101,7 @@ Page({
this.data.isCashierClosed = true;
this.doPay(this.data.orderNo, res.barCode);
}
}, fail: (res) => {
},fail:(res) => {
my.showToast({
type: 'exception',
content: api.decodeErrorMessage(res.error),
......@@ -171,7 +122,7 @@ Page({
//如果正在支付中,则等待支付结果返回
} else {
//跳转支付结果页面,说明支付已完成,无论取消支付还是支付成功等都跳转支付结果页
// if (this.data.actualPayPriceYuan != null) {
// my.redirectTo({
// //payPrice和couponPrice需要考虑支付宝优惠
......@@ -191,12 +142,49 @@ Page({
else
console.log('RESULT: ' + res.bizType);
});
} catch (err) {
} catch(err) {
console.log("收银台启动回调 异常==>" + JSON.stringify(err));
}
},
//调用收款接口
doPay(orderNo, payCode) {
console.log("doPay调用");
this.setData({isPaying:true});
//使用barCode来当面付
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});
if(res == null){
return;
}
if(res.resultCode == 1){
//成功
console.log("支付回调成功,跳转 " );
// if(data.isCashierClosed == true){
my.ix.offCashierEventReceive();
this.saveData(this.data.list, res.data);
my.redirectTo({
url: '/pages/paysuccess/paysuccess',
});
// }
} else {
console.log("支付回调失败,toast提示 ");
my.ix.offCashierEventReceive();
my.showToast({
type: 'fail',
content: res.message,
duration: 2000
});
}
}.bind(this));
},
/**
* 保存最近支付成功的相关信息,每次支付成功都需刷新
* @param paySuccessGoodsList 支付成功的商品列表信息
......@@ -212,6 +200,6 @@ Page({
data: paySuccessResponse
});
},
});
......@@ -32,8 +32,6 @@ function getOrder(
if (app.globalData.localAccountInfo != null) {
orderCreateRequest.storeId = app.globalData.localAccountInfo.storeId;
}
//测试代码
orderCreateRequest.storeId = "001";
orderCreateRequest.tradeAmount = tradeAmount;
orderCreateRequest.deviceType = "ALIPAY";
orderCreateRequest.list = list;
......@@ -331,5 +329,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