|
|
@ -53,7 +53,7 @@ |
|
|
|
export default { |
|
|
|
name: 'Promotion', |
|
|
|
computed: { |
|
|
|
...mapState(['userInfo']), |
|
|
|
...mapState(['userInfo', 'promotionUrl']), |
|
|
|
}, |
|
|
|
data() { |
|
|
|
return { |
|
|
@ -65,6 +65,7 @@ |
|
|
|
show : false, |
|
|
|
bgColor : '#fe6c17', |
|
|
|
load : false, |
|
|
|
index : 0, |
|
|
|
} |
|
|
|
}, |
|
|
|
onShow() { |
|
|
@ -86,7 +87,9 @@ |
|
|
|
clickTab(){ |
|
|
|
this.bgColor = '#de0917' |
|
|
|
this.show = true |
|
|
|
if(this.load){ |
|
|
|
if(this.promotionUrl){ |
|
|
|
this.imagePath = this.promotionUrl |
|
|
|
}else if(this.load){ |
|
|
|
uni.showLoading({ |
|
|
|
title: "拼命绘画中..." |
|
|
|
}) |
|
|
@ -134,13 +137,25 @@ |
|
|
|
const bgImage = canvas.createImage() |
|
|
|
bgImage.src = this.configList.qr_image |
|
|
|
|
|
|
|
const coderImage = canvas.createImage() |
|
|
|
coderImage.src = this.baseUrl + this.url |
|
|
|
|
|
|
|
bgImage.onload = () => { |
|
|
|
|
|
|
|
canvas.width = bgImage.width |
|
|
|
canvas.height = bgImage.height |
|
|
|
|
|
|
|
ctx.drawImage(bgImage, |
|
|
|
0, 0, bgImage.width, bgImage.height) |
|
|
|
0, 0, bgImage.width, bgImage.height) |
|
|
|
|
|
|
|
|
|
|
|
//二维码图片 |
|
|
|
coderImage.onload = () => { |
|
|
|
|
|
|
|
ctx.drawImage(coderImage, |
|
|
|
canvas.width / 2 - 175, canvas.height / 2 - 100, 350, 350) |
|
|
|
this.canvasToTempFilePath() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//用户图片 |
|
|
@ -163,36 +178,30 @@ |
|
|
|
let s = this.title || '' |
|
|
|
// ctx.fillText(s, canvas.width / Ratio - s.length * 11, 50); |
|
|
|
|
|
|
|
//二维码图片 |
|
|
|
const coderImage = canvas.createImage() |
|
|
|
coderImage.src = this.baseUrl + this.url |
|
|
|
coderImage.onload = () => { |
|
|
|
ctx.drawImage(coderImage, |
|
|
|
canvas.width / 2 - 175, canvas.height / 2 - 100, 350, 350) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 绘制完成后存储路径 |
|
|
|
|
|
|
|
setTimeout(() => { |
|
|
|
wx.canvasToTempFilePath({ |
|
|
|
x: 0, |
|
|
|
y: 0, |
|
|
|
width: this.canvas.width, |
|
|
|
height: this.canvas.height, |
|
|
|
canvas, |
|
|
|
success: (res) => { |
|
|
|
var tempFilePath = res.tempFilePath; |
|
|
|
this.imagePath = tempFilePath |
|
|
|
uni.hideLoading() |
|
|
|
this.load = false |
|
|
|
} |
|
|
|
}); |
|
|
|
}, 600); |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}, |
|
|
|
canvasToTempFilePath(){ |
|
|
|
// 绘制完成后存储路径 |
|
|
|
setTimeout(() => { |
|
|
|
wx.canvasToTempFilePath({ |
|
|
|
x: 0, |
|
|
|
y: 0, |
|
|
|
width: this.canvas.width, |
|
|
|
height: this.canvas.height, |
|
|
|
canvas : this.canvas, |
|
|
|
success: (res) => { |
|
|
|
var tempFilePath = res.tempFilePath; |
|
|
|
this.imagePath = tempFilePath |
|
|
|
|
|
|
|
this.$store.commit('setPromotionUrl', res.tempFilePath) |
|
|
|
|
|
|
|
uni.hideLoading() |
|
|
|
this.load = false |
|
|
|
} |
|
|
|
}); |
|
|
|
}, 200); |
|
|
|
}, |
|
|
|
back() { |
|
|
|
uni.navigateBack(-1) |
|
|
|
}, |
|
|
|