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() {