8.26提交
This commit is contained in:
+62
-46
@@ -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 = {
|
||||
|
||||
Reference in New Issue
Block a user