|
|
@ -23,7 +23,7 @@ export default { |
|
|
success: function(res) { |
|
|
success: function(res) { |
|
|
if (res.data.code == 200) { |
|
|
if (res.data.code == 200) { |
|
|
data1 = res.data.result |
|
|
data1 = res.data.result |
|
|
console.log('打印的数据----------',data1) |
|
|
console.log('打印的数据----------', data1) |
|
|
that.bindViewTap(id, false, onDone) |
|
|
that.bindViewTap(id, false, onDone) |
|
|
} else { |
|
|
} else { |
|
|
uni.showToast({ |
|
|
uni.showToast({ |
|
|
@ -41,6 +41,7 @@ export default { |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
} else { |
|
|
} else { |
|
|
|
|
|
if(uni.getStorageSync('peisongyuan')) return; |
|
|
uni.showModal({ |
|
|
uni.showModal({ |
|
|
title: '提示', |
|
|
title: '提示', |
|
|
content: '您还没有连接打印机,将无法为您打印小票!', |
|
|
content: '您还没有连接打印机,将无法为您打印小票!', |
|
|
@ -107,79 +108,86 @@ export default { |
|
|
data1.deliveryType == 1 && data1.orderType == 3 ? data1.deliveryInfo.numberCode : data1.numberCode |
|
|
data1.deliveryType == 1 && data1.orderType == 3 ? data1.deliveryInfo.numberCode : data1.numberCode |
|
|
); |
|
|
); |
|
|
printerJobs.setAlign('ct').setSize(2, 2).setLineSpacing(60).print( |
|
|
printerJobs.setAlign('ct').setSize(2, 2).setLineSpacing(60).print( |
|
|
(data1.deliveryInfo && data1.deliveryInfo.appointmentDelivery == 1 && data1.status != 7 && data1.status == 11)? '预约单': |
|
|
(data1.deliveryInfo && data1.deliveryInfo.appointmentDelivery == 1 && data1.status != 7 && data1 |
|
|
(data1.status == 7 || data1.status == 11)? '申请退款': |
|
|
.status == 11) ? '预约单' : |
|
|
(data1.deliveryType == 1 && data1.orderType == 3) ? '面对面配送': |
|
|
(data1.status == 7 || data1.status == 11) ? '申请退款' : |
|
|
(data1.status == 3 && data1.deliveryType == 2 && data1.userRequireMake != 1)? '待消费': |
|
|
(data1.deliveryType == 1 && data1.orderType == 3) ? '面对面配送' : |
|
|
data1.status == 5? '已完成': |
|
|
(data1.status == 3 && data1.deliveryType == 2 && data1.userRequireMake != 1) ? '待消费' : |
|
|
data1.status == 6? '已取消': |
|
|
data1.status == 5 ? '已完成' : |
|
|
data1.status == 8? '已退款': |
|
|
data1.status == 6 ? '已取消' : |
|
|
data1.status == 12? '已售后': |
|
|
data1.status == 8 ? '已退款' : |
|
|
data1.isPack == 0 && data1.otherOrder == null ? '到店-堂食': |
|
|
data1.status == 12 ? '已售后' : |
|
|
data1.deliveryType == 1 && data1.isPack == 1 ? '配送': |
|
|
data1.isPack == 0 && data1.otherOrder == null ? '到店-堂食' : |
|
|
data1.isPack == 1 && data1.otherOrder == null ? '到店-打包': '' |
|
|
data1.deliveryType == 1 && data1.isPack == 1 ? '配送' : |
|
|
|
|
|
data1.isPack == 1 && data1.otherOrder == null ? '到店-打包' : '' |
|
|
|
|
|
|
|
|
); |
|
|
); |
|
|
if(data1.deliveryInfo && data1.deliveryInfo.appointmentDelivery == 1){ |
|
|
if (data1.deliveryInfo && data1.deliveryInfo.appointmentDelivery == 1) { |
|
|
printerJobs.setAlign('lt').print( |
|
|
printerJobs.setAlign('lt').print( |
|
|
'要求送达时间:' + (data1.deliveryInfo == null ? ' ' : this.formatTime(data1.deliveryInfo.mustFinishTime)) |
|
|
'要求送达时间:' + (data1.deliveryInfo == null ? ' ' : this.formatTime(data1.deliveryInfo |
|
|
|
|
|
.mustFinishTime)) |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
printerJobs.setSize(1, 1).setLineSpacing(40); |
|
|
printerJobs.setSize(1, 1).setLineSpacing(40); |
|
|
printerJobs.setAlign('lt').print(data1.shopName + ((data1.deliveryType == 1 && data1.orderType == 3)? '('+data1.numberCode + ')':'')); |
|
|
printerJobs.setAlign('lt').print(data1.shopName + ((data1.deliveryType == 1 && data1.orderType == 3) ? '(' + |
|
|
|
|
|
data1.numberCode + ')' : '')); |
|
|
|
|
|
|
|
|
printerJobs.setAlign('lt').print( |
|
|
printerJobs.setAlign('lt').print( |
|
|
'下单时间:' + this.formatTime(data1.createTime) |
|
|
'下单时间:' + this.formatTime(data1.createTime) |
|
|
); |
|
|
); |
|
|
if(data1.mallRefundRecord == null){ |
|
|
if (data1.mallRefundRecord == null) { |
|
|
if(data1.deliveryType == 1){ |
|
|
if (data1.deliveryType == 1) { |
|
|
printerJobs.setAlign('lt').print( |
|
|
printerJobs.setAlign('lt').print( |
|
|
'预计送达时间:' + (data1.deliveryInfo == null ? ' ' : this.formatTime(data1.deliveryInfo.mustFinishTime)) |
|
|
'预计送达时间:' + (data1.deliveryInfo == null ? ' ' : this.formatTime(data1.deliveryInfo |
|
|
|
|
|
.mustFinishTime)) |
|
|
); |
|
|
); |
|
|
}else if(data1.userRequireMake == 1){ |
|
|
} else if (data1.userRequireMake == 1) { |
|
|
printerJobs.setAlign('lt').print( |
|
|
printerJobs.setAlign('lt').print( |
|
|
'核销时间:' + this.formatTime(data1.createTime) |
|
|
'核销时间:' + this.formatTime(data1.createTime) |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if(data1.mallRefundRecord != null){ |
|
|
if (data1.mallRefundRecord != null) { |
|
|
if(data1.userRequireMake == 1 && data1.deliveryType == 2){ |
|
|
if (data1.userRequireMake == 1 && data1.deliveryType == 2) { |
|
|
printerJobs.setAlign('lt').print( |
|
|
printerJobs.setAlign('lt').print( |
|
|
'核销时间:' + this.formatTime(data1.createTime) |
|
|
'核销时间:' + this.formatTime(data1.createTime) |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
printerJobs.setAlign('lt').print( |
|
|
printerJobs.setAlign('lt').print( |
|
|
'申请退款时间:' + (data1.mallRefundRecord == null ? ' ' : this.formatTime(data1.mallRefundRecord[0].createTime)) |
|
|
'申请退款时间:' + (data1.mallRefundRecord == null ? ' ' : this.formatTime(data1.mallRefundRecord[0] |
|
|
|
|
|
.createTime)) |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
printerJobs.print(printerUtil.fillLine('-', 1, 32)); |
|
|
printerJobs.print(printerUtil.fillLine('-', 1, 32)); |
|
|
if(data1.deliveryType == 1 && data1.status != 7 && data1.status != 11 && data1.status != 5 && data1.status != 6 && data1.status != 8 && data1.status != 12){ |
|
|
if (data1.deliveryType == 1 && data1.status != 7 && data1.status != 11 && data1.status != 5 && data1 |
|
|
|
|
|
.status != 6 && data1.status != 8 && data1.status != 12) { |
|
|
printerJobs.setAlign('lt').setSize(2, 2).setLineSpacing(60).print( |
|
|
printerJobs.setAlign('lt').setSize(2, 2).setLineSpacing(60).print( |
|
|
data1.receiverName == null ? ' ' : data1.receiverName |
|
|
data1.deliveryInfo == null ? ' ' : data1.deliveryInfo.receiverName |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
printerJobs.setSize(1, 1).setLineSpacing(40); |
|
|
printerJobs.setSize(1, 1).setLineSpacing(40); |
|
|
printerJobs.setAlign('lt').print('联系电话: ' + this.maskPhoneLastFour(data1.receiverPhone)); |
|
|
printerJobs.setAlign('lt').print('联系电话: ' + this.maskPhoneLastFour(data1.receiverPhone)); |
|
|
if(data1.deliveryType == 1 && data1.status != 7 && data1.status != 11 && data1.status != 5 && data1.status != 6 && data1.status != 8 && data1.status != 12){ |
|
|
if (data1.deliveryType == 1 && data1.status != 7 && data1.status != 11 && data1.status != 5 && data1 |
|
|
|
|
|
.status != 6 && data1.status != 8 && data1.status != 12) { |
|
|
printerJobs.setAlign('lt').setSize(2, 2).setLineSpacing(60).print( |
|
|
printerJobs.setAlign('lt').setSize(2, 2).setLineSpacing(60).print( |
|
|
'地址:' + (data1.receiverAddress == null ? ' ' : data1.receiverAddress) |
|
|
'地址:' + (data1.deliveryInfo == null ? ' ' : data1.deliveryInfo.receiverAddress) |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
printerJobs.setSize(1, 1).setLineSpacing(40); |
|
|
printerJobs.setSize(1, 1).setLineSpacing(40); |
|
|
printerJobs.setAlign('lt').print('顾客电话已被隐藏,您可登录商家端或骑手端查看'); |
|
|
printerJobs.setAlign('lt').print('顾客电话已被隐藏,您可登录商家端或骑手端查看'); |
|
|
printerJobs.print(printerUtil.fillLine('-', 1, 32)); |
|
|
printerJobs.print(printerUtil.fillLine('-', 1, 32)); |
|
|
for (var i = 0; i < data1.goodsList.length; i++) { |
|
|
for (var i = 0; i < data1.goodsList.length; i++) { |
|
|
if(i != 0){ |
|
|
if (i != 0) { |
|
|
printerJobs.setSize(1, 1).print(" "); |
|
|
printerJobs.setSize(1, 1).print(" "); |
|
|
} |
|
|
} |
|
|
var productName = this.removeEmojis(data1.goodsList[i].productName) |
|
|
var productName = this.removeEmojis(data1.goodsList[i].productName) |
|
|
printerJobs.setAlign('lt').setSize(2, 2).print(productName); |
|
|
printerJobs.setAlign('lt').setSize(2, 2).print(productName); |
|
|
|
|
|
|
|
|
if (data1.goodsList[i].specs.indexOf(',') != -1) { |
|
|
if (data1.goodsList[i].specs.indexOf(',') != -1) { |
|
|
printerJobs.setSize(1, 1).setLineSpacing(10).print(' '); |
|
|
printerJobs.setSize(1, 1).setLineSpacing(10).print(' '); |
|
|
printerJobs.setSize(1, 1).print(this.delNode(data1.goodsList[i].specs)); |
|
|
printerJobs.setSize(1, 1).print(this.delNode(data1.goodsList[i].specs)); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
printerJobs.setSize(1, 1).setLineSpacing(10).print(' '); |
|
|
printerJobs.setSize(1, 1).setLineSpacing(10).print(' '); |
|
|
printerJobs.setAlign('lt').setSize(2, 2) |
|
|
printerJobs.setAlign('lt').setSize(2, 2) |
|
|
@ -189,27 +197,29 @@ export default { |
|
|
} |
|
|
} |
|
|
printerJobs.setLineSpacing(30).setSize(1, 1).print(printerUtil.fillLine('-', 1, 32)); |
|
|
printerJobs.setLineSpacing(30).setSize(1, 1).print(printerUtil.fillLine('-', 1, 32)); |
|
|
printerJobs.setAlign('lt').print('配 送 费:' + data1.deliveryFee); |
|
|
printerJobs.setAlign('lt').print('配 送 费:' + data1.deliveryFee); |
|
|
if(data1.packageFee > 0){ |
|
|
if (data1.packageFee > 0) { |
|
|
printerJobs.print('打 包 费:' + data1.packageFee); |
|
|
printerJobs.print('打 包 费:' + data1.packageFee); |
|
|
} |
|
|
} |
|
|
printerJobs.print('商品金额:' + data1.goodsAmount); |
|
|
printerJobs.print('商品金额:' + data1.goodsAmount); |
|
|
if(data1.userCoupon && data1.userCoupon.length >0){ |
|
|
if (data1.userCoupon && data1.userCoupon.length > 0) { |
|
|
printerJobs.print('优 惠 券:-' + data1.userCoupon[0].discountAmount); |
|
|
printerJobs.print('优 惠 券:-' + data1.userCoupon[0].discountAmount); |
|
|
} |
|
|
} |
|
|
if(data1.freeAmount > 0){ |
|
|
if (data1.freeAmount > 0) { |
|
|
printerJobs.print('锦鲤免单:-' + data1.freeAmount); |
|
|
printerJobs.print('锦鲤免单:-' + data1.freeAmount); |
|
|
} |
|
|
} |
|
|
printerJobs.print('合计金额:' + ((data1.goodsAmount + data1.deliveryFee + data1.packageFee).toFixed(2))); |
|
|
printerJobs.print('合计金额:' + ((data1.goodsAmount + data1.deliveryFee + data1.packageFee).toFixed(2))); |
|
|
if(data1.mallRefundRecord != null){ |
|
|
if (data1.mallRefundRecord != null) { |
|
|
printerJobs.print('应退金额:' + data1.totalAmount); |
|
|
printerJobs.print('应退金额:' + data1.totalAmount); |
|
|
}else{ |
|
|
} else { |
|
|
printerJobs.print('实付金额:' + data1.totalAmount); |
|
|
printerJobs.print('实付金额:' + data1.totalAmount); |
|
|
} |
|
|
} |
|
|
printerJobs.setSize(2, 2).print('备注:' + data1.remark); |
|
|
printerJobs.setSize(2, 2).print('备注:' + data1.remark); |
|
|
printerJobs.lineFeed(1); |
|
|
printerJobs.lineFeed(1); |
|
|
if(data1.mallRefundRecord != null){ |
|
|
if (data1.mallRefundRecord != null) { |
|
|
printerJobs.setAlign('lt').setLineSpacing(30).print( |
|
|
printerJobs.setAlign('lt').setLineSpacing(30).print( |
|
|
'退款原因:' + (data1.mallRefundRecord == null ? ' ' : data1.mallRefundRecord[0].reason) |
|
|
'退款原因:' + (data1.mallRefundRecord == null ? ' ' : this.getCancelReasonDescription(data1.mallRefundRecord[0].reason) + ' ' + this |
|
|
|
|
|
.getRefundTypeText(data1.mallRefundRecord[0]) + '|' + this.getRefundReasonTypeText(data1 |
|
|
|
|
|
.mallRefundRecord[0])) |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
printerJobs.setSize(1, 1).setLineSpacing(30).print(printerUtil.fillLine('-', 1, 32)); |
|
|
printerJobs.setSize(1, 1).setLineSpacing(30).print(printerUtil.fillLine('-', 1, 32)); |
|
|
@ -218,6 +228,39 @@ export default { |
|
|
let buffer = printerJobs.buffer(); |
|
|
let buffer = printerJobs.buffer(); |
|
|
this.sendPrint(buffer, onDone); |
|
|
this.sendPrint(buffer, onDone); |
|
|
}, |
|
|
}, |
|
|
|
|
|
getCancelReasonDescription(reason) { |
|
|
|
|
|
// 处理空值和null
|
|
|
|
|
|
if (reason == null || reason === '') { |
|
|
|
|
|
return ''; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 尝试查找中文冒号(:)
|
|
|
|
|
|
const chineseColonIndex = reason.indexOf(':'); |
|
|
|
|
|
|
|
|
|
|
|
// 确定实际存在的冒号位置(取第一个出现的冒号)
|
|
|
|
|
|
let colonIndex = -1; |
|
|
|
|
|
if (chineseColonIndex !== -1) { |
|
|
|
|
|
colonIndex = chineseColonIndex; |
|
|
|
|
|
} else if (englishColonIndex !== -1) { |
|
|
|
|
|
colonIndex = englishColonIndex; |
|
|
|
|
|
} |
|
|
|
|
|
return colonIndex !== -1 ? reason.substring(colonIndex +1) : ''; |
|
|
|
|
|
}, |
|
|
|
|
|
getRefundTypeText(item) { |
|
|
|
|
|
if (!item) return ''; |
|
|
|
|
|
if (item.refundType == 1) return '退商品'; |
|
|
|
|
|
if (item.refundType == 2) return '退配送费'; |
|
|
|
|
|
return '全额退款'; |
|
|
|
|
|
}, |
|
|
|
|
|
getRefundReasonTypeText(item) { |
|
|
|
|
|
if (!item) return ''; |
|
|
|
|
|
if (item.refundTypeStatus == 1) return '商家原因'; |
|
|
|
|
|
if (item.refundTypeStatus == 2) return '配送员原因'; |
|
|
|
|
|
if (item.refundTypeStatus == 3) { |
|
|
|
|
|
return item.linkId && String(item.linkId).indexOf('W') != -1 ? '配送员原因' : '商家原因'; |
|
|
|
|
|
} |
|
|
|
|
|
return '平台退款'; |
|
|
|
|
|
}, |
|
|
// 去除字符串中的 Emoji 表情
|
|
|
// 去除字符串中的 Emoji 表情
|
|
|
removeEmojis(str) { |
|
|
removeEmojis(str) { |
|
|
if (!str) return ''; |
|
|
if (!str) return ''; |
|
|
|