1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| drawImageToCanvas() { const systemInfo = uni.getSystemInfoSync(); const canvasWidth = systemInfo.windowWidth; const canvasHeight = systemInfo.windowHeight; const context = uni.createCanvasContext('myCanvas', this);
context.drawImage('/static/image/share.png', 0, 0, canvasWidth, canvasHeight); context.setFillStyle('#D43030'); context.setFontSize(32); context.fillText(this.invitationCode, canvasWidth / 2 - 50, canvasHeight / 2 * 0.84); context.drawImage( this.qrcode, canvasWidth / 3 - 20, canvasHeight / 2, canvasWidth / 1 , canvasWidth / 2 ); context.save(); context.draw(true, setTimeout(() => { uni.canvasToTempFilePath({ canvasId: 'myCanvas', success: (res) => { this.show = false; this.ImagePath = res.tempFilePath; uni.hideLoading(); }, fail: (err) => { uni.hideLoading(); console.error(err); } }, this); }, 1000)); }
|