liujq преди 2 седмици
родител
ревизия
4aab4b4bb3
променени са 1 файла, в които са добавени 47 реда и са изтрити 1 реда
  1. 47 1
      src/pagesRoom/dtl.jsx

+ 47 - 1
src/pagesRoom/dtl.jsx

@@ -748,6 +748,7 @@ class Index extends Component {
     ctx.fillStyle = "#fff"
     ctx.fill()
 
+
     let imgBg = cvs.createImage();
     // imgBg.src = require('./img/dtl/bg_room_dtl.jpg')
     imgBg.src = 'https://img.honglounews.com/20260107092402-3240.jpg_adm0?r='+ Math.random()
@@ -784,7 +785,6 @@ class Index extends Component {
     })
     ctx.drawImage(img4, 356, 828, 345, 286)
 
-
     that.drawCenterText(ctx, '#343434', curObj.title.length > 25 ? curObj.title.substring(0, 25) + '...' : curObj.title, 350, 460, '28px')
     if (str === 'hide') {
       that.drawCenterText(ctx, '#333', '详情咨询巴老师', 350, 255, 'normal bold 70px')
@@ -805,6 +805,28 @@ class Index extends Component {
     that.drawText(ctx, '#ff2400', curObj.price, 380, 390, 'normal bold 80px')
 
 
+     // 添加水印图片
+    let watermark = cvs.createImage();
+    watermark.src = 'https://img.honglounews.com/20260113025251-2897.png_adm0';
+    await new Promise(resolve => {
+      watermark.onload = resolve;
+    });
+    // 平铺图片
+    const tileSize = 175;
+    const canvasWidth = 700;
+    const canvasHeight = 1516;
+    const cols = Math.ceil(canvasWidth / tileSize);
+    const rows = Math.ceil(canvasHeight / tileSize);
+    ctx.globalAlpha = 0.7;
+    for (let y = 0; y < rows; y++) {
+      for (let x = 0; x < cols; x++) {
+        const destX = x * tileSize;
+        const destY = y * tileSize;
+        ctx.drawImage(watermark, destX, destY, tileSize, tileSize);
+      }
+    }
+    ctx.globalAlpha = 1.0;
+
     // let base64 = ctx.canvas.toDataURL("image/png")
     // that.setState({
     //   curShareCardImg: base64
@@ -818,6 +840,7 @@ class Index extends Component {
       img2 = null
       img3 = null
       img4 = null
+      watermark = null
       Taro.hideLoading()
     }, 6000)
 
@@ -944,6 +967,28 @@ class Index extends Component {
     that.drawText(ctx, '#ff2400', curObj.price, 380, 390, 'normal bold 80px')
 
 
+     // 添加水印图片
+    let watermark = cvs.createImage();
+    watermark.src = 'https://img.honglounews.com/20260113025251-2897.png_adm0';
+    await new Promise(resolve => {
+      watermark.onload = resolve;
+    });
+    // 平铺图片
+    const tileSize = 175;
+    const canvasWidth = 700;
+    const canvasHeight = 1516;
+    const cols = Math.ceil(canvasWidth / tileSize);
+    const rows = Math.ceil(canvasHeight / tileSize);
+    ctx.globalAlpha = 0.7;
+    for (let y = 0; y < rows; y++) {
+      for (let x = 0; x < cols; x++) {
+        const destX = x * tileSize;
+        const destY = y * tileSize;
+        ctx.drawImage(watermark, destX, destY, tileSize, tileSize);
+      }
+    }
+    ctx.globalAlpha = 1.0;
+
     // let base64 = ctx.canvas.toDataURL("image/png")
     // that.setState({
     //   curShareCardImg: base64
@@ -957,6 +1002,7 @@ class Index extends Component {
       img2 = null
       img3 = null
       img4 = null
+      watermark = null
       Taro.hideLoading()
     }, 6000)