|
@@ -42,7 +42,7 @@ Component({
|
|
|
return false
|
|
|
},
|
|
|
poster: function () {
|
|
|
- const ctx = wx.createCanvasContext('myCanvas');
|
|
|
+
|
|
|
const that = this;
|
|
|
wx.showLoading({
|
|
|
title: '海报生成中',
|
|
@@ -55,32 +55,15 @@ Component({
|
|
|
success: res => {
|
|
|
this.setData({
|
|
|
QRCodeImagePath: res.tempFilePath
|
|
|
+ },()=>{
|
|
|
+ this.saveAvatar();
|
|
|
})
|
|
|
}
|
|
|
});
|
|
|
- wx.downloadFile({
|
|
|
- url: that.data.avatar,
|
|
|
- success: res => {
|
|
|
- this.setData({
|
|
|
- avatar: res.tempFilePath
|
|
|
- })
|
|
|
- }
|
|
|
- });
|
|
|
- // 下载icon
|
|
|
- if (this.data.shareType === 'works') {
|
|
|
- wx.downloadFile({
|
|
|
- url: that.data.iconImg,
|
|
|
- success: res => {
|
|
|
- this.setData({
|
|
|
- iconImg: res.tempFilePath
|
|
|
- })
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- this.makeImage(ctx);
|
|
|
})
|
|
|
},
|
|
|
- makeImage: function (ctx) {
|
|
|
+ makeImage: function () {
|
|
|
+ const ctx = wx.createCanvasContext('myCanvas');
|
|
|
// 画出背景和相同内容
|
|
|
if (this.data.shareType === 'works') {
|
|
|
ctx.drawImage('../../../static/image/works_poster.jpg', 0, 0, 1200, 2100, 0, 0, 600, 1050); //插入图片
|
|
@@ -143,7 +126,8 @@ Component({
|
|
|
ctx.fillText('朗朗读书声,是世界上最美妙的声音', (300 - ctx.measureText('朗朗读书声,是世界上最美妙的声音').width) / 2, 327.5)
|
|
|
}
|
|
|
console.log('花二维码')
|
|
|
- console.log(this.data.QRCodeImagePath)
|
|
|
+ console.log(this.data)
|
|
|
+ console.log(this.data.avatar)
|
|
|
ctx.drawImage(this.data.QRCodeImagePath, 35, 353, 90, 90);
|
|
|
ctx.draw();
|
|
|
setTimeout(() => {
|
|
@@ -166,9 +150,37 @@ Component({
|
|
|
wx.hideLoading();
|
|
|
}
|
|
|
})
|
|
|
- }, 200)
|
|
|
+ }, 400)
|
|
|
|
|
|
},
|
|
|
+ saveIcon: function(){
|
|
|
+ wx.downloadFile({
|
|
|
+ url: this.data.iconImg,
|
|
|
+ success: res => {
|
|
|
+ this.setData({
|
|
|
+ iconImg: res.tempFilePath
|
|
|
+ },()=>{
|
|
|
+ this.makeImage();
|
|
|
+ })
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ saveAvatar: function(){
|
|
|
+ wx.downloadFile({
|
|
|
+ url: this.data.avatar,
|
|
|
+ success: res => {
|
|
|
+ this.setData({
|
|
|
+ avatar: res.tempFilePath
|
|
|
+ },()=>{
|
|
|
+ if (this.data.shareType === 'works'){
|
|
|
+ this.saveIcon();
|
|
|
+ } else {
|
|
|
+ this.makeImage();
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
share: function (data) {
|
|
|
console.log(data)
|
|
|
if (this.data.shareType === 'works') {
|