123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280 |
- <!DOCTYPE html>
- <html lang="zh-CN">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>华视读卡器照片功能详细调试</title>
- <style>
- body { font-family: Arial, sans-serif; margin: 20px; background: #f5f5f5; }
- .container { max-width: 1200px; margin: 0 auto; background: white; padding: 20px; border-radius: 8px; }
- .test-section { margin: 20px 0; padding: 15px; border: 1px solid #ddd; border-radius: 5px; }
- .result { margin: 10px 0; padding: 10px; border-radius: 4px; }
- .result.success { background: #d4edda; border: 1px solid #28a745; }
- .result.error { background: #f8d7da; border: 1px solid #dc3545; }
- .result.info { background: #d1ecf1; border: 1px solid #17a2b8; }
- .result.warning { background: #fff3cd; border: 1px solid #ffc107; }
- button { padding: 10px 20px; margin: 5px; border: none; border-radius: 4px; cursor: pointer; background: #007bff; color: white; }
- button:hover { background: #0056b3; }
- button.success { background: #28a745; }
- button.warning { background: #ffc107; color: #212529; }
- pre { background: #f8f9fa; padding: 10px; border-radius: 4px; overflow-x: auto; max-height: 300px; font-size: 12px; }
- .debug-panel { background: #f8f9fa; border: 1px solid #dee2e6; padding: 15px; margin: 10px 0; border-radius: 5px; }
- .step-title { font-weight: bold; color: #495057; margin-bottom: 10px; }
- </style>
- </head>
- <body>
- <div class="container">
- <h1>🔍 华视读卡器照片功能详细调试分析</h1>
-
- <div class="debug-panel">
- <div class="step-title">📋 调试计划</div>
- <p>本页面将逐步分析照片读取失败的原因:</p>
- <ol>
- <li><strong>验证基础功能</strong> - 确认读卡器工作正常</li>
- <li><strong>检查函数调用</strong> - 验证照片相关函数是否被正确调用</li>
- <li><strong>分析返回值</strong> - 检查函数返回值和错误代码</li>
- <li><strong>数据分析</strong> - 详细分析返回的数据内容</li>
- <li><strong>提供解决方案</strong> - 基于分析结果给出建议</li>
- </ol>
- </div>
- <div class="test-section">
- <h2>🧪 分步调试测试</h2>
- <button onclick="step1_BasicTest()">1️⃣ 基础功能测试</button>
- <button onclick="step2_PhotoTest()" class="warning">2️⃣ 照片功能测试</button>
- <button onclick="step3_DetailAnalysis()" class="success">3️⃣ 详细数据分析</button>
- <button onclick="clearResults()">🗑️ 清除结果</button>
- </div>
- <div id="results"></div>
- </div>
- <script>
- let lastReadCardData = null;
- function addResult(title, data, type = 'info') {
- const results = document.getElementById('results');
- const div = document.createElement('div');
- div.className = `result ${type}`;
-
- let content = `<h3>${title} <small>${new Date().toLocaleTimeString()}</small></h3>`;
- if (typeof data === 'object') {
- content += `<pre>${JSON.stringify(data, null, 2)}</pre>`;
- } else {
- content += `<pre>${data}</pre>`;
- }
-
- div.innerHTML = content;
- results.appendChild(div);
- results.scrollTop = results.scrollHeight;
- }
- function step1_BasicTest() {
- addResult('🚀 第1步:基础功能测试', '验证华视读卡器基本功能...', 'info');
-
- // 1.1 健康检查
- fetch('http://localhost:8321/readcard/huashi/health')
- .then(response => response.json())
- .then(data => {
- addResult('✅ 1.1 服务健康检查', data, 'success');
-
- // 1.2 设备状态
- return fetch('http://localhost:8321/readcard/huashi/status');
- })
- .then(response => response.json())
- .then(data => {
- const statusType = data.code === 200 ? 'success' : 'warning';
- addResult('📊 1.2 设备状态检查', data, statusType);
-
- if (data.code === 200) {
- addResult('🎯 第1步总结',
- `基础功能测试完成:
- • 服务状态:正常运行 ✅
- • 设备状态:${data.deviceStatus} ✅
- • 连接端口:${data.portDescription} ✅
- • 设备初始化:${data.initialized ? '已完成' : '未完成'} ${data.initialized ? '✅' : '⚠️'}
- 接下来进行照片功能测试...`, 'success');
- } else {
- addResult('❌ 第1步警告', '设备状态异常,可能影响照片读取功能', 'warning');
- }
- })
- .catch(error => {
- addResult('❌ 第1步失败', `基础功能测试失败: ${error.message}`, 'error');
- });
- }
- function step2_PhotoTest() {
- addResult('🚀 第2步:照片功能测试', '开始测试照片读取功能...', 'info');
-
- fetch('http://localhost:8321/readcard/huashi/simple?action=readcard&port=1001', {
- method: 'GET',
- headers: { 'Content-Type': 'application/json' }
- })
- .then(response => response.json())
- .then(data => {
- lastReadCardData = data;
- const type = data.code === 200 ? 'success' : 'error';
- addResult('📋 2.1 读卡结果', data, type);
-
- if (data.code === 200 && data.data) {
- analyzePhotoResult(data.data);
- }
- })
- .catch(error => {
- addResult('❌ 第2步失败', `照片功能测试失败: ${error.message}`, 'error');
- });
- }
- function analyzePhotoResult(cardData) {
- let analysis = '📸 照片数据分析:\n\n';
-
- // 基础信息
- analysis += '🔍 基础检查:\n';
- analysis += `• photoBase64 字段存在: ${cardData.hasOwnProperty('photoBase64')}\n`;
- analysis += `• photoBase64 值: "${cardData.photoBase64}"\n`;
- analysis += `• photoBase64 长度: ${cardData.photoBase64 ? cardData.photoBase64.length : 0}\n`;
- analysis += `• hasPhoto: ${cardData.hasPhoto}\n`;
- analysis += `• photoFormat: ${cardData.photoFormat || '未设置'}\n`;
- analysis += `• photoSize: ${cardData.photoSize || 0}\n\n`;
-
- // 问题诊断
- if (!cardData.photoBase64 || cardData.photoBase64.length === 0) {
- analysis += '❌ 问题诊断:\n';
- analysis += '• 照片BASE64数据为空\n';
- analysis += '• 可能原因:\n';
- analysis += ' 1. 华视SDK照片函数未正确调用\n';
- analysis += ' 2. 身份证芯片中没有照片数据\n';
- analysis += ' 3. SDK版本不支持照片读取\n';
- analysis += ' 4. 函数调用时机不正确\n';
- analysis += ' 5. P/Invoke声明有误\n\n';
-
- analysis += '🔧 建议排查步骤:\n';
- analysis += '• 检查调试输出中的函数调用日志\n';
- analysis += '• 验证Termb.dll是否包含照片函数\n';
- analysis += '• 确认身份证是否包含照片信息\n';
- analysis += '• 尝试不同的函数调用顺序\n';
- } else {
- analysis += '✅ 获取到照片数据\n';
- analysis += `• 数据长度: ${cardData.photoBase64.length}\n`;
-
- // 检查数据质量
- if (cardData.photoBase64.length > 100) {
- const uniqueChars = new Set(cardData.photoBase64.split('')).size;
- analysis += `• 字符种类数: ${uniqueChars}\n`;
-
- if (uniqueChars < 5) {
- analysis += '⚠️ 警告:字符种类过少,可能是无效数据\n';
- }
- }
- }
-
- addResult('🔍 照片数据分析', analysis, cardData.hasPhoto ? 'success' : 'warning');
- }
- function step3_DetailAnalysis() {
- if (!lastReadCardData) {
- addResult('⚠️ 第3步:需要先执行读卡', '请先执行第2步的照片功能测试', 'warning');
- return;
- }
-
- addResult('🚀 第3步:详细数据分析', '分析读卡数据的详细内容...', 'info');
-
- const cardData = lastReadCardData.data;
- let detailAnalysis = '📊 详细数据分析报告:\n\n';
-
- // 身份证基本信息
- detailAnalysis += '👤 身份证基本信息:\n';
- detailAnalysis += `• 姓名: ${cardData.name}\n`;
- detailAnalysis += `• 性别: ${cardData.sex}\n`;
- detailAnalysis += `• 民族: ${cardData.nation}\n`;
- detailAnalysis += `• 身份证号: ${cardData.idCode}\n`;
- detailAnalysis += `• 签发机关: ${cardData.department}\n`;
- detailAnalysis += `• 有效期: ${cardData.startDate} - ${cardData.endDate}\n\n`;
-
- // 照片功能状态
- detailAnalysis += '📸 照片功能状态:\n';
- detailAnalysis += `• 是否获取到照片: ${cardData.hasPhoto ? '❌ 否' : '❌ 否'}\n`;
- detailAnalysis += `• 照片格式: ${cardData.photoFormat || '未知'}\n`;
- detailAnalysis += `• 照片数据大小: ${cardData.photoSize || 0} 字节\n\n`;
-
- // 技术分析
- detailAnalysis += '🔧 技术分析:\n';
- detailAnalysis += '• SDK版本: 华视电子V3.3.0.7\n';
- detailAnalysis += '• 当前测试的函数:\n';
- detailAnalysis += ' - Getbase64JpgData (获取JPG格式BASE64)\n';
- detailAnalysis += ' - Getbase64BMPData (获取BMP格式BASE64)\n';
- detailAnalysis += ' - GetJpgData (获取JPG二进制数据)\n';
- detailAnalysis += ' - GetBMPData (获取BMP二进制数据)\n';
- detailAnalysis += ' - CVR_Read_Content (读取内容)\n\n';
-
- // 下一步建议
- detailAnalysis += '💡 下一步建议:\n';
- if (!cardData.hasPhoto) {
- detailAnalysis += '• 查看Visual Studio输出窗口的调试信息\n';
- detailAnalysis += '• 确认华视SDK是否支持当前身份证的照片读取\n';
- detailAnalysis += '• 尝试使用华视官方测试工具验证\n';
- detailAnalysis += '• 检查身份证是否为新版本(包含照片信息)\n';
- detailAnalysis += '• 联系华视技术支持确认SDK使用方法\n';
- } else {
- detailAnalysis += '• 照片功能正常工作\n';
- detailAnalysis += '• 可以考虑优化图片格式和大小\n';
- }
-
- addResult('📊 详细分析报告', detailAnalysis, 'info');
-
- // 显示调试建议
- addResult('🔬 调试建议',
- `基于当前分析结果,建议:
- 1. 📋 检查调试输出:
- 在Visual Studio的"输出"窗口查看Debug输出,
- 应该能看到照片获取过程的详细日志。
- 2. 🧪 验证SDK功能:
- 使用华视官方提供的测试程序验证:
- • Demo.exe
- • CAPKITestDemo.exe
- 看这些程序是否能正常读取照片。
- 3. 💳 确认身份证版本:
- 照片功能可能只对特定版本的身份证有效:
- • 二代身份证(包含照片芯片)
- • 部分一代身份证可能不包含照片信息
- 4. 🔧 技术验证:
- 可以尝试直接调用DLL函数进行测试,
- 确认是API层面问题还是SDK问题。`, 'info');
- }
- function clearResults() {
- document.getElementById('results').innerHTML = '';
- lastReadCardData = null;
- }
- // 页面加载提示
- window.onload = function() {
- addResult('🎯 华视读卡器照片功能详细调试',
- `本页面提供照片功能的深度调试分析。
- 🎯 调试目标:
- 找出照片BASE64返回为空的具体原因
- 🔍 调试方法:
- • 分步骤验证每个环节
- • 详细分析返回数据
- • 提供针对性解决方案
- 📋 使用说明:
- 1. 按顺序执行测试步骤
- 2. 仔细查看每步的输出结果
- 3. 根据分析结果进行问题排查
- ⚠️ 注意事项:
- • 确保身份证已正确放置在读卡器上
- • 运行测试前先检查设备状态
- • 建议同时查看程序的调试输出`, 'info');
- };
- </script>
- </body>
- </html>
|