uu
This commit is contained in:
parent
e82e92c6d9
commit
bc6d96fd0f
@ -116,6 +116,7 @@ function grayPixle(pix) {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
export function overwriteImageData(data) {
|
export function overwriteImageData(data) {
|
||||||
|
console.log("overwriteImageData data====", data)
|
||||||
let sendWidth = data.width,
|
let sendWidth = data.width,
|
||||||
sendHeight = data.height;
|
sendHeight = data.height;
|
||||||
const threshold = data.threshold || 180;
|
const threshold = data.threshold || 180;
|
||||||
@ -173,6 +174,7 @@ export function overwriteImageData(data) {
|
|||||||
*/
|
*/
|
||||||
export function sendDataToPrint(options, allUint8Array) {
|
export function sendDataToPrint(options, allUint8Array) {
|
||||||
const allLenth = allUint8Array.length;
|
const allLenth = allUint8Array.length;
|
||||||
|
console.log("====allLenth===", allLenth)
|
||||||
const writeArrayCopyer = allUint8Array.slice(0);
|
const writeArrayCopyer = allUint8Array.slice(0);
|
||||||
const print = (options, writeArray) => {
|
const print = (options, writeArray) => {
|
||||||
if (writeArray.length) {
|
if (writeArray.length) {
|
||||||
@ -244,6 +246,8 @@ export function getImageCommandArray(opt = {}, imageInfo = {}) {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
export function getPrintImageWriteArray(opt = {}, imageInfo = {}) {
|
export function getPrintImageWriteArray(opt = {}, imageInfo = {}) {
|
||||||
|
console.log('getPrintImageWriteArray:opt======', opt)
|
||||||
|
console.log('getPrintImageWriteArray:imageInfo=====', imageInfo)
|
||||||
const lineByLine = typeof opt.lineByLine !== 'boolean' ? true : opt.lineByLine;
|
const lineByLine = typeof opt.lineByLine !== 'boolean' ? true : opt.lineByLine;
|
||||||
const width = imageInfo.width;
|
const width = imageInfo.width;
|
||||||
let arr = imageInfo.array;
|
let arr = imageInfo.array;
|
||||||
|
|||||||
@ -37,7 +37,7 @@ export default {
|
|||||||
canvasId: 'shareCanvas',
|
canvasId: 'shareCanvas',
|
||||||
imgData: '',
|
imgData: '',
|
||||||
percentage: 0, // 打印进度
|
percentage: 0, // 打印进度
|
||||||
threshold: [200], // 阈值(值越大,图片打印越深)
|
threshold: 200, // 阈值(值越大,图片打印越深)
|
||||||
blueToothData: {
|
blueToothData: {
|
||||||
deviceId: '',
|
deviceId: '',
|
||||||
serviceId: '',
|
serviceId: '',
|
||||||
@ -56,20 +56,16 @@ export default {
|
|||||||
},
|
},
|
||||||
// 打印
|
// 打印
|
||||||
async handlePrint(){
|
async handlePrint(){
|
||||||
|
const that = this
|
||||||
showLoading('正在打印')
|
// showLoading('正在打印')
|
||||||
const pix = res.data;
|
|
||||||
const opt = {
|
const opt = {
|
||||||
...this.blueToothData,
|
...this.blueToothData,
|
||||||
onProgress: (percentage) => {
|
onProgress: (percentage) => {
|
||||||
this.setData({
|
console.log("打印进度====", percentage)
|
||||||
percentage,
|
that.percentage = percentage
|
||||||
});
|
|
||||||
},
|
},
|
||||||
lasterSuccess: () => {
|
lasterSuccess: () => {
|
||||||
this.setData({
|
that.percentage = 0
|
||||||
percentage: 0,
|
|
||||||
});
|
|
||||||
uni.showModal({
|
uni.showModal({
|
||||||
title: '提示',
|
title: '提示',
|
||||||
content: '数据已发送完,请检查打印的内容是否正常',
|
content: '数据已发送完,请检查打印的内容是否正常',
|
||||||
@ -79,18 +75,18 @@ export default {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('====this.imgData===', this.imgData)
|
||||||
//打印图片
|
//打印图片
|
||||||
printJob.printImage(
|
printJob.printImage(
|
||||||
opt,
|
opt,
|
||||||
// 将图片数据转成位图数据
|
// 将图片数据转成位图数据
|
||||||
printJob.overwriteImageData({
|
printJob.overwriteImageData({
|
||||||
threshold: threshold[0],
|
threshold: this.threshold,
|
||||||
imageData: this.imgData,
|
imageData: this.imgData,
|
||||||
width: this.canvasWidth,
|
width: this.canvasWidth,
|
||||||
height: this.canvasHeight,
|
height: this.canvasHeight,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
},
|
},
|
||||||
// 选择本地文件打印-- TODO
|
// 选择本地文件打印-- TODO
|
||||||
// chooseImage() {
|
// chooseImage() {
|
||||||
@ -168,7 +164,7 @@ export default {
|
|||||||
height = parseInt(that.canvasWidth * (res.height / res.width))
|
height = parseInt(that.canvasWidth * (res.height / res.width))
|
||||||
that.$emit("update:canvasHeight", height)
|
that.$emit("update:canvasHeight", height)
|
||||||
}
|
}
|
||||||
cxt.drawImage(res.path, 0, 0, that.canvasWidth, that.canvasHeight);
|
cxt.drawImage(res.path, 0, 0, that.canvasWidth, height);
|
||||||
console.log("开始绘制图片===")
|
console.log("开始绘制图片===")
|
||||||
cxt.draw(true, ()=> {
|
cxt.draw(true, ()=> {
|
||||||
console.log("绘制图片结束===")
|
console.log("绘制图片结束===")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user