0eb0cf12fb
移除不再需要的测试脚本、调试页面和解决方案文档,包括: - 各种测试PHP文件(test.php, test_filters.php等) - VIP功能测试和调试页面(test_vip*.php, vip_debug_page.html等) - 数据库连接测试脚本(test_db_connection.php) - 解决方案文档(SOLUTIONS.md, VIP_*_Report.md)
341 lines
13 KiB
HTML
341 lines
13 KiB
HTML
<!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;
|
|
max-width: 800px;
|
|
margin: 0 auto;
|
|
padding: 20px;
|
|
}
|
|
.test-area {
|
|
background: #f9f9f9;
|
|
padding: 20px;
|
|
border-radius: 8px;
|
|
border: 1px solid #ddd;
|
|
margin-bottom: 20px;
|
|
}
|
|
input {
|
|
padding: 8px;
|
|
width: 300px;
|
|
margin-right: 10px;
|
|
}
|
|
button {
|
|
padding: 8px 15px;
|
|
background: #4CAF50;
|
|
color: white;
|
|
border: none;
|
|
cursor: pointer;
|
|
border-radius: 4px;
|
|
}
|
|
button:hover {
|
|
background: #45a049;
|
|
}
|
|
.result {
|
|
margin-top: 20px;
|
|
padding: 15px;
|
|
background: #e9f5ff;
|
|
border-radius: 4px;
|
|
border-left: 4px solid #2196F3;
|
|
}
|
|
.success {
|
|
background: #e8f5e8;
|
|
border-left-color: #4CAF50;
|
|
}
|
|
.error {
|
|
background: #ffebee;
|
|
border-left-color: #f44336;
|
|
}
|
|
.warning {
|
|
background: #fff3e0;
|
|
border-left-color: #ff9800;
|
|
}
|
|
pre {
|
|
background: #f0f0f0;
|
|
padding: 10px;
|
|
border-radius: 4px;
|
|
overflow-x: auto;
|
|
}
|
|
.test-case {
|
|
margin: 10px 0;
|
|
padding: 10px;
|
|
border: 1px solid #eee;
|
|
border-radius: 4px;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h1>VIP搜索功能测试</h1>
|
|
|
|
<div class="test-area">
|
|
<h2>手动搜索测试</h2>
|
|
<input type="text" id="search-input" value="18699627661" placeholder="输入手机号、姓名或车牌号">
|
|
<button onclick="runSearchTest()">搜索测试</button>
|
|
|
|
<div id="search-result" class="result">
|
|
请点击搜索按钮开始测试...
|
|
</div>
|
|
</div>
|
|
|
|
<div class="test-area">
|
|
<h2>预定义测试用例</h2>
|
|
|
|
<div class="test-case">
|
|
<h3>测试1: 搜索手机号 18699627661</h3>
|
|
<button onclick="runTestCase('18699627661', '王五')">执行测试</button>
|
|
<div id="test1-result" class="result"></div>
|
|
</div>
|
|
|
|
<div class="test-case">
|
|
<h3>测试2: 搜索姓名 "张三"</h3>
|
|
<button onclick="runTestCase('张三', '张三')">执行测试</button>
|
|
<div id="test2-result" class="result"></div>
|
|
</div>
|
|
|
|
<div class="test-case">
|
|
<h3>测试3: 搜索车牌号 "京A12345"</h3>
|
|
<button onclick="runTestCase('京A12345', '张三')">执行测试</button>
|
|
<div id="test3-result" class="result"></div>
|
|
</div>
|
|
|
|
<div class="test-case">
|
|
<h3>测试4: 部分手机号搜索 "186"</h3>
|
|
<button onclick="runTestCase('186', '多结果')">执行测试</button>
|
|
<div id="test4-result" class="result"></div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="test-area">
|
|
<h2>测试数据管理</h2>
|
|
<button onclick="clearTestData()">清除测试数据</button>
|
|
<button onclick="recreateTestData()">重新创建测试数据</button>
|
|
<button onclick="showTestData()">查看当前测试数据</button>
|
|
|
|
<div id="data-result" class="result"></div>
|
|
</div>
|
|
|
|
<script>
|
|
// 模拟手机号标准化函数(来自原项目)
|
|
function standardizePhoneNumber(phone) {
|
|
// 移除所有非数字字符
|
|
return phone.replace(/\D/g, '');
|
|
}
|
|
|
|
// 模拟搜索函数
|
|
function searchVIPCustomers(searchTerm) {
|
|
console.log('开始搜索测试:', searchTerm);
|
|
|
|
// 从localStorage获取测试数据
|
|
const savedVips = localStorage.getItem('temp_vip_customers');
|
|
let vipData = [];
|
|
|
|
if (savedVips) {
|
|
try {
|
|
vipData = JSON.parse(savedVips);
|
|
console.log('从localStorage加载VIP数据:', vipData.length, '条记录');
|
|
} catch (e) {
|
|
console.error('解析VIP数据失败:', e);
|
|
}
|
|
}
|
|
|
|
// 如果没有数据,创建测试数据
|
|
if (vipData.length === 0) {
|
|
vipData = [
|
|
{ customer_name: '张三', phone: '18612345678', car_model: '奔驰C级', car_number: '京A12345' },
|
|
{ customer_name: '李四', phone: '13987654321', car_model: '宝马3系', car_number: '京B54321' },
|
|
{ customer_name: '王五', phone: '18699627661', car_model: '奥迪A4', car_number: '沪A12345' },
|
|
{ customer_name: '赵六', phone: '18699627777', car_model: '特斯拉Model 3', car_number: '深A67890' },
|
|
{ customer_name: '钱七', phone: '13812345678', car_model: '丰田凯美瑞', car_number: '广A12345' }
|
|
];
|
|
|
|
// 保存到localStorage
|
|
localStorage.setItem('temp_vip_customers', JSON.stringify(vipData));
|
|
console.log('创建并保存测试数据');
|
|
}
|
|
|
|
// 标准化搜索词
|
|
const term = searchTerm.toLowerCase().trim();
|
|
const standardPhone = standardizePhoneNumber(term);
|
|
|
|
// 执行搜索
|
|
const results = vipData.filter(vip => {
|
|
// 标准化手机号
|
|
const vipPhoneStandard = standardizePhoneNumber(vip.phone || '');
|
|
|
|
// 检查多种匹配条件
|
|
return (
|
|
// 姓名匹配
|
|
(vip.customer_name || '').toLowerCase().includes(term) ||
|
|
// 手机号精确匹配
|
|
vip.phone === term ||
|
|
// 标准化手机号匹配
|
|
vipPhoneStandard === standardPhone ||
|
|
// 部分手机号匹配
|
|
vipPhoneStandard.includes(standardPhone) ||
|
|
// 车牌号匹配
|
|
(vip.car_number || '').toLowerCase().includes(term) ||
|
|
// 车型匹配
|
|
(vip.car_model || '').toLowerCase().includes(term)
|
|
);
|
|
});
|
|
|
|
return {
|
|
term: searchTerm,
|
|
standardPhone: standardPhone,
|
|
totalVips: vipData.length,
|
|
results: results,
|
|
hasResults: results.length > 0
|
|
};
|
|
}
|
|
|
|
// 执行手动搜索测试
|
|
function runSearchTest() {
|
|
const searchInput = document.getElementById('search-input');
|
|
const resultDiv = document.getElementById('search-result');
|
|
const searchTerm = searchInput.value;
|
|
|
|
resultDiv.innerHTML = '正在搜索...';
|
|
|
|
// 执行搜索
|
|
const searchResult = searchVIPCustomers(searchTerm);
|
|
|
|
// 格式化结果显示
|
|
let html = `
|
|
<h3>搜索结果摘要</h3>
|
|
<p><strong>搜索词:</strong> ${searchResult.term}</p>
|
|
<p><strong>标准化手机号:</strong> ${searchResult.standardPhone}</p>
|
|
<p><strong>VIP客户总数:</strong> ${searchResult.totalVips}</p>
|
|
<p><strong>匹配结果数:</strong> ${searchResult.results.length}</p>
|
|
`;
|
|
|
|
// 根据结果设置样式
|
|
if (searchResult.hasResults) {
|
|
resultDiv.className = 'result success';
|
|
|
|
// 添加匹配结果列表
|
|
html += '<h4>匹配的VIP客户:</h4><pre>';
|
|
searchResult.results.forEach((vip, index) => {
|
|
html += `[${index + 1}] ${vip.customer_name || '未知'} - ${vip.phone || '未知'} - ${vip.car_model || '未知'} - ${vip.car_number || '未知'}\n`;
|
|
});
|
|
html += '</pre>';
|
|
} else {
|
|
resultDiv.className = 'result warning';
|
|
html += '<p>没有找到匹配的VIP客户</p>';
|
|
}
|
|
|
|
// 显示详细日志
|
|
html += '<h4>控制台日志:</h4>';
|
|
html += `<p>输入手机号= ${searchResult.term}</p>`;
|
|
html += `<p>标准化后= ${searchResult.standardPhone}</p>`;
|
|
html += `<p>VIP客户总数= ${searchResult.totalVips}</p>`;
|
|
html += `<p>有效匹配= ${searchResult.hasResults ? JSON.stringify(searchResult.results[0]) : 'null'}</p>`;
|
|
|
|
resultDiv.innerHTML = html;
|
|
|
|
// 在控制台输出
|
|
console.log('搜索测试结果:', searchResult);
|
|
}
|
|
|
|
// 执行预定义测试用例
|
|
function runTestCase(searchTerm, expectedName) {
|
|
const testId = 'test' + searchTerm.replace(/\D/g, '') + '-result';
|
|
const resultDiv = document.getElementById(testId) || document.getElementById('test1-result');
|
|
|
|
resultDiv.innerHTML = '正在执行测试...';
|
|
|
|
// 执行搜索
|
|
const searchResult = searchVIPCustomers(searchTerm);
|
|
|
|
// 验证结果
|
|
let isSuccess = false;
|
|
if (searchResult.hasResults) {
|
|
if (expectedName === '多结果') {
|
|
isSuccess = searchResult.results.length > 1;
|
|
} else {
|
|
isSuccess = searchResult.results.some(vip => vip.customer_name === expectedName);
|
|
}
|
|
}
|
|
|
|
// 设置结果样式和内容
|
|
resultDiv.className = isSuccess ? 'result success' : 'result error';
|
|
|
|
let html = `
|
|
<p><strong>搜索词:</strong> ${searchTerm}</p>
|
|
<p><strong>预期结果:</strong> ${expectedName}</p>
|
|
<p><strong>实际结果:</strong> ${searchResult.hasResults ? searchResult.results[0]?.customer_name : '未找到'}</p>
|
|
<p><strong>测试状态:</strong> ${isSuccess ? '通过' : '失败'}</p>
|
|
`;
|
|
|
|
if (searchResult.hasResults) {
|
|
html += '<h4>匹配结果:</h4><pre>';
|
|
searchResult.results.forEach((vip, index) => {
|
|
html += `[${index + 1}] ${vip.customer_name}: ${vip.phone} (${vip.car_model}) ${vip.car_number}\n`;
|
|
});
|
|
html += '</pre>';
|
|
}
|
|
|
|
resultDiv.innerHTML = html;
|
|
}
|
|
|
|
// 清除测试数据
|
|
function clearTestData() {
|
|
localStorage.removeItem('temp_vip_customers');
|
|
document.getElementById('data-result').innerHTML = '<p>测试数据已清除</p>';
|
|
document.getElementById('data-result').className = 'result';
|
|
}
|
|
|
|
// 重新创建测试数据
|
|
function recreateTestData() {
|
|
const testData = [
|
|
{ customer_name: '张三', phone: '18612345678', car_model: '奔驰C级', car_number: '京A12345' },
|
|
{ customer_name: '李四', phone: '13987654321', car_model: '宝马3系', car_number: '京B54321' },
|
|
{ customer_name: '王五', phone: '18699627661', car_model: '奥迪A4', car_number: '沪A12345' },
|
|
{ customer_name: '赵六', phone: '18699627777', car_model: '特斯拉Model 3', car_number: '深A67890' },
|
|
{ customer_name: '钱七', phone: '13812345678', car_model: '丰田凯美瑞', car_number: '广A12345' }
|
|
];
|
|
|
|
localStorage.setItem('temp_vip_customers', JSON.stringify(testData));
|
|
|
|
const resultDiv = document.getElementById('data-result');
|
|
resultDiv.className = 'result success';
|
|
resultDiv.innerHTML = '<p>测试数据已重新创建</p>';
|
|
}
|
|
|
|
// 显示当前测试数据
|
|
function showTestData() {
|
|
const savedVips = localStorage.getItem('temp_vip_customers');
|
|
const resultDiv = document.getElementById('data-result');
|
|
|
|
if (savedVips) {
|
|
try {
|
|
const vipData = JSON.parse(savedVips);
|
|
resultDiv.className = 'result';
|
|
|
|
let html = `<h4>当前测试数据 (${vipData.length}条)</h4><pre>`;
|
|
vipData.forEach((vip, index) => {
|
|
html += `[${index + 1}] ${vip.customer_name}: ${vip.phone} (${vip.car_model}) ${vip.car_number}\n`;
|
|
});
|
|
html += '</pre>';
|
|
|
|
resultDiv.innerHTML = html;
|
|
} catch (e) {
|
|
resultDiv.className = 'result error';
|
|
resultDiv.innerHTML = `<p>数据解析失败: ${e.message}</p>`;
|
|
}
|
|
} else {
|
|
resultDiv.className = 'result warning';
|
|
resultDiv.innerHTML = '<p>没有找到测试数据</p>';
|
|
}
|
|
}
|
|
|
|
// 页面加载时自动显示测试数据
|
|
window.onload = function() {
|
|
showTestData();
|
|
};
|
|
</script>
|
|
</body>
|
|
</html> |