专业游戏陪玩服务
与顶尖玩家一起游戏,提升你的游戏水平
订单类型:
2小时单排
开始时间:
2023-06-20 15:30
// 卡密验证表单提交
document.getElementById('cardVerificationForm').addEventListener('submit', function(e) {
e.preventDefault();
const cardCode = document.getElementById('cardCode').value;
const errorMsg = document.getElementById('cardErrorMsg');
// 模拟验证过程
errorMsg.textContent = '验证中...';
errorMsg.classList.remove('hidden');
setTimeout(() => {
if (cardCode.trim() === '') {
errorMsg.textContent = '请输入卡密';
} else {
// 隐藏卡密验证模态框,显示订单流程
hideCardVerification();
showOrderFlow();
}
}, 1000);
});
// 步骤1表单提交
document.getElementById('step1Form').addEventListener('submit', function(e) {
e.preventDefault();
const cardCode = document.getElementById('step1CardCode').value;
const errorMsg = document.getElementById('step1ErrorMsg');
if (cardCode.trim() === '') {
errorMsg.textContent = '请输入卡密';
errorMsg.classList.remove('hidden');
return;
}
errorMsg.classList.add('hidden');
// 模拟验证成功,进入下一步
setTimeout(() => {
goToStep(2);
}, 1000);
});
// 步骤2表单提交
document.getElementById('step2Form').addEventListener('submit', function(e) {
e.preventDefault();
const gameName = document.getElementById('gameName').value;
const tempPassword = document.getElementById('tempPassword').value;
if (gameName.trim() === '' || tempPassword.trim() === '') {
alert('请填写完整信息');
return;
}
// 模拟提交成功,进入排队
setTimeout(() => {
goToStep(3);
startQueueSimulation();
}, 1000);
});
// 模拟排队过程
function startQueueSimulation() {
let position = 3;
const positionElement = document.getElementById('queuePosition');
const waitTimeElement = document.getElementById('estimatedWaitTime');
const interval = setInterval(() => {
if (position > 1) {
position--;
positionElement.textContent = position;
waitTimeElement.textContent = (position * 5) + '分钟';
} else {
clearInterval(interval);
// 排队完成,进入订单
setTimeout(() => {
goToStep(4);
updateOrderInfo();
}, 2000);
}
}, 3000);
}
// 更新订单信息
function updateOrderInfo() {
document.getElementById('playerName').textContent = '打手' + Math.floor(Math.random() * 100);
document.getElementById('playerStatus').textContent = '在线 - 准备中';
document.getElementById('orderType').textContent = document.getElementById('gameName').value + ' - 2小时';
document.getElementById('startTime').textContent = new Date().toLocaleString('zh-CN');
}
// 确认订单完成
function confirmOrderComplete() {
if (confirm('确认订单已完成吗?')) {
alert('订单已完成,感谢使用我们的服务!');
hideOrderFlow();
}
}
// 显示订单流程模态框
function showOrderFlow() {
document.getElementById('orderFlowModal').classList.remove('hidden');
}
lucide.createIcons();
// 显示卡密验证模态框
function showCardVerification() {
document.getElementById('cardVerificationModal').classList.remove('hidden');
}
// 隐藏卡密验证模态框
function hideCardVerification() {
document.getElementById('cardVerificationModal').classList.add('hidden');
document.getElementById('cardCode').value = '';
document.getElementById('cardErrorMsg').classList.add('hidden');
}
// 隐藏订单流程模态框
function hideOrderFlow() {
document.getElementById('orderFlowModal').classList.add('hidden');
resetOrderFlow();
}
// 重置订单流程
function resetOrderFlow() {
document.querySelectorAll('.step-indicator').forEach(indicator => {
indicator.classList.remove('active', 'completed');
indicator.querySelector('.step-number').textContent = indicator.dataset.step;
});
document.querySelectorAll('.step-content').forEach(content => {
content.classList.add('hidden');
});
document.querySelector('[data-step="1"]').classList.add('active');
document.getElementById('step1').classList.remove('hidden');
}
// 切换到指定步骤
function goToStep(step) {
document.querySelectorAll('.step-content').forEach(content => {
content.classList.add('hidden');
});
document.getElementById(`step${step}`).classList.remove('hidden');
document.querySelectorAll('.step-indicator').forEach(indicator => {
const stepNum = parseInt(indicator.dataset.step);
indicator.classList.remove('active', 'completed');
if (stepNum < step) {
indicator.classList.add('completed');
indicator.querySelector('.step-number').innerHTML = '';
} else if (stepNum === step) {
indicator.classList.add('active');
}
});
lucide.createIcons();
}
// 卡密验证表单提交
document.getElementById('cardVerificationForm').addEventListener('submit', function(e) {
e.preventDefault();
const cardCode = document.getElementById('cardCode').value;
const errorMsg = document.getElementById('cardErrorMsg');
if (!cardCode) {
errorMsg.textContent = '请输入卡密';
errorMsg.classList.remove('hidden');
return;
}
// 模拟卡密验证
setTimeout(() => {
if (cardCode === 'TEST123') {
hideCardVerification();
showOrderFlow();
document.getElementById('step1CardCode').value = cardCode;
} else {
errorMsg.textContent = '卡密无效或已使用';
errorMsg.classList.remove('hidden');
}
}, 500);
});
// 步骤1表单提交
document.getElementById('step1Form').addEventListener('submit', function(e) {
e.preventDefault();
const cardCode = document.getElementById('step1CardCode').value;
const errorMsg = document.getElementById('step1ErrorMsg');
if (!cardCode) {
errorMsg.textContent = '请输入卡密';
errorMsg.classList.remove('hidden');
return;
}
// 模拟卡密验证
setTimeout(() => {
if (cardCode === 'TEST123') {
goToStep(2);
} else {
errorMsg.textContent = '卡密无效或已使用';
errorMsg.classList.remove('hidden');
}
}, 500);
});
// 步骤2表单提交
document.getElementById('step2Form').addEventListener('submit', function(e) {
e.preventDefault();
const gameName = document.getElementById('gameName').value;
const tempPassword = document.getElementById('tempPassword').value;
if (!gameName || !tempPassword) {
alert('请填写完整信息');
return;
}
// 模拟提交
setTimeout(() => {
goToStep(3);
startQueueSimulation();
}, 500);
});
// 显示订单流程模态框
function showOrderFlow() {
document.getElementById('orderFlowModal').classList.remove('hidden');
}
// 排队模拟
function startQueueSimulation() {
let position = parseInt(document.getElementById('queuePosition').textContent);
const interval = setInterval(() => {
if (position > 1) {
position--;
document.getElementById('queuePosition').textContent = position;
// 更新等待时间
const waitTime = position * 5;
document.getElementById('estimatedWaitTime').textContent = waitTime + '分钟';
} else {
clearInterval(interval);
// 模拟接单
setTimeout(() => {
goToStep(4);
// 设置订单信息
document.getElementById('playerName').textContent = '专业打手_小王';
document.getElementById('playerStatus').textContent = '在线 - 准备开始';
document.getElementById('orderType').textContent = '2小时单排';
const now = new Date();
const timeString = now.getFullYear() + '-' +
String(now.getMonth() + 1).padStart(2, '0') + '-' +
String(now.getDate()).padStart(2, '0') + ' ' +
String(now.getHours()).padStart(2, '0') + ':' +
String(now.getMinutes()).padStart(2, '0');
document.getElementById('startTime').textContent = timeString;
}, 2000);
}
}, 3000);
}
// 确认订单完成
function confirmOrderComplete() {
if (confirm('确认订单已完成吗?')) {
alert('感谢您的使用!欢迎再次下单。');
hideOrderFlow();
resetOrderFlow();
}
}
// 模拟排队过程
function startQueueSimulation() {
let position = 3;
const positionElement = document.getElementById('queuePosition');
const waitTimeElement = document.getElementById('estimatedWaitTime');
const interval = setInterval(() => {
position--;
if (position <= 0) {
clearInterval(interval);
goToStep(4);
return;
}
positionElement.textContent = position;
waitTimeElement.textContent = `${position * 5}分钟`;
}, 3000);
}
// 确认订单完成
function confirmOrderComplete() {
if (confirm('确认订单已完成吗?')) {
alert('感谢您的使用!订单已完成。');
hideOrderFlow();
}
}
// 页面加载完成后初始化
document.addEventListener('DOMContentLoaded', function() {
// 检查URL参数,看是否有卡密
const urlParams = new URLSearchParams(window.location.search);
const cardCode = urlParams.get('card');
if (cardCode) {
document.getElementById('step1CardCode').value = cardCode;
showOrderFlow();
}
});