This commit is contained in:
aihe 2024-08-09 01:05:36 +08:00
parent 34f121f4ca
commit 262f553ac5
4 changed files with 16 additions and 10 deletions

View File

@ -21,6 +21,7 @@ import * as canvasUtil from "@/common/canvasUtil"
import tanexPrinterUniSdk from './nativePrint/tanexPrinterUniSdk'
import printModule from './nativePrint/print'
import dayjs from "dayjs"
import { Base64 } from "js-base64"
export default {
props:{
@ -77,13 +78,17 @@ export default {
})
},
// 直接传打印指令给打印机
handlePrintCommandData(str){
handlePrintCommandData(bs64Str){
let that = this
return new Promise((resolve, reject)=> {
let { bl, deviceId } = that.checkPrintParam()
if(!bl) {
return reject('打印参数校验不通过')
}
debugger
printModule.sendData(str)
let cmdStr = Base64.decode(bs64Str)
printModule.sendData(cmdStr)
resolve(true)
})
},
checkPrintParam() {
let msg = '', bl = false

View File

@ -84,7 +84,7 @@ export default {
async confirmPrint(opt = { }){
let { imageUrl, prtCmdData } = opt
imageUrl = imageUrl || this.imageUrl || []
prtCmdData = prtCmdData || ''
prtCmdData = encodeURIComponent(prtCmdData || '')
if(imageUrl.length == 0 && !prtCmdData) {
this.showToast('缺少打印内容')
} else {

View File

@ -17,7 +17,8 @@
"dayjs": "^1.11.10",
"file-saver": "2.0.5",
"pdf-lib": "1.17.1",
"vconsole": "3.15.1"
"vconsole": "3.15.1",
"js-base64": "3.7.7"
},
"dcloudext": {
"category": [

View File

@ -32,7 +32,7 @@ export default {
methods: {
initData(){
let urls = this.queryOption?.imageUrl?.split(",")
let prtCmdData = this.queryOption?.prtCmdData || ''
let prtCmdData = decodeURIComponent(this.queryOption?.prtCmdData || '')
this.pageLoading = false
if(urls?.length > 0) {
this.$refs.curPrint.startPrint({