|
@@ -290,13 +290,27 @@ Page({
|
|
bgImg.src = this.data.configure.bgImg
|
|
bgImg.src = this.data.configure.bgImg
|
|
bgImg.onload = () => {
|
|
bgImg.onload = () => {
|
|
ctx.drawImage(bgImg, 0, 0, 375, 300);
|
|
ctx.drawImage(bgImg, 0, 0, 375, 300);
|
|
- ctx.fillStyle = `${this.data.configure.toColor}`;
|
|
|
|
ctx.font = `${this.data.configure.fromFontSize/2}px PingFang`;
|
|
ctx.font = `${this.data.configure.fromFontSize/2}px PingFang`;
|
|
- ctx.fillText(this.data.configure.toText, this.data.configure.templateBase.toLeft / 2, this.data.configure.templateBase.toTop / 2 + this.data.configure.fromFontSize / 2)
|
|
|
|
|
|
+ ctx.fillStyle = `${this.data.configure.toColor}`;
|
|
|
|
+ let toLeft = 0
|
|
|
|
+ if (this.data.configure.toTextAlign == 'left') {
|
|
|
|
+ toLeft = this.data.configure.templateBase.toLeft / 2
|
|
|
|
+ } else if (this.data.configure.toTextAlign == 'right') {
|
|
|
|
+ toLeft = this.data.configure.templateBase.toLeft / 2 + (this.data.configure.templateBase.toWidth / 2 - ctx.measureText(this.data.configure.toText).width)
|
|
|
|
+ } else if (this.data.configure.toTextAlign == 'center') {
|
|
|
|
+ toLeft = this.data.configure.templateBase.toLeft / 2 + ((this.data.configure.templateBase.toWidth / 2 - ctx.measureText(this.data.configure.toText).width) / 2)
|
|
|
|
+ }
|
|
|
|
+ ctx.fillText(this.data.configure.toText, toLeft, this.data.configure.templateBase.toTop / 2 + this.data.configure.fromFontSize / 2)
|
|
ctx.fillStyle = `${this.data.configure.fromColor}`;
|
|
ctx.fillStyle = `${this.data.configure.fromColor}`;
|
|
- ctx.fillText(this.data.configure.fromText, this.data.configure.templateBase.fromLeft / 2, this.data.configure.templateBase.fromTop / 2 + this.data.configure.toFontSize / 2)
|
|
|
|
- console.log(this.data.configure.toText, this.data.configure.templateBase.toLeft / 2, this.data.configure.templateBase.toTop / 2);
|
|
|
|
- console.log(this.data.configure.fromText, this.data.configure.templateBase.fromLeft / 2, this.data.configure.templateBase.fromTop / 2);
|
|
|
|
|
|
+ let fromLeft = 0
|
|
|
|
+ if (this.data.configure.fromTextAlign == 'left') {
|
|
|
|
+ fromLeft = this.data.configure.templateBase.fromLeft / 2
|
|
|
|
+ } else if (this.data.configure.fromTextAlign == 'right') {
|
|
|
|
+ fromLeft = this.data.configure.templateBase.fromLeft / 2 + (this.data.configure.templateBase.fromWidth / 2 - ctx.measureText(this.data.configure.fromText).width)
|
|
|
|
+ } else if (this.data.configure.fromTextAlign == 'center') {
|
|
|
|
+ fromLeft = this.data.configure.templateBase.fromLeft / 2 + ((this.data.configure.templateBase.fromWidth / 2 - ctx.measureText(this.data.configure.fromText).width) / 2)
|
|
|
|
+ }
|
|
|
|
+ ctx.fillText(this.data.configure.fromText, fromLeft, this.data.configure.templateBase.fromTop / 2 + this.data.configure.toFontSize / 2)
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
wx.canvasToTempFilePath({
|
|
wx.canvasToTempFilePath({
|
|
canvas: canvas,
|
|
canvas: canvas,
|