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({ ...@@ -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
...@@ -62,26 +64,35 @@ Page({ ...@@ -62,26 +64,35 @@ Page({
if (totalPrice != null) { if (totalPrice != null) {
this.setData({ this.setData({
payPrice: totalPrice - totalDisc, payPrice: payUtils.fen2Yuan(payUtils.yuan2Fen(totalPrice) - payUtils.yuan2Fen(totalDisc)),
totalPrice: totalPrice, totalPrice: totalPrice,
couponPrice: totalDisc, couponPrice: totalDisc,
}) })
} }
//商品数据 //如果是直接收款,则无需获取商品信息
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 () {
} // }
}); // });
} // }
}); });
...@@ -31,7 +31,7 @@ Page({ ...@@ -31,7 +31,7 @@ Page({
dialogResultFailureText: "录入失败,请稍后重试!", dialogResultFailureText: "录入失败,请稍后重试!",
}, },
onReady() { onReady() {
if (my.canIUse('hideBackHome')) { if (my.canIUse('hideBackHome')) {
my.hideBackHome(); my.hideBackHome();
} }
...@@ -62,11 +62,11 @@ Page({ ...@@ -62,11 +62,11 @@ Page({
}) })
} else if (res.action == ACTION_MEMBER) { } 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({ context.setData({
memberPhone: res.data, memberPhone: res.data,
showMemberPhone:showPhone, showMemberPhone: showPhone,
memberPoint:2130 memberPoint: 2130
}) })
} }
else if (res.action == ACTION_GO_BALANCE) { else if (res.action == ACTION_GO_BALANCE) {
...@@ -80,11 +80,11 @@ Page({ ...@@ -80,11 +80,11 @@ Page({
my.reLaunch({ my.reLaunch({
url: "/pages/home/home", url: "/pages/home/home",
}); });
}else if (res.action == ACTION_USE_COUPON) { } else if (res.action == ACTION_USE_COUPON) {
//优惠券 //优惠券
context.setData({ context.setData({
scanDialogDisplay: res.data.discCouponState, scanDialogDisplay: res.data.discCouponState,
totalDisc:res.data. discCouponPrice totalDisc: res.data.discCouponPrice
}); });
if (res.data.discCouponState == 1) { if (res.data.discCouponState == 1) {
...@@ -96,7 +96,7 @@ Page({ ...@@ -96,7 +96,7 @@ Page({
} }
}); });
} }
} }
} }
...@@ -112,7 +112,7 @@ Page({ ...@@ -112,7 +112,7 @@ Page({
onKeyPress(r) { onKeyPress(r) {
if (this.data.scanDialogDisplay != 0) { if (this.data.scanDialogDisplay != 0) {
this.useCoupon(r); this.useCoupon(r);
return return
} }
console.log("scan onKeyPress==>" + r); console.log("scan onKeyPress==>" + r);
this.getGoodInfoByBarcode(r); this.getGoodInfoByBarcode(r);
...@@ -122,10 +122,10 @@ Page({ ...@@ -122,10 +122,10 @@ Page({
useCoupon(code) { useCoupon(code) {
this.setData({ scanDialogDisplay: 2 }) this.setData({ scanDialogDisplay: 2 })
setTimeout(() => { setTimeout(() => {
let totalDiscTemp = this.data.totalDisc + Math.round(Math.random() * 4) + 1; let totalDiscTemp = this.data.totalDisc + Math.round(Math.random() * 4) + 1;
//超额 //超额
if(totalDiscTemp > this.data.totalPrice){ if (totalDiscTemp > this.data.totalPrice) {
let req = {} let req = {}
req.discCouponMsg = "超额优惠券" req.discCouponMsg = "超额优惠券"
req.discCouponState = 4; req.discCouponState = 4;
...@@ -133,18 +133,18 @@ Page({ ...@@ -133,18 +133,18 @@ Page({
this.useCouponCallback(ACTION_USE_COUPON, req) this.useCouponCallback(ACTION_USE_COUPON, req)
return return
} }
let req = {} let req = {}
req.discCouponPrice = totalDiscTemp; req.discCouponPrice = totalDiscTemp;
req.discCouponState = 3; req.discCouponState = 3;
this.useCouponCallback(ACTION_USE_COUPON,req) this.useCouponCallback(ACTION_USE_COUPON, req)
}, 700); }, 700);
}, },
//用券回调 //用券回调
useCouponCallback(action, result) { useCouponCallback(action, result) {
let context = this; let context = this;
my.ix.sendBuddyMessage({ my.ix.sendBuddyMessage({
target: getApp().globalData.backScreenAppId, target: getApp().globalData.backScreenAppId,
data: { data: {
...@@ -154,7 +154,7 @@ Page({ ...@@ -154,7 +154,7 @@ Page({
success: (res) => { success: (res) => {
console.info(`sendBuddyMessage success: ${JSON.stringify(res)}`); console.info(`sendBuddyMessage success: ${JSON.stringify(res)}`);
//用券成功 //用券成功
if(result.discCouponState == 3){ if (result.discCouponState == 3) {
//模拟数据 1 - 5 随机整数 //模拟数据 1 - 5 随机整数
context.setData({ scanDialogDisplay: 0, totalDisc: result.discCouponPrice }) context.setData({ scanDialogDisplay: 0, totalDisc: result.discCouponPrice })
my.showToast({ my.showToast({
...@@ -166,13 +166,13 @@ Page({ ...@@ -166,13 +166,13 @@ Page({
}, },
}); });
//用券失败 //用券失败
}else if(result.discCouponState == 4){ } else if (result.discCouponState == 4) {
context.setData({ scanDialogDisplay: 4 }) context.setData({ scanDialogDisplay: 4 })
} }
}, },
fail: (res) => { fail: (res) => {
console.info(`sendBuddyMessage failed: ${JSON.stringify(res)}`); console.info(`sendBuddyMessage failed: ${JSON.stringify(res)}`);
context.useCouponCallback(action,result) context.useCouponCallback(action, result)
} }
}); });
}, },
...@@ -233,9 +233,9 @@ Page({ ...@@ -233,9 +233,9 @@ Page({
//价格 分转元 //价格 分转元
goodinfo.quantity = 1; goodinfo.quantity = 1;
goodinfo.price = goodinfo.price goodinfo.price = goodinfo.price
goodinfo.salePrice = goodinfo.salePrice goodinfo.salePrice = goodinfo.salePrice
goodinfo.discnt = goodinfo.discnt goodinfo.discnt = goodinfo.discnt
//总数量 //总数量
let totalQuantityTemp = 0 let totalQuantityTemp = 0
......
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