Browse Source

打印loading2024/7/9 13:35:39

hella_vue3
zhang_li 3 months ago
parent
commit
0d9f96fbe6
  1. 119
      src/pages/point/index.vue

119
src/pages/point/index.vue

@ -58,7 +58,7 @@
</view>
</view>
</view>
<view class="" style="position: fixed; width: 100%; bottom: 0rpx; left: 0px">
<view class="" style="position: fixed; width: 100%; bottom: 0rpx; left: 0px" v-show="isLoadFinish">
<button @click="printImage"
style="background: rgb(60, 156, 255) !important ; color: white; margin-top: 80rpx">打印</button>
</view>
@ -67,7 +67,7 @@
<script setup lang="ts">
import { ref, reactive, nextTick, createApp, watch } from 'vue'
import { onShow, onLoad } from '@dcloudio/uni-app'
import { onShow, onLoad, onUnload } from '@dcloudio/uni-app'
import { pathToBase64 } from '../../api/img-to-base64.js'
//
const htmlFileUrl = '/hybrid/html/point.html' // js
@ -75,10 +75,44 @@
const testModule = uni.requireNativePlugin('TestModule')
// #endif
const timer = ref(null)
const originData = ref([])
const data = ref([])
const newHtmlContent = ref('') // html
const isLoadFinish = ref(false)
const qrcodeRef = ref()
const getListData = () => {
nextTick(async () => {
//
const el = _this.$refs['qrcodeRef']
let str = ''
// #ifdef APP
el.forEach(async (item, index) => {
await item.canvasToTempFilePath({
success: async (res) => {
// base64
await pathToBase64(res.tempFilePath).then(base64 => {
_this.data[index].barcodeBase64 = base64
if (index == el.length - 1) {
_this.isLoadFinish = true
uni.hideLoading();
}
}).catch(err => {
console.log(err);
})
},
fail(err) {
console.log('err:::', err)
}
})
})
// #endif
})
}
// #ifdef APP
//
const printImage = () => {
@ -199,72 +233,29 @@
}
)
onLoad(option) {
uni.showLoading({
title: '加载中...',
mask: true
});
if (option.points) {
data.value = JSON.parse(option.points);
originData.value = JSON.parse(option.points);
}
}
onUnload(() => {
if (timer.value) {
clearTimeout(timer.value)
timer.value = null
}
})
onShow(() => {
//
// data.value = [
// {
// itemNumber: '555555',
// itemName: 'hahah',
// referenceOrderRow: '55',
// referenceOrderCode: '55',
// supplierCode: '555',
// packageCode: '9999-8888',
// amount: '55',
// barcodeString: 'HMQ;V1.0;Dwork1-line1;F;R2024-04-03T08:28:41;B20240403;PPN0403-000005;I399.960-12;Q5.000000;UEA;',
// barcodeBase64: ''
// },
// {
// itemNumber: '66',
// itemName: 'hahah',
// referenceOrderRow: '66',
// referenceOrderCode: '666',
// supplierCode: '66',
// packageCode: '66666',
// amount: '666666',
// barcodeString: 'HMQ;V1.0;Dwork1-line1;F;R2024-04-03T08:28:41;B20240403;PPN0403-000005;I399.960-12;Q5.000000;UEA;',
// barcodeBase64: ''
// },
// {
// itemNumber: '66',
// itemName: 'hahah',
// referenceOrderRow: '66',
// referenceOrderCode: '666',
// supplierCode: '66',
// packageCode: '66666',
// amount: '666666',
// barcodeString: 'HMQ;V1.0;Dwork1-line1;F;R2024-04-03T08:28:41;',
// barcodeBase64: ''
// }
// ]
nextTick(async () => {
//
const el = qrcodeRef.value
const str = ''
el.forEach(async (item, index) => {
await item.canvasToTempFilePath({
success: async (res) => {
// base64
await pathToBase64(res.tempFilePath)
.then((base64) => {
data.value[index].barcodeBase64 = base64
if (index == el.length - 1) {
isLoadFinish.value = true
}
})
.catch((err) => {
console.log(err)
})
},
fail(err) {
console.log('err:::', err)
}
})
})
})
timer.value = setTimeout(() => {
if (timer.value) {
clearTimeout(timer.value)
timer.value = null
}
data.value = originData.value
getListData()
}, 1000)
})
</script>

Loading…
Cancel
Save