6.21提交

This commit is contained in:
zoujiandong
2025-06-21 17:43:26 +08:00
parent ce9158a8a0
commit 8f4ee464dc
7 changed files with 990 additions and 844 deletions
+36 -36
View File
@@ -42,7 +42,7 @@ function formatTime(date) {
}
// 点击按钮触发的事件
function tapBtn(e, _this, pageType) {
function tapBtn(e, _this, pageType,from) {
let btnType = e.target.dataset.type;
let c = {};
@@ -94,14 +94,14 @@ function formatTime(date) {
return;
// 保存
case 'save':
saveImg(_this, pageType);
saveImg(_this, pageType,from);
return;
default:
return;
}
}
function saveImg(_this, pageType) {
function saveImg(_this, pageType,from) {
let c = {};
if (pageType === 1) {
c.canvasHeight = 50;
@@ -164,51 +164,51 @@ function formatTime(date) {
ctx.drawImage(src, 0, 0, _this.data.canvasWidth, _this.data.canvasHeight);
ctx.draw();
_canvaseSaveToImg(_this);
_canvaseSaveToImg(_this,from);
}
},_this);
} else {
_canvaseSaveToImg(_this);
_canvaseSaveToImg(_this,from);
}
// }
}
function _canvaseSaveToImg(_this) {
function _canvaseSaveToImg(_this,from) {
// 调用微信canvas存为图片
wx.canvasToTempFilePath({
canvasId: 'myCanvas',
success: function (res) {
// _this.triggerEvent('dealImg',{
// img: res.tempFilePath,
// type:'upload'
// })
// 转图片成功,继续调用存储相册接口
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
})
}
_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转图片失败