| xqd
@@ -19,7 +19,8 @@ Page({
|
|
|
shareImage: '',
|
|
|
shareText: '',
|
|
|
shareTextPosX: '',
|
|
|
- shareTextPosY: ''
|
|
|
+ shareTextPosY: '',
|
|
|
+ shareTempFilePath: ''
|
|
|
},
|
|
|
onLoad: function () {
|
|
|
wx.getSystemInfo({
|
| xqd
@@ -49,6 +50,14 @@ Page({
|
|
|
shareTextPosX: res.data.shareTextPosX,
|
|
|
shareTextPosY: res.data.shareTextPosY,
|
|
|
})
|
|
|
+ wx.downloadFile({
|
|
|
+ url: res.data.shareImage,
|
|
|
+ success: res => {
|
|
|
+ this.setData({
|
|
|
+ shareImage: res.tempFilePath
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
})
|
| xqd
@@ -198,26 +207,55 @@ Page({
|
|
|
ctx.textAlign = 'center'
|
|
|
// ctx.fillText('我已成功打卡14天', width / 2, height / 2 - 7)
|
|
|
ctx.fillText(text, text_x, text_y)
|
|
|
- ctx.draw()
|
|
|
+ ctx.draw(false, this.getTempFilePath)
|
|
|
},
|
|
|
togglePopup() {
|
|
|
this.setData({
|
|
|
showPopup: !this.data.showPopup
|
|
|
});
|
|
|
},
|
|
|
- handleShare() {
|
|
|
+ getTempFilePath: function () {
|
|
|
wx.canvasToTempFilePath({
|
|
|
canvasId: 'shareCanvas',
|
|
|
success: (res) => {
|
|
|
- wx.saveImageToPhotosAlbum({
|
|
|
- filePath: res.tempFilePath,
|
|
|
- success: () => {
|
|
|
- wx.showToast({
|
|
|
- title: '已保存到相册'
|
|
|
- })
|
|
|
- }
|
|
|
+ this.setData({
|
|
|
+ shareTempFilePath: res.tempFilePath
|
|
|
})
|
|
|
}
|
|
|
- }, this)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ handleShare() {
|
|
|
+ // wx.canvasToTempFilePath({
|
|
|
+ // canvasId: 'shareCanvas',
|
|
|
+ // success: (res) => {
|
|
|
+ // wx.saveImageToPhotosAlbum({
|
|
|
+ // filePath: res.tempFilePath,
|
|
|
+ // success: () => {
|
|
|
+ // wx.showToast({
|
|
|
+ // title: '已保存到相册'
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ // }, this)
|
|
|
+ if (!this.data.shareTempFilePath) {
|
|
|
+ wx.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: '图片绘制中,请稍后重试',
|
|
|
+ showCancel: false
|
|
|
+ })
|
|
|
+ }
|
|
|
+ wx.saveImageToPhotosAlbum({
|
|
|
+ filePath: this.data.shareTempFilePath,
|
|
|
+ success: (res) => {
|
|
|
+
|
|
|
+ },
|
|
|
+ complete: res => {
|
|
|
+ this.setData({
|
|
|
+ showPopup: false
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
+
|
|
|
})
|