This commit is contained in:
aihe 2024-06-26 23:14:41 +08:00
parent 9ade67d3aa
commit 5663896055
4 changed files with 33 additions and 18 deletions

View File

@ -68,9 +68,8 @@ export default {
}
prtInstance.setPagePrint()
let commond = prtInstance.getPrintCmd()
console.log("打印命令组装完成,开始打印=====", commond)
console.log("打印命令组装完成,开始打印=====")
printModule.print(commond)
that.showToast('数据发送成功,如果无法打印请重连设备重试')
resolve(true)
// await that.loadPrintProcess()
// printModule.printTestSimple(deviceId)
@ -97,12 +96,20 @@ export default {
if(!Array.isArray(imgsRes)) {
imgsRes = [imgsRes]
}
let cBl = false
if(conSta) {
await this.handlePrint(imgsRes)
return true
} else {
return false
showLoading('正在发送打印数据..')
try{
await this.handlePrint(imgsRes)
showToast('数据发送成功,如果无法打印请重连设备重试')
cBl = true
}catch(e){
console.log('callPrint 打印异常=======')
console.error(e)
}
hideLoading()
}
return cBl
}
}
}

View File

@ -19,7 +19,7 @@
<template v-slot:footer>
<view class="blcok-white-noradius">
<u-row>
<u-button @click="confirmPrint" type="primary" size="large" shape="square"
<u-button @click="confirmPrint" :disabled="allImgRes.length == 0" type="primary" size="large" shape="square"
custom-style="height:80rpx;font-size: 30rpx;border-radius: 14rpx;margin: 0 10rpx;">确认打印</u-button>
</u-row>
</view>
@ -72,6 +72,7 @@ export default {
imageUrl: [],
paperWidth: 600,
show: false,
allImgRes: []
}
},
mounted () {
@ -92,7 +93,7 @@ export default {
},
async startPrint({ imageUrl, paperWidth } = {}, preview = true) {
this.imageUrl = [] // 每次打印前,清空历史数据
this.allImgRes = []
// 默认先做预览
if(imageUrl.length > 0) {
if(!Array.isArray(imageUrl)){
@ -102,24 +103,30 @@ export default {
this.paperWidth = paperWidth || this.paperWidth
if(preview) {
this.previewModel.show = true
} else {
this.confirmPrint()
}
await promiseTimeout(450) // 保证页面节点渲染出来
await this.setAllImgRes()
!preview && this.confirmPrint()
} else {
this.showToast('缺少打印内容')
}
},
async confirmPrint(){
setAllImgRes(){
let that = this
let allRes = this.imageUrl.map((url, index)=> {
// !!!注意:必须修改。 canvas渲染的图必须修改url,否则渲染不出来
url = `${url}?t=${new Date().valueOf()}`
return this.$refs[`curCanvas${index}`][0].renderCanvasImg(url, this.paperWidth)
})
Promise.all(allRes).then(async (imgsRes)=> {
let res = await this.$refs.curPrint.callPrint({
imgsRes,
paperWidth: this.paperWidth
})
return Promise.all(allRes).then((imgsRes)=> {
that.allImgRes = imgsRes
return imgsRes
})
},
async confirmPrint(){
let res = await this.$refs.curPrint.callPrint({
imgsRes: this.allImgRes,
paperWidth: this.paperWidth
})
},
autoConnectCallback(bl){

View File

@ -3,7 +3,7 @@
"appid" : "__UNI__BCB0FB5",
"description" : "探路国际速运",
"versionName" : "1.0.0",
"versionCode" : "109",
"versionCode" : "1010",
"transformPx" : false,
/* 5+App特有相关 */
"app-plus" : {

View File

@ -46,7 +46,7 @@
</template>
<script>
import { USERKEY } from "@/store/actionKey"
import { getSessionLoginInfo, setSessionLoginInfo } from "@/session"
import { getSessionLoginInfo, setSessionLoginInfo, setSessionXToken } from "@/session"
import { encrypt } from "@/common/libs/jsencrypt_utils"
@ -81,6 +81,7 @@
const { submitParams } = this
this.showLoading()
try{
setSessionXToken() // 登录前先清除xtoke
await this.$store.dispatch(USERKEY.LOGIN, {
...submitParams,
...(submitParams.isEncrypt ? {