优化小程序码的生成

This commit is contained in:
zhl 2021-06-10 13:41:25 +08:00
parent accc2df829
commit 3a17a007e5

View File

@ -506,21 +506,20 @@ export default class extends Vue {
const canvas = document.getElementById('qr_canvas') as HTMLCanvasElement const canvas = document.getElementById('qr_canvas') as HTMLCanvasElement
if (!canvas) { if (!canvas) {
return false return false
} else { }
// //
const context = canvas.getContext('2d') const context = canvas.getContext('2d')
context!.clearRect(0, 0, QR_WIDTH, QR_WIDTH) context!.clearRect(0, 0, QR_WIDTH, QR_WIDTH)
const img = new Image() const img = new Image()
img.src = this.qrUrl + '?t=' + new Date().getDate() img.src = this.qrUrl + '?t=' + new Date().getDate()
img.setAttribute('crossOrigin', 'Anonymous') img.setAttribute('crossOrigin', 'Anonymous')
// //
img.onload = () => { img.onload = () => {
if (img.complete) { if (img.complete) {
// //
context!.drawImage(img, 0, 0, QR_WIDTH, QR_WIDTH) context!.drawImage(img, 0, 0, QR_WIDTH, QR_WIDTH)
if (this.shopLogo) { if (this.shopLogo) {
this.drawLogo(context) this.drawLogo(context)
}
} }
} }
} }