|
@@ -1,9 +1,9 @@
|
|
|
<template>
|
|
|
<photo-consumer
|
|
|
class="carousel-item"
|
|
|
- :src="watermark || base_img_url2 + (photo.resFilename ? photo.resFilename : photo.filename) + resize"
|
|
|
+ :src="watermark || base_img_url2 + (photo.resFilename && !name ? photo.resFilename : photo.filename) + resize"
|
|
|
>
|
|
|
- <img v-if="Math.abs(current - index) < 3" crossorigin="anonymous" @load="drawWatermark($event)" loading="lazy" :src="watermark || (base_img_url2 + (photo.resFilename ? photo.resFilename : photo.filename) + resize)" style="width: 100%;" />
|
|
|
+ <img v-if="Math.abs(current - index) < 3" crossorigin="anonymous" @load="drawWatermark($event, name)" loading="lazy" :src="watermark || (base_img_url2 + (photo.resFilename && !name ? photo.resFilename : photo.filename) + resize)" style="width: 100%;" />
|
|
|
<canvas ref="canvasRef" style="position: absolute;"></canvas>
|
|
|
<div class="tag-text" v-if="showTagBox" >
|
|
|
<span v-html="photo.growText"></span>
|
|
@@ -21,9 +21,8 @@ import { base_img_url2 } from "@/api/config";
|
|
|
import {imageCache,loadImage} from "./cacheImg.js"
|
|
|
import {dateFormat} from "@/utils/date_util.js"
|
|
|
import {pointToFormat} from "@/utils/util.js"
|
|
|
-import {drawTextInRect, drawBorderImageInRect, drawImageInRect, drawRectInRect, drawHorizontalTextList} from "./utils"
|
|
|
+import {drawTextInRect, drawBorderImageInRect, drawImageInRect, drawRectInRect, drawHorizontalTextList, drawTargetRectangles} from "./utils"
|
|
|
const resize = "?x-oss-process=image/resize,p_120/format,webp/quality,q_100";
|
|
|
-
|
|
|
const canvasRef = ref(null);
|
|
|
const watermark = ref(null)
|
|
|
const baseMapBig = ref(false)
|
|
@@ -48,6 +47,10 @@ const props = defineProps({
|
|
|
current:{
|
|
|
type: Number,
|
|
|
required: true
|
|
|
+ },
|
|
|
+ name:{
|
|
|
+ type: String,
|
|
|
+ default: ""
|
|
|
}
|
|
|
})
|
|
|
let img = null;
|
|
@@ -67,7 +70,28 @@ let data = {year:props.photo.uploadDate.substring(0,4),
|
|
|
uploadDate:props.photo.uploadDate,
|
|
|
}
|
|
|
|
|
|
-async function drawWatermark(event) {
|
|
|
+async function drawWatermark(event,name) {
|
|
|
+ console.log(name)
|
|
|
+ if(!name){
|
|
|
+ drawWatermark1(event)
|
|
|
+ }else{
|
|
|
+ drawTargetRectangles2(event.target,props.photo.watermarks.find(item=>item.name === name))
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function drawTargetRectangles2(img, obj) {
|
|
|
+ const canvas = canvasRef.value;
|
|
|
+ let scale = 3
|
|
|
+ canvas.width = img.width * scale;
|
|
|
+ canvas.height = img.height * scale;
|
|
|
+ ctx = canvas.getContext('2d');
|
|
|
+ ctx.scale(scale, scale)
|
|
|
+ ctx.drawImage(img, 0, 0, img.width, img.height);
|
|
|
+ drawTargetRectangles(ctx, obj, 4000,3000,img.width, img.height)
|
|
|
+ watermark.value = canvas.toDataURL();
|
|
|
+}
|
|
|
+
|
|
|
+async function drawWatermark1(event) {
|
|
|
img = event.target
|
|
|
await loadImage(props.photo.baseMap,"base_map_"+props.photo.treeId)
|
|
|
data.baseMap = imageCache.get("base_map_"+props.photo.treeId)
|
|
@@ -85,6 +109,7 @@ async function drawWatermark(event) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
function drawWatermark2(img,weather) {
|
|
|
const canvas = canvasRef.value;
|
|
|
let scale = 3
|