8.26提交

This commit is contained in:
zoujiandong
2025-08-26 17:21:01 +08:00
parent d292fec408
commit 7799c04883
7 changed files with 181 additions and 68 deletions
+62 -46
View File
@@ -162,9 +162,13 @@ function formatTime(date) {
ctx.drawImage(_this.data.background, 0, 0, _this.data.canvasWidth, _this.data.canvasHeight);
// 覆盖上画的内容
ctx.drawImage(src, 0, 0, _this.data.canvasWidth, _this.data.canvasHeight);
ctx.draw();
//let that=this
ctx.draw(false,function(){
_canvaseSaveToImg(_this,from);
});
_canvaseSaveToImg(_this,from);
}
},_this);
} else {
@@ -174,51 +178,63 @@ function formatTime(date) {
}
function _canvaseSaveToImg(_this,from) {
let that=_this;
console.log(from)
console.log(_this);
// 调用微信canvas存为图片
wx.canvasToTempFilePath({
canvasId: 'myCanvas',
success: function (res) {
_this.triggerEvent('afterhandlePaint',{
imgSrc: res.tempFilePath,
name:from
})
// 转图片成功,继续调用存储相册接口
// wx.saveImageToPhotosAlbum({
// filePath: res.tempFilePath,
// // 存储成功
// success: function (r) {
// wx.hideLoading();
// wx.showToast({
// title: '保存成功',
// })
// _this.setData({
// saving: false,
// showPaint:false
// })
// },
// // 失败弹窗
// fail: function (res) {
// wx.hideLoading();
// wx.showToast({
// title: '保存失败',
// icon: 'loading',
// })
// _this.setData({
// saving: false,
// showPaint:false
// })
// }
// })
},
fail: function (res) {
// canvas转图片失败
wx.hideLoading();
wx.showToast({
icon: 'loading',
title: '失败',
})
}
},_this)
setTimeout(()=>{
wx.canvasToTempFilePath({
canvasId: 'myCanvas',
fileType:'png',
success: function (res) {
// wx.previewImage({
// urls:[res.tempFilePath],
// current:res.tempFilePath
// })
that.triggerEvent('afterhandlePaint',{
imgSrc: res.tempFilePath,
name:from
})
// 转图片成功,继续调用存储相册接口
// wx.saveImageToPhotosAlbum({
// filePath: res.tempFilePath,
// // 存储成功
// success: function (r) {
// wx.hideLoading();
// wx.showToast({
// title: '保存成功',
// })
// _this.setData({
// saving: false,
// showPaint:false
// })
// },
// // 失败弹窗
// fail: function (res) {
// wx.hideLoading();
// wx.showToast({
// title: '保存失败',
// icon: 'loading',
// })
// _this.setData({
// saving: false,
// showPaint:false
// })
// }
// })
},
fail: function (res) {
// canvas转图片失败
wx.hideLoading();
wx.showToast({
icon: 'loading',
title: '失败',
})
}
},that)
},1500)
}
module.exports = {