This repository has been archived on 2026-06-20. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
carwash_order/test/test_vip_booking_history.php
T
wsh5485 0eb0cf12fb chore: 删除测试和调试相关文件
移除不再需要的测试脚本、调试页面和解决方案文档,包括:
- 各种测试PHP文件(test.php, test_filters.php等)
- VIP功能测试和调试页面(test_vip*.php, vip_debug_page.html等)
- 数据库连接测试脚本(test_db_connection.php)
- 解决方案文档(SOLUTIONS.md, VIP_*_Report.md)
2025-12-05 01:38:06 +08:00

266 lines
10 KiB
PHP

<?php
// 测试VIP客户上次预约记录显示功能
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>VIP客户预约历史测试</title>
<style>
body {
font-family: Arial, sans-serif;
line-height: 1.6;
margin: 20px;
background-color: #f5f5f5;
}
.container {
max-width: 800px;
margin: 0 auto;
background: white;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
h1 {
color: #333;
border-bottom: 2px solid #4CAF50;
padding-bottom: 10px;
}
.test-section {
margin-bottom: 30px;
padding: 15px;
background-color: #f9f9f9;
border-radius: 6px;
}
h2 {
color: #4CAF50;
margin-top: 0;
}
.test-result {
background-color: #fff;
padding: 15px;
border-radius: 4px;
border: 1px solid #ddd;
margin: 15px 0;
}
.test-case {
margin-bottom: 20px;
padding: 15px;
border-left: 4px solid #2196F3;
background-color: #e3f2fd;
}
button {
background-color: #4CAF50;
color: white;
border: none;
padding: 10px 15px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 10px 2px;
cursor: pointer;
border-radius: 4px;
}
button:hover {
background-color: #45a049;
}
.back-link {
display: inline-block;
margin-top: 20px;
padding: 10px 15px;
background-color: #2196F3;
color: white;
text-decoration: none;
border-radius: 4px;
}
.back-link:hover {
background-color: #1976D2;
}
pre {
background-color: #f0f0f0;
padding: 10px;
border-radius: 4px;
overflow-x: auto;
}
.success {
color: #4CAF50;
font-weight: bold;
}
.error {
color: #f44336;
font-weight: bold;
}
</style>
</head>
<body>
<div class="container">
<h1>VIP客户预约历史测试页面</h1>
<div class="test-section">
<h2>功能说明</h2>
<p>本页面用于测试VIP客户预约界面显示上次预约记录的功能。测试包括以下场景:</p>
<ul>
<li>VIP客户有最近预约记录的场景</li>
<li>VIP客户没有预约记录的场景(首次到店)</li>
</ul>
</div>
<div class="test-section">
<h2>测试1:获取VIP客户最近预约记录的API</h2>
<p>验证 <code>get_vip_last_booking.php</code> API是否正常工作:</p>
<div class="test-case">
<h3>场景1: 有预约记录的VIP客户</h3>
<p>模拟ID为1的VIP客户(有预约记录):</p>
<button onclick="testApiWithBooking()">测试有预约记录的VIP客户</button>
<div id="with-booking-result" class="test-result"></div>
</div>
<div class="test-case">
<h3>场景2: 无预约记录的VIP客户</h3>
<p>模拟ID为999的VIP客户(无预约记录):</p>
<button onclick="testApiWithoutBooking()">测试无预约记录的VIP客户</button>
<div id="without-booking-result" class="test-result"></div>
</div>
</div>
<div class="test-section">
<h2>测试2:前端显示功能</h2>
<p>模拟在index.php页面中选择VIP客户后的界面效果:</p>
<div class="test-case">
<h3>模拟显示有预约记录的VIP客户信息</h3>
<button onclick="simulateWithBooking()">模拟显示有预约记录</button>
<div id="simulate-with-booking" class="test-result">
<div id="vip_last_booking_info" style="display:none;">
<div class="panel panel-info">
<div class="panel-heading">
<h3 class="panel-title">上次预约记录</h3>
</div>
<div id="last_booking_content" class="panel-body">
<!-- 内容将通过JavaScript动态填充 -->
</div>
</div>
</div>
</div>
</div>
<div class="test-case">
<h3>模拟显示无预约记录的VIP客户信息</h3>
<button onclick="simulateWithoutBooking()">模拟显示无预约记录</button>
<div id="simulate-without-booking" class="test-result">
<div id="vip_last_booking_info2" style="display:none;">
<div class="panel panel-info">
<div class="panel-heading">
<h3 class="panel-title">上次预约记录</h3>
</div>
<div id="last_booking_content2" class="panel-body">
<!-- 内容将通过JavaScript动态填充 -->
</div>
</div>
</div>
</div>
</div>
</div>
<div class="test-section">
<h2>使用指南</h2>
<ol>
<li>点击上述按钮测试各种场景</li>
<li>查看控制台输出以获取更详细的调试信息</li>
<li>在实际应用中,选择VIP客户后系统会自动显示相关预约信息</li>
<li>请确保 <code>get_vip_last_booking.php</code> 文件存在且具有正确的权限</li>
</ol>
</div>
<a href="index.php" class="back-link">返回预约页面</a>
</div>
<script>
// 测试有预约记录的VIP客户API
function testApiWithBooking() {
const resultDiv = document.getElementById('with-booking-result');
resultDiv.innerHTML = '正在请求...';
// 使用test=1参数获取模拟数据
fetch('get_vip_last_booking.php?vip_id=1&test=1')
.then(response => response.json())
.then(data => {
console.log('API响应 (有预约记录):', data);
resultDiv.innerHTML = `
<p>API返回结果:<span class="success">成功</span></p>
<pre>${JSON.stringify(data, null, 2)}</pre>
<p>预期结果:返回包含has_booking:true和预约信息的数据</p>
`;
})
.catch(error => {
console.error('API错误:', error);
resultDiv.innerHTML = `<p class="error">请求失败: ${error.message}</p>`;
});
}
// 测试无预约记录的VIP客户API
function testApiWithoutBooking() {
const resultDiv = document.getElementById('without-booking-result');
resultDiv.innerHTML = '正在请求...';
// 使用no_booking=1参数获取无预约记录的模拟数据
fetch('get_vip_last_booking.php?vip_id=999&no_booking=1')
.then(response => response.json())
.then(data => {
console.log('API响应 (无预约记录):', data);
resultDiv.innerHTML = `
<p>API返回结果:<span class="success">成功</span></p>
<pre>${JSON.stringify(data, null, 2)}</pre>
<p>预期结果:返回has_booking:false的数据</p>
`;
})
.catch(error => {
console.error('API错误:', error);
resultDiv.innerHTML = `<p class="error">请求失败: ${error.message}</p>`;
});
}
// 模拟显示有预约记录的场景
function simulateWithBooking() {
const bookingInfoDiv = document.getElementById('vip_last_booking_info');
const contentDiv = document.getElementById('last_booking_content');
// 模拟数据
const mockData = {
has_booking: true,
booking_time: '2024-07-15 14:30',
package_name: '豪华洗车套餐',
duration: '60分钟'
};
// 显示信息
bookingInfoDiv.style.display = 'block';
contentDiv.innerHTML = `
<p><strong>上次预约时间:</strong> ${mockData.booking_time}</p>
<p><strong>预约套餐:</strong> ${mockData.package_name}</p>
<p><strong>施工时长:</strong> ${mockData.duration}</p>
`;
console.log('模拟显示有预约记录的场景:', mockData);
}
// 模拟显示无预约记录的场景
function simulateWithoutBooking() {
const bookingInfoDiv = document.getElementById('vip_last_booking_info2');
const contentDiv = document.getElementById('last_booking_content2');
// 显示信息
bookingInfoDiv.style.display = 'block';
contentDiv.innerHTML = '<p class="success">该VIP首次到店</p>';
console.log('模拟显示无预约记录的场景(首次到店)');
}
// 页面加载时的提示
console.log('VIP客户预约历史测试页面已加载。请点击按钮测试不同场景。');
</script>
</body>
</html>