Commit d6f23122 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 595d1f4e df135c4b
......@@ -48,3 +48,6 @@ export const ACTION_REFUND_FAILED = "ACTION_REFUND_FAILED";
//登录完成
export const ACTION_LOGIN_OK = "ACTION_LOGIN_OK";
//打印上一单
export const ACTION_PRINT_LAST_ORDER = "ACTION_PRINT_LAST_ORDER";
......@@ -9,6 +9,7 @@ import { ACTION_GO_HOME } from '../../const/actioncmd'
import { ACTION_REFUND } from '../../const/actioncmd'
import { ACTION_REFUND_FAILED } from '../../const/actioncmd'
import { ACTION_REFUND_SUCCESS } from '../../const/actioncmd'
import { ACTION_PRINT_LAST_ORDER } from '../../const/actioncmd'
import { API_REFUND } from '../../const/apiurl'
......@@ -104,7 +105,7 @@ Page({
dialogResultFailureRemind: "兑换码未识别",
dialogResultFailureText: "兑换失败,请稍后重试!",
})
} else if (res.action == ACTION_REFUND) {
//显示弹窗
context.setData({
......@@ -124,11 +125,120 @@ Page({
scanDialogDisplay: 0,
dialogShowType: "",//重置类型
})
} else if (res.action == ACTION_PRINT_LAST_ORDER) {
//打印上一单
//商品列表
var printLastOrder_goodsList = my.getStorageSync({ key: 'paySuccessGoodsList' }).data;
var printLastOrder_paySuccessResp = my.getStorageSync({ key: 'paySuccessResponse' }).data;
if (printLastOrder_paySuccessResp == null) {
//本地没有上一单信息
my.ix.sendBuddyMessage({
// 填入目标小程序的 AppID
target: getApp().globalData.backScreenAppId,
data: {
action: ACTION_PRINT_LAST_ORDER,
data: {
code: -1,
data: "本地没有上一单信息"
}
},
success: (res) => {
console.info(`sendBuddyMessage success: ${JSON.stringify(res)}`);
},
fail: (res) => {
console.info(`sendBuddyMessage failed: ${JSON.stringify(res)}`);
}
});
return;
}
//去打印
context.printLastOrder(printLastOrder_goodsList, printLastOrder_paySuccessResp)
}
}
});
},
/**打印上一单 */
printLastOrder(printLastOrder_goodsList, printLastOrder_paySuccessResp) {
var printLastOrder_orderPriceFen = printLastOrder_paySuccessResp.tradeAmount;
var printLastOrder_couponPriceFen = printLastOrder_paySuccessResp.mdiscount + printLastOrder_paySuccessResp.discount;
var printLastOrder_payPriceFen = printLastOrder_paySuccessResp.tradeAmount - (printLastOrder_paySuccessResp.mdiscount + printLastOrder_paySuccessResp.discount);
var printLastOrder_totalCount = context.caculateTotalCountFromGoodsList(printLastOrder_goodsList);
//分转元
var miyapay = require("../../utils/miyapay4.js");
var printLastOrder_orderPriceYuan = miyapay.fen2Yuan(printLastOrder_orderPriceFen);
var printLastOrder_couponPriceYuan = miyapay.fen2Yuan(printLastOrder_couponPriceFen);
var printLastOrder_payPriceYuan = miyapay.fen2Yuan(printLastOrder_payPriceFen);
//支付渠道
var payChannel = "未知";
if (printLastOrder_paySuccessResp.channel == 1) {
payChannel = "微信";
} else if (printLastOrder_paySuccessResp.channel == 3) {
payChannel = "支付宝";
}
var printer = require("../../utils/printer.js");
var cmds = [
printer.setAlign(printer.ALIGN_CENTER),
printer.printText(getApp().globalData.localAccountInfo.storeName),
printer.setAlign(printer.ALIGN_LEFT),
printer.printDivide("-"),
printer.printText("门店号:" + printLastOrder_paySuccessResp.storeId),
printer.printText("收银员账号:" + printLastOrder_paySuccessResp.operatorId),
printer.printText("订单号:" + printLastOrder_paySuccessResp.tradeNo),
printer.printNowDate(),
printer.printDivide("-"),
printer.printText("活动商品"),
printer.printText("商品名称 " + " 编码 " + " 数量"),
];
for (var i = 0; i < printLastOrder_goodsList.length; i++) {
//循环取出商品数据
cmds.push(printer.setAlign(printer.ALIGN_LEFT));
cmds.push(printer.printText(printLastOrder_goodsList[i].name));
cmds.push(printer.printTwoText(printLastOrder_goodsList[i].barcode, printLastOrder_goodsList[i].quantity + ""));
}
cmds.push(printer.setAlign(printer.ALIGN_LEFT));
cmds.push(printer.printDivide("-"));
cmds.push(printer.printText("应收金额:" + printLastOrder_orderPriceYuan));
cmds.push(printer.printText(payChannel + ":" + printLastOrder_payPriceYuan));
for (var i = 0; i < 4; i++) {
cmds.push(printer.feedPaper());
}
printer.print({
isCheckStatus: getApp().globalData.containerVersionCode > 20,
cmds: cmds,
callback: (res) => {
//发送给后屏,告知打印结果
my.ix.sendBuddyMessage({
// 填入目标小程序的 AppID
target: getApp().globalData.backScreenAppId,
data: {
action: ACTION_PRINT_LAST_ORDER,
data: res
},
success: (res) => {
console.info(`sendBuddyMessage success: ${JSON.stringify(res)}`);
},
fail: (res) => {
console.info(`sendBuddyMessage failed: ${JSON.stringify(res)}`);
}
});
}
});
},
//计算件数
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;
},
//外接扫码枪事件
onKeyPress(r) {
console.log("scan onKeyPress==>" + r);
......@@ -136,7 +246,7 @@ Page({
if (this.data.dialogShowType == "refund") {
//退款
this.refund(r);
} else if(this.data.dialogShowType == "coupon") {
} else if (this.data.dialogShowType == "coupon") {
// 兑换券
this.verifyCoupon(r);
}
......@@ -205,6 +315,14 @@ Page({
});
},
//增加扫码内容,以及退款等操作的内容
onKeyPress(r) {
//只有在弹窗出现时才扫码
if (this.data.scanDialogDisplay > 0) {
this.refund(r);
}
},
//退款
refund(barcode) {
this.setData({ scanDialogDisplay: 2 })
......
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