3 changed files with 68 additions and 1 deletions
-
3uniapp_project_code/src/pages/index/standby.vue
-
19uniapp_project_code/src/pages/pay/index.vue
-
47uniapp_project_code/src/utils/print.js
@ -0,0 +1,47 @@ |
|||
function resetOXPrintInfo(printInfo) { |
|||
let data = []; |
|||
// 遍历 printInfo 中的 goods_data 数组,对每个商品对象进行处理
|
|||
let line_46mm = "-------------------------------\n"; |
|||
data.push(line_46mm); |
|||
for (let item of printInfo.goods_data) { |
|||
let row = item.name + ";" + item.nums + ";" + item.price + ";" + (item.price*item.nums).toFixed(2); |
|||
data.push(row); |
|||
} |
|||
data.push(line_46mm); |
|||
data.push(`金额合计:${printInfo.amount||'-'}\n`); |
|||
data.push(`交易时间:${printInfo.time||'-'}\n`); |
|||
data.push(`订单号:${printInfo.order_no||'-'}\n`); |
|||
data.push(`门店:${printInfo.venue_name||'-'}\n`); |
|||
|
|||
//如:["乒乓球;5;3.99;19.95"],每个元素代表一行,每行的内容用分号隔开. 46mm打印机约定最大4列.其它纸张需要另做兼容.
|
|||
|
|||
// 示例
|
|||
// ['-------------------------------\n', '南瓜1Kg;1;0.01;0.01', '乔丹篮球;2;0.01;0.02', '-------------------------------\n', '金额合计:0.03\n', '交易时间:-\n', '订单号:-\n', '门店:-\n']
|
|||
return data; |
|||
} |
|||
|
|||
const testPrintInfo = { |
|||
"goods_data": [ |
|||
{ |
|||
"id": 31, |
|||
"name": "南瓜1Kg", |
|||
"nums": 1, |
|||
"price": 0.01, |
|||
"unit": "个" |
|||
}, |
|||
{ |
|||
"id": 32, |
|||
"name": "乔丹篮球", |
|||
"nums": 2, |
|||
"price": 0.01, |
|||
"unit": "个" |
|||
} |
|||
], |
|||
"amount": 0.03 |
|||
} |
|||
|
|||
|
|||
export default { |
|||
resetOXPrintInfo, |
|||
testPrintInfo, |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue