钉钉小程序拍照+水印+保存本地+上传服务器
axml
<canvas style="position:fixed;top:100vh;left:100vw; width:{
{imgWidth}};height:{
{imgHeight}};" canvas-id="myCanvas" id="myCanvas" class="myCanvas"></canvas>
绝对定位 目的不影响页面美观
JS
// 拍照
dd.chooseImage({
sourceType: ['camera'],
success: (res) => {
const filePath = res.filePaths[0];
// 获取图片信息 宽高
dd.getImageInfo({
src: filePath,
success(res) {
dd.showLoading({content:'图片处理中...'});
const imgWidth = res.width;
const imgHeight = res.height;
that.setData({imgWidth,imgHeight});
ctx.drawImage(filePath, 0, 0, imgWidth, imgHeight);
ctx.setFontSize(50);
ctx.setFillStyle('red');
ctx.setTextAlign('left');
ctx.fillText('站址名称:&