2222
This commit is contained in:
@@ -321,7 +321,7 @@
|
||||
const fillTextToImgWx = (base64) => {
|
||||
let maskText = "@肝胆相照临床病例库";
|
||||
return new Promise((resolve, reject) => {
|
||||
wx.createSelectorQuery().in(instace.proxy)
|
||||
wx.createSelectorQuery().in(instace.proxy)
|
||||
.select("#pwatermarkCanvas")
|
||||
.fields({
|
||||
node: true,
|
||||
@@ -347,15 +347,15 @@
|
||||
let font = ""; //fontsize"px Arial";
|
||||
|
||||
let fontColor = "#fff";
|
||||
let strokeWidth = 3;
|
||||
let strokeWidth =10;
|
||||
uni.getImageInfo({
|
||||
src: base64,
|
||||
success: (imageRes) => {
|
||||
// 设置canvas宽高
|
||||
let scale =28;
|
||||
// (imageRes.width / 800) * 30 > 12
|
||||
// ? (imageRes.width / 800) * 30
|
||||
// : 12;
|
||||
//28;
|
||||
let scale =(imageRes.width / 800) * 30 > 12
|
||||
? (imageRes.width / 800) * 30
|
||||
: 12;
|
||||
font = scale + "px Arial";
|
||||
console.log(imageRes);
|
||||
canvas.width = imageRes.width;
|
||||
@@ -372,8 +372,8 @@
|
||||
|
||||
// 将图片绘制到canvas上
|
||||
ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
|
||||
let posXmargin = 10; //this.data.posXmargin // 自定义离左/右边的距离
|
||||
let posYmargin = 10; // this.data.posYmargin // 自定义离上/下边的距离
|
||||
let posXmargin =20; //this.data.posXmargin // 自定义离左/右边的距离
|
||||
let posYmargin = 20; // this.data.posYmargin // 自定义离上/下边的距离
|
||||
let randomNumber = 3; //Math.floor(Math.random() * (3 + 1));
|
||||
console.log("randomNumber:" + randomNumber);
|
||||
switch (randomNumber) {
|
||||
@@ -381,8 +381,7 @@
|
||||
let lt_x = posXmargin;
|
||||
let lt_y = posYmargin + textHeight;
|
||||
ctx.font = font;
|
||||
ctx.fillStyle = fontColor;
|
||||
ctx.storkStyle = "black";
|
||||
ctx.storkStyle = "#000";
|
||||
ctx.strokeWidth = strokeWidth;
|
||||
ctx.fillStyle = "#fff";
|
||||
ctx.fillText(maskText, lt_x, lt_y);
|
||||
@@ -399,6 +398,7 @@
|
||||
ctx.strokeWidth = strokeWidth;
|
||||
ctx.fillStyle = "#fff";
|
||||
ctx.fillText(maskText, lb_x, lb_y);
|
||||
|
||||
//ctx.restore()
|
||||
//ctx.save()
|
||||
break;
|
||||
@@ -411,7 +411,7 @@
|
||||
let rt_y = posYmargin + textHeight * 2;
|
||||
ctx.font = font;
|
||||
ctx.fillStyle = fontColor;
|
||||
ctx.strokeStyle = "black";
|
||||
ctx.strokeStyle = "#000";
|
||||
ctx.strokeWidth = strokeWidth;
|
||||
ctx.fillStyle = "#fff";
|
||||
ctx.fillText(maskText, rt_x, rt_y);
|
||||
@@ -420,17 +420,21 @@
|
||||
break;
|
||||
case 3: //右下角
|
||||
let rb_x =
|
||||
imgWidth - textWidth * 6 - posXmargin <= 0
|
||||
imgWidth - scale*10 - posXmargin <= 0
|
||||
? 10
|
||||
: imgWidth - 276- posXmargin;
|
||||
: imgWidth - scale*10 - posXmargin;
|
||||
console.log(rb_x)
|
||||
let rb_y = imgHeight - posYmargin;
|
||||
ctx.font = font;
|
||||
ctx.fillStyle = fontColor;
|
||||
ctx.strokeStyle = "black";
|
||||
ctx.strokeWidth = strokeWidth;
|
||||
ctx.strokeStyle = "#000";
|
||||
//ctx.strokeWidth = strokeWidth;
|
||||
ctx.fillStyle = "#fff";
|
||||
ctx.fillText(maskText, rb_x, rb_y);
|
||||
console.log('rb_x')
|
||||
console.log(rb_x)
|
||||
ctx.strokeText(maskText,rb_x, rb_y);
|
||||
ctx.fillText(maskText, rb_x, rb_y);
|
||||
|
||||
//ctx.restore()
|
||||
//ctx.save()
|
||||
break;
|
||||
@@ -460,6 +464,7 @@
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const fillTextToImg = (base64) => {
|
||||
const img = new Image();
|
||||
img.src = base64;
|
||||
@@ -610,8 +615,7 @@
|
||||
};
|
||||
Promise.all(promiseFun).then((res) => {
|
||||
uni.showToast({
|
||||
duration: 1000,
|
||||
message: "上传成功",
|
||||
title: "上传成功",
|
||||
icon:"none"
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user