From 58558a2bc6570bf917950d9190d0758c3f118ab9 Mon Sep 17 00:00:00 2001 From: Zhukj <3262118957> Date: Mon, 20 Apr 2026 10:57:31 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E7=AC=AC=E4=B8=89?= =?UTF-8?q?=E4=B8=AA=E9=BB=98=E8=AE=A4=E6=96=87=E6=9C=AC=E6=A1=86=EF=BC=8C?= =?UTF-8?q?=E5=9B=BA=E5=AE=9A=E4=B8=89=E4=B8=AA=E6=96=87=E6=9C=AC=E6=A1=86?= =?UTF-8?q?=E5=9D=90=E6=A0=87=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 10 ++++++---- js/script.js | 51 ++++----------------------------------------------- 2 files changed, 10 insertions(+), 51 deletions(-) diff --git a/index.html b/index.html index bc15ada..1ee9fba 100644 --- a/index.html +++ b/index.html @@ -85,10 +85,12 @@
- -
姓名:
- -
编号:
+ +
企业:
+ +
姓名:
+ +
编号:
请点击上方「添加图片」按钮上传背景图
diff --git a/js/script.js b/js/script.js index 89949c5..d3b9fc5 100644 --- a/js/script.js +++ b/js/script.js @@ -11,6 +11,7 @@ const emptyTip = document.getElementById('emptyTip'); const input1 = document.getElementById('input1'); const input2 = document.getElementById('input2'); + const input3 = document.getElementById('input3'); const exportCanvas = document.getElementById('exportCanvas'); const longPressTip = document.getElementById('longPressTip'); const canvasArea = document.getElementById('canvasArea'); @@ -97,9 +98,10 @@ // 初始化输入框 initInput(input1); initInput(input2); + initInput(input3); - // 为原有两个输入框添加删除按钮 - [input1, input2].forEach(inputEl => { + // 为三个输入框添加删除按钮 + [input1, input2, input3].forEach(inputEl => { const deleteBtn = document.createElement('button'); deleteBtn.className = 'text-delete-btn'; deleteBtn.innerHTML = '×'; @@ -237,56 +239,11 @@ bgOpacitySlider.value = 100; bgOpacityValue.textContent = '100%'; updateBgImage(); - - // 创建初始文本输入框 - createInitialTextInputs(); }; img.src = e.target.result; }; reader.readAsDataURL(file); } - - // 创建初始文本输入框 - function createInitialTextInputs() { - const container = imageContainer; - const containerWidth = container.clientWidth; - const containerHeight = container.clientHeight; - - // 定义3个输入框的位置(像素值) - const inputs = [ - { left: 98, top: 232.945, text: '参会企业:' }, - { left: 98, top: 275.555, text: '姓名:' }, - { left: 98, top: 317.548, text: '编号:' } - ]; - - inputs.forEach((input, index) => { - const textEl = document.createElement('div'); - textEl.className = 'text-input'; - textEl.contentEditable = 'false'; - textEl.textContent = input.text; - - // 将像素位置转换为百分比 - const leftPercent = (input.left / containerWidth * 100); - const topPercent = (input.top / containerHeight * 100); - textEl.style.left = leftPercent + '%'; - textEl.style.top = topPercent + '%'; - - // 删除按钮 - const deleteBtn = document.createElement('button'); - deleteBtn.className = 'text-delete-btn'; - deleteBtn.innerHTML = '×'; - deleteBtn.addEventListener('click', (e) => { - e.stopPropagation(); - textEl.remove(); - }); - textEl.appendChild(deleteBtn); - - const inputLayer = container.querySelector('.preview-input-layer'); - inputLayer.appendChild(textEl); - - initInput(textEl); - }); - } // 添加文本输入框 function addTextInput() {