Commit e7242221 authored by jiangjiantao's avatar jiangjiantao

Merge branch 'dev-1.0' of…

Merge branch 'dev-1.0' of https://gitlab.infra.miyatech.com/pengguangpu/doublescreen-front into dev-1.0
parents e50eb7e5 cc3c445a
......@@ -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
......@@ -62,12 +64,19 @@ Page({
if (totalPrice != null) {
this.setData({
payPrice: totalPrice - totalDisc,
payPrice: payUtils.fen2Yuan(payUtils.yuan2Fen(totalPrice) - payUtils.yuan2Fen(totalDisc)),
totalPrice: totalPrice,
couponPrice: totalDisc,
})
}
//如果是直接收款,则无需获取商品信息
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 () {
// }
// });
}
// }
});
......@@ -62,11 +62,11 @@ Page({
})
} else if (res.action == ACTION_MEMBER) {
let showPhone = res.data.substring(0,3)+"****"+res.data.substring(7,11)
let showPhone = res.data.substring(0, 3) + "****" + res.data.substring(7, 11)
context.setData({
memberPhone: res.data,
showMemberPhone:showPhone,
memberPoint:2130
showMemberPhone: showPhone,
memberPoint: 2130
})
}
else if (res.action == ACTION_GO_BALANCE) {
......@@ -80,11 +80,11 @@ Page({
my.reLaunch({
url: "/pages/home/home",
});
}else if (res.action == ACTION_USE_COUPON) {
} else if (res.action == ACTION_USE_COUPON) {
//优惠券
context.setData({
scanDialogDisplay: res.data.discCouponState,
totalDisc:res.data. discCouponPrice
totalDisc: res.data.discCouponPrice
});
if (res.data.discCouponState == 1) {
......@@ -125,7 +125,7 @@ Page({
let totalDiscTemp = this.data.totalDisc + Math.round(Math.random() * 4) + 1;
//超额
if(totalDiscTemp > this.data.totalPrice){
if (totalDiscTemp > this.data.totalPrice) {
let req = {}
req.discCouponMsg = "超额优惠券"
req.discCouponState = 4;
......@@ -137,7 +137,7 @@ Page({
let req = {}
req.discCouponPrice = totalDiscTemp;
req.discCouponState = 3;
this.useCouponCallback(ACTION_USE_COUPON,req)
this.useCouponCallback(ACTION_USE_COUPON, req)
}, 700);
},
......@@ -154,7 +154,7 @@ Page({
success: (res) => {
console.info(`sendBuddyMessage success: ${JSON.stringify(res)}`);
//用券成功
if(result.discCouponState == 3){
if (result.discCouponState == 3) {
//模拟数据 1 - 5 随机整数
context.setData({ scanDialogDisplay: 0, totalDisc: result.discCouponPrice })
my.showToast({
......@@ -166,13 +166,13 @@ Page({
},
});
//用券失败
}else if(result.discCouponState == 4){
} else if (result.discCouponState == 4) {
context.setData({ scanDialogDisplay: 4 })
}
},
fail: (res) => {
console.info(`sendBuddyMessage failed: ${JSON.stringify(res)}`);
context.useCouponCallback(action,result)
context.useCouponCallback(action, result)
}
});
},
......
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