Commit f5071335 authored by pengguangpu's avatar pengguangpu

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

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