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