Commit f5071335 authored by pengguangpu's avatar pengguangpu

修复支付结果页显示bug、打印上一单商品数据多余bug;

parent 60adba16
......@@ -15,7 +15,8 @@ Page({
list: [],
orderNo: "",
isPaying: false,
//记录跳转源,默认是首页home,如果是直接收款则是direct
from: "home"
},
//回退到上一个页面
......@@ -47,6 +48,7 @@ Page({
},
onLoad(options) {
console.log("balance onLoad==>" + JSON.stringify(options));
var totalQuantity = options.totalQuantity
var totalPrice = options.totalPrice
var totalDisc = options.totalDisc
......@@ -68,6 +70,13 @@ Page({
})
}
//如果是直接收款,则无需获取商品信息
if (options.type != null && options.type == "direct") {
console.log("直接收银,无需获取商品数据");
this.setData({
from: "direct"
});
} else {
//商品数据
let context = this;
my.getStorage({
......@@ -82,6 +91,8 @@ Page({
console.log("商品信息 ===》 " + JSON.stringify(res));
}
});
}
var speechContent = this.data.payPrice + "元";
my.ix.speech({
......@@ -125,7 +136,7 @@ Page({
},
onUnload() {
console.log("balance onShow");
console.log("balance onHide");
// 页面隐藏
//关闭后屏监听
my.ix.offBuddyMessage();
......@@ -253,6 +264,20 @@ Page({
my.ix.offCashierEventReceive();
this.saveData(this.data.list, res.data);
//如果是直接收款,则需抹掉本地商品数据信息
console.log("this.data.from==>" + this.data.from);
if (this.data.from == "direct") {
console.log("直接收款,抹掉商品数据");
my.setStorageSync({
key: 'paySuccessGoodsList',
data: null
});
my.setStorageSync({
key: 'goods',
data: null
});
}
my.reLaunch({
url: '/pages/paysuccess/paysuccess?totalGoodsNum=' + this.data.goodsNum,
});
......
......@@ -82,7 +82,7 @@ Page({
} else if (res.action == ACTION_DIRECT_PAYMENT) {
//直接收款
my.reLaunch({
url: "/pages/balance/balance?totalPrice=" + res.data + "&totalQuantity=0&totalDisc=0",
url: "/pages/balance/balance?totalPrice=" + res.data + "&totalQuantity=0&totalDisc=0&type=direct",
});
} else if (res.action == ACTION_CONVERT_COUPON) {
//兑换券
......@@ -362,7 +362,7 @@ Page({
printer.printText("订单号:" + printLastOrder_paySuccessResp.tradeNo),
printer.printNowDate(),
];
if (null != this.data.goodsList && this.data.goodsList.length > 0) {
if (null != printLastOrder_goodsList && printLastOrder_goodsList.length > 0) {
cmds.push(printer.printDivide("-")),
cmds.push(printer.printText("活动商品")),
cmds.push(printer.printText("商品名称 " + " 编码 " + " 数量"))
......
......@@ -71,8 +71,8 @@ page {
.printLoading {
position: relative;
width: 186rpx;
height: 186rpx;
width: 220rpx;
height: 189rpx;
margin: 0 auto;
margin-top: 38rpx;
/* border: 2px solid red; */
......
......@@ -25,8 +25,8 @@
</view>
</view>
<view class="printLoading">
<view hidden="{{!isShowPrinting}}">
<i-spin></i-spin>
<view style="margin:0 auto;position:absolute;left:16rpx;" hidden="{{!isShowPrinting}}">
<i-spin ></i-spin>
</view>
<view style="position:absolute;width:100%;height:100%;left:0rpx;top:0rpx;color:#000000;font-weight:bold;">
<view style="display: absolute;margin:0 auto;align-content: center;align-items: center;text-align:center;line-height:186rpx;">
......
......@@ -43,7 +43,7 @@ Page({
this.data.orderPriceFen = this.data.paySuccessResponse.tradeAmount;
this.data.couponPriceFen = this.data.paySuccessResponse.mdiscount + this.data.paySuccessResponse.discount;
this.data.payPriceFen = this.data.paySuccessResponse.tradeAmount - (this.data.paySuccessResponse.mdiscount + this.data.paySuccessResponse.discount);
this.data.totalCount = query.totalGoodsNum;
this.data.totalCount = this.caculateTotalCountFromGoodsList(this.data.goodsList);
var miyapay = require("../../utils/miyapay4.js");
this.data.orderPriceYuan = miyapay.fen2Yuan(this.data.orderPriceFen);
......@@ -58,6 +58,18 @@ Page({
}
},
//计算件数
caculateTotalCountFromGoodsList(goodsList) {
if (goodsList == null || goodsList.length == 0) {
return 0;
}
var totalCount = 0;
for (var i = 0; i < goodsList.length; i++) {
totalCount = totalCount + goodsList[i].quantity;
}
return totalCount;
},
print() {
//发起打印
var printer = require("../../utils/printer.js");
......@@ -74,10 +86,10 @@ Page({
];
if(null != this.data.goodsList && this.data.goodsList.length > 0){
cmds.push(printer.printDivide("-")) ,
cmds.push( printer.printText("活动商品")),
cmds.push( printer.printText("商品名称 " + " 编码 " + " 数量"))
if (null != this.data.goodsList && this.data.goodsList.length > 0) {
cmds.push(printer.printDivide("-")),
cmds.push(printer.printText("活动商品")),
cmds.push(printer.printText("商品名称 " + " 编码 " + " 数量"))
for (var i = 0; i < this.data.goodsList.length; i++) {
//循环取出商品数据
cmds.push(printer.setAlign(printer.ALIGN_LEFT));
......@@ -138,7 +150,6 @@ Page({
if (printEnabledLocal == null) {
printEnabledLocal = true;
}
//如果不打印小票,界面将有所变化
if (printEnabledLocal == false) {
this.setData({
......@@ -174,19 +185,19 @@ Page({
my.ix.offBuddyMessage();
},
onUnload(){
//清理支付数据
my.removeStorageSync({
key: 'paySuccessGoodsList',
});
// onUnload(){
// //清理支付数据
// my.removeStorageSync({
// key: 'paySuccessGoodsList',
// });
my.removeStorage({
key: 'goods',
success: function () {
}
});
// my.removeStorage({
// key: 'goods',
// success: function () {
// }
// });
}
// }
});
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