const productDataMap = { "JavaWeb": { title: "JavaWeb", img: "images/内蒙古工业大学夜晚.jpg", content: `

产品特点

优势功能

` }, "实验室SaS": { title: "实验室SaS", img: "images/内蒙古工业大学夜晚.jpg", content: `

产品特点

优势功能

` }, "坤班官网": { title: "坤班官网", img: "images/内蒙古工业大学夜晚.jpg", content: `

产品特点

优势功能

` }, "UE5": { title: "UE5", img: "images/内蒙古工业大学夜晚.jpg", content: `

产品特点

优势功能

` }, "其他": { title: "其他产品", img: "images/内蒙古工业大学夜晚.jpg", content: `

产品特点

优势功能

` }, }; document.addEventListener('DOMContentLoaded', function() { // 从URL获取产品类型 const urlParams = new URLSearchParams(window.location.search); const productType = urlParams.get('type') || "JavaWeb"; // const other = productType.slice(2,3); console.log(productType); const detailTitle = document.getElementById('detailTitle'); // const detailImg = document.getElementById('detailImg'); const detailContent = document.getElementById('detailContent'); const formProductName = document.getElementById('formProductName'); const formTip = document.getElementById('formTip'); let product = productDataMap[productType]; // 填充产品详情 if(productType.slice(0,2)=='其他'){ product = productDataMap[productType.slice(0,2)]; console.log(productType.slice(2,3)); if(product){ detailTitle.textContent = product.title+productType.slice(2,3); detailContent.innerHTML = product.content; formProductName.textContent = product.title; } }else{ if (product) { detailTitle.textContent = product.title; detailContent.innerHTML = product.content; formProductName.textContent = product.title; } } // console.log(product.title); // } // 预约表单逻辑 const btnReserve = document.querySelector('.btn-reserve'); const btnCancel = document.querySelector('.btn-cancel'); const userName = document.getElementById('user-name'); const contact = document.getElementById('contact'); const btnReturn = document.querySelector('.btn-return'); btnReserve.addEventListener('click', function() { if (!userName.value.trim() || !/^1[3-9]\d{9}$/.test(contact.value)) { formTip.style.color = 'red'; formTip.textContent = '请输入完整且格式正确的信息!'; return; } alert("预约成功!我们将尽快与您联系。"); }); btnCancel.addEventListener('click', function() { userName.value = ''; contact.value = ''; formTip.textContent = ''; }); btnReturn.addEventListener('click',function(){ history.back(); }); });