0eb0cf12fb
移除不再需要的测试脚本、调试页面和解决方案文档,包括: - 各种测试PHP文件(test.php, test_filters.php等) - VIP功能测试和调试页面(test_vip*.php, vip_debug_page.html等) - 数据库连接测试脚本(test_db_connection.php) - 解决方案文档(SOLUTIONS.md, VIP_*_Report.md)
183 lines
8.1 KiB
PHP
183 lines
8.1 KiB
PHP
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>VIP客户加载测试</title>
|
|
<style>
|
|
body { font-family: Arial, sans-serif; padding: 20px; }
|
|
.test-section { margin: 20px 0; padding: 15px; border: 1px solid #ddd; border-radius: 8px; }
|
|
.success { background-color: #d4edda; border-color: #c3e6cb; }
|
|
.error { background-color: #f8d7da; border-color: #f5c6cb; }
|
|
.loading { background-color: #d1ecf1; border-color: #bee5eb; }
|
|
button { padding: 10px 20px; margin: 5px; cursor: pointer; }
|
|
.vip-list { margin-top: 15px; }
|
|
.vip-item { padding: 8px; margin: 5px 0; background: #f8f9fa; border-radius: 4px; }
|
|
pre { background: #f8f9fa; padding: 10px; border-radius: 4px; overflow: auto; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h1>🔍 VIP客户功能测试</h1>
|
|
|
|
<div class="test-section loading">
|
|
<h3>1. VIP客户数据加载测试</h3>
|
|
<button onclick="testLoadVIPCustomers()">测试加载VIP客户</button>
|
|
<button onclick="testLoadSingleVIP()">测试加载单个VIP客户</button>
|
|
<div id="vip-test-results"></div>
|
|
</div>
|
|
|
|
<div class="test-section">
|
|
<h3>2. 搜索功能测试</h3>
|
|
<input type="text" id="search-input" placeholder="输入搜索关键词" oninput="testSearch()">
|
|
<button onclick="testSearch()">搜索</button>
|
|
<div id="search-results"></div>
|
|
</div>
|
|
|
|
<div class="test-section">
|
|
<h3>3. 页面内嵌测试</h3>
|
|
<button onclick="testInlineVIP()">测试内嵌VIP功能</button>
|
|
<div id="inline-vip-container" style="margin-top: 15px; border: 1px solid #ccc; padding: 15px; display: none;">
|
|
<label>搜索VIP客户: <input type="text" id="test-vip-search" oninput="testInlineSearch()"></label>
|
|
<div id="test-vip-results"></div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
let allVIPCustomers = [];
|
|
|
|
function testLoadVIPCustomers() {
|
|
const resultDiv = document.getElementById('vip-test-results');
|
|
resultDiv.innerHTML = '<div class="loading">正在加载VIP客户数据...</div>';
|
|
|
|
fetch('get_vip_customers.php')
|
|
.then(response => {
|
|
console.log('Response status:', response.status);
|
|
console.log('Response headers:', response.headers);
|
|
return response.text();
|
|
})
|
|
.then(text => {
|
|
console.log('Raw response:', text);
|
|
resultDiv.innerHTML = '<div class="loading">返回数据: <pre>' + text + '</pre></div>';
|
|
|
|
try {
|
|
const data = JSON.parse(text);
|
|
allVIPCustomers = data;
|
|
resultDiv.innerHTML = '<div class="success">✅ VIP客户加载成功,共' + data.length + '条记录</div>';
|
|
|
|
if (data.length > 0) {
|
|
let listHtml = '<div class="vip-list"><h4>VIP客户列表:</h4>';
|
|
data.forEach(vip => {
|
|
listHtml += `<div class="vip-item">${vip.customer_name} - ${vip.phone} - ${vip.car_model || '未知车型'}</div>`;
|
|
});
|
|
listHtml += '</div>';
|
|
resultDiv.innerHTML += listHtml;
|
|
} else {
|
|
resultDiv.innerHTML += '<div class="error">❌ 未找到VIP客户数据</div>';
|
|
}
|
|
} catch(e) {
|
|
resultDiv.innerHTML = '<div class="error">❌ JSON解析失败: ' + e.message + '</div>';
|
|
}
|
|
})
|
|
.catch(error => {
|
|
console.error('Fetch error:', error);
|
|
resultDiv.innerHTML = '<div class="error">❌ 网络请求失败: ' + error.message + '</div>';
|
|
});
|
|
}
|
|
|
|
function testLoadSingleVIP() {
|
|
const resultDiv = document.getElementById('vip-test-results');
|
|
resultDiv.innerHTML = '<div class="loading">正在加载单个VIP客户数据...</div>';
|
|
|
|
// 尝试加载第一个VIP客户
|
|
fetch('get_vip_customer.php?id=1')
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
resultDiv.innerHTML = '<div class="success">✅ 单个VIP客户加载成功</div>';
|
|
resultDiv.innerHTML += '<div class="vip-list"><h4>VIP客户详情:</h4><pre>' + JSON.stringify(data, null, 2) + '</pre></div>';
|
|
})
|
|
.catch(error => {
|
|
resultDiv.innerHTML = '<div class="error">❌ 单个VIP客户加载失败: ' + error.message + '</div>';
|
|
});
|
|
}
|
|
|
|
function testSearch() {
|
|
const searchTerm = document.getElementById('search-input').value;
|
|
const resultDiv = document.getElementById('search-results');
|
|
|
|
if (searchTerm.trim() === '') {
|
|
resultDiv.innerHTML = '<div>请输入搜索关键词</div>';
|
|
return;
|
|
}
|
|
|
|
if (allVIPCustomers.length === 0) {
|
|
resultDiv.innerHTML = '<div class="error">请先加载VIP客户数据</div>';
|
|
return;
|
|
}
|
|
|
|
const filtered = allVIPCustomers.filter(vip =>
|
|
vip.customer_name.includes(searchTerm) ||
|
|
vip.phone.includes(searchTerm)
|
|
);
|
|
|
|
if (filtered.length > 0) {
|
|
let resultHtml = '<div class="success">找到 ' + filtered.length + ' 个匹配结果:</div>';
|
|
filtered.forEach(vip => {
|
|
resultHtml += `<div class="vip-item">${highlightText(vip.customer_name, searchTerm)} - ${highlightText(vip.phone, searchTerm)} - ${vip.car_model || '未知车型'}</div>`;
|
|
});
|
|
resultDiv.innerHTML = resultHtml;
|
|
} else {
|
|
resultDiv.innerHTML = '<div class="error">未找到匹配结果</div>';
|
|
}
|
|
}
|
|
|
|
function highlightText(text, searchTerm) {
|
|
const regex = new RegExp(`(${searchTerm})`, 'gi');
|
|
return text.replace(regex, '<mark>$1</mark>');
|
|
}
|
|
|
|
function testInlineVIP() {
|
|
const container = document.getElementById('inline-vip-container');
|
|
container.style.display = container.style.display === 'none' ? 'block' : 'none';
|
|
|
|
if (container.style.display === 'block' && allVIPCustomers.length === 0) {
|
|
// 自动加载VIP客户数据
|
|
testLoadVIPCustomers();
|
|
}
|
|
}
|
|
|
|
function testInlineSearch() {
|
|
const searchInput = document.getElementById('test-vip-search');
|
|
const resultsDiv = document.getElementById('test-vip-results');
|
|
|
|
const searchTerm = searchInput.value.trim();
|
|
|
|
if (searchTerm === '') {
|
|
resultsDiv.innerHTML = '';
|
|
return;
|
|
}
|
|
|
|
const filtered = allVIPCustomers.filter(vip =>
|
|
vip.customer_name.includes(searchTerm) ||
|
|
vip.phone.includes(searchTerm)
|
|
);
|
|
|
|
if (filtered.length > 0) {
|
|
let resultHtml = '';
|
|
filtered.forEach(vip => {
|
|
resultHtml += `<div class="vip-item" onclick="alert('选中: ${vip.customer_name}')">${highlightText(vip.customer_name, searchTerm)} - ${highlightText(vip.phone, searchTerm)}</div>`;
|
|
});
|
|
resultsDiv.innerHTML = resultHtml;
|
|
} else {
|
|
resultsDiv.innerHTML = '<div style="color: #999; font-style: italic;">未找到匹配结果</div>';
|
|
}
|
|
}
|
|
|
|
// 页面加载时自动测试
|
|
window.onload = function() {
|
|
setTimeout(() => {
|
|
console.log('页面加载完成,自动测试VIP功能');
|
|
testLoadVIPCustomers();
|
|
}, 1000);
|
|
};
|
|
</script>
|
|
</body>
|
|
</html> |