123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365 |
- <!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>
- * {
- margin: 0;
- padding: 0;
- box-sizing: border-box;
- }
- body {
- font-family: 'Microsoft YaHei', sans-serif;
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
- min-height: 100vh;
- padding: 20px;
- }
- .container {
- max-width: 1200px;
- margin: 0 auto;
- background: white;
- border-radius: 15px;
- box-shadow: 0 20px 60px rgba(0,0,0,0.1);
- overflow: hidden;
- }
- .header {
- background: linear-gradient(135deg, #8e44ad 0%, #3498db 100%);
- color: white;
- padding: 30px;
- text-align: center;
- }
- .header h1 {
- font-size: 2.5em;
- margin-bottom: 10px;
- font-weight: 600;
- }
- .header p {
- font-size: 1.1em;
- opacity: 0.9;
- }
- .content {
- padding: 40px;
- }
- .info-section {
- background: #f8f9fa;
- border-radius: 10px;
- padding: 25px;
- margin-bottom: 30px;
- border-left: 5px solid #8e44ad;
- }
- .info-section h3 {
- color: #2c3e50;
- margin-bottom: 15px;
- font-size: 1.3em;
- }
- .test-section {
- background: white;
- border-radius: 10px;
- padding: 30px;
- margin-bottom: 30px;
- border: 1px solid #e9ecef;
- }
- .test-buttons {
- display: grid;
- grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
- gap: 20px;
- margin-bottom: 30px;
- }
- .test-btn {
- background: linear-gradient(135deg, #8e44ad 0%, #9b59b6 100%);
- color: white;
- border: none;
- padding: 15px 25px;
- border-radius: 8px;
- font-size: 1.1em;
- cursor: pointer;
- transition: all 0.3s ease;
- text-align: center;
- }
- .test-btn:hover {
- transform: translateY(-2px);
- box-shadow: 0 8px 25px rgba(142, 68, 173, 0.3);
- }
- .result-area {
- background: #f8f9fa;
- border-radius: 8px;
- padding: 20px;
- margin-top: 20px;
- min-height: 200px;
- font-family: 'Courier New', monospace;
- white-space: pre-wrap;
- border: 1px solid #dee2e6;
- }
- .success {
- background: #d4edda;
- color: #155724;
- border: 1px solid #c3e6cb;
- }
- .error {
- background: #f8d7da;
- color: #721c24;
- border: 1px solid #f5c6cb;
- }
- .loading {
- display: none;
- text-align: center;
- padding: 20px;
- color: #8e44ad;
- }
- .spinner {
- border: 3px solid #f3f3f3;
- border-top: 3px solid #8e44ad;
- border-radius: 50%;
- width: 30px;
- height: 30px;
- animation: spin 1s linear infinite;
- margin: 0 auto 10px;
- }
- @keyframes spin {
- 0% { transform: rotate(0deg); }
- 100% { transform: rotate(360deg); }
- }
- </style>
- </head>
- <body>
- <div class="container">
- <div class="header">
- <h1>江苏医保刷脸功能测试</h1>
- <p>使用NationECCode.dll实现 - 与泰和完全一致的刷脸授权获取医保身份功能</p>
- </div>
- <div class="content">
- <!-- 实现说明 -->
- <div class="info-section">
- <h3>💡 实现说明</h3>
- <p>✓ 使用相同的NationECCode.dll动态库</p>
- <p>✓ 相同的两步式认证流程:cn.nhsa.ec.auth → cn.nhsa.auth.check</p>
- <p>✓ 相同的服务地址和机构编号(写死参数)</p>
- <p>✓ 完全符合国家医保电子凭证业务标准动态库交互规范</p>
- <p>✓ 唯一区别:使用江苏医保的配置参数而非泰和配置</p>
- </div>
- <!-- 测试按钮 -->
- <div class="test-section">
- <h3>🧪 功能测试</h3>
- <div class="test-buttons">
- <button class="test-btn" onclick="testFaceAuth('01101')">
- 门诊挂号 (01101)
- </button>
- <button class="test-btn" onclick="testFaceAuth('01301')">
- 门诊结算 (01301)
- </button>
- <button class="test-btn" onclick="testFaceAuth('02121')">
- 药店购药 (02121)
- </button>
- <button class="test-btn" onclick="testFaceAuth('01102')">
- 住院建档 (01102)
- </button>
- <button class="test-btn" onclick="testFaceAuth('01103')">
- 入院登记 (01103)
- </button>
- <button class="test-btn" onclick="testFaceAuth('01104')">
- 缴纳预缴金 (01104)
- </button>
- </div>
- <!-- 加载指示器 -->
- <div class="loading" id="loading">
- <div class="spinner"></div>
- <p>正在进行江苏医保刷脸认证...</p>
- <p style="font-size: 12px; color: #666; margin-top: 5px;">请耐心等待,刷脸操作可能需要60秒</p>
- </div>
- <!-- 结果显示区域 -->
- <div id="result" class="result-area">
- 🎯 江苏医保刷脸功能测试页面
- 📋 实现说明:
- • 使用NationECCode.dll动态库(与泰和完全一致)
- • 两步式认证:cn.nhsa.ec.auth + cn.nhsa.auth.check
- • 写死配置参数:机构编号H32132200561
- • 符合国家医保电子凭证业务标准规范
- 🚀 点击上方按钮开始测试不同业务类型的刷脸功能
- ⚠️ 注意:测试前请确保:
- 1. NationECCode.dll已正确部署
- 2. 刷脸设备正常工作
- 3. 网络连接正常
- 4. 服务地址可访问
- </div>
- </div>
- </div>
- </div>
- <script>
- // 测试江苏医保刷脸功能
- async function testFaceAuth(businessType) {
- const loadingElement = document.getElementById('loading');
- const resultElement = document.getElementById('result');
-
- // 显示加载状态
- loadingElement.style.display = 'block';
- resultElement.innerHTML = '';
- resultElement.className = 'result-area';
- try {
- const startTime = new Date();
- const url = `http://localhost:8321/readcard/entry?param=jiangsu_face_${businessType}`;
-
- console.log('发起江苏医保刷脸请求:', {
- url: url,
- businessType: businessType,
- timestamp: startTime.toLocaleString()
- });
- // 添加AbortController用于超时控制
- const controller = new AbortController();
- const timeoutId = setTimeout(() => controller.abort(), 60000); // 60秒超时(增加超时时间)
- const response = await fetch(url, {
- method: 'GET',
- headers: {
- 'Content-Type': 'application/json'
- },
- signal: controller.signal
- });
- clearTimeout(timeoutId);
- const endTime = new Date();
- const responseTime = endTime - startTime;
- let result;
- try {
- result = await response.json();
- } catch (e) {
- const responseText = await response.text();
- result = {
- code: 1001,
- message: '响应解析失败: ' + e.message,
- rawResponse: responseText
- };
- }
- // 隐藏加载状态
- loadingElement.style.display = 'none';
- // 显示结果
- displayResult(result, businessType, responseTime, response.status);
- } catch (error) {
- // 隐藏加载状态
- loadingElement.style.display = 'none';
-
- // 处理不同类型的错误
- let errorResult;
- if (error.name === 'AbortError') {
- errorResult = {
- code: 1001,
- message: '请求超时(60秒): 刷脸操作可能需要更长时间,请耐心等待或重试',
- error: 'NetworkTimeout',
- suggestion: '1. 确认刷脸设备正常工作 2. 检查网络连接 3. 重新尝试刷脸操作 4. 如果问题持续,请检查DLL配置',
- timestamp: new Date().toLocaleString()
- };
- } else {
- errorResult = {
- code: 1001,
- message: '网络请求失败: ' + error.message,
- error: error.name,
- timestamp: new Date().toLocaleString()
- };
- }
- displayResult(errorResult, businessType, 0, 0, true);
- }
- }
- // 显示测试结果
- function displayResult(result, businessType, responseTime, httpStatus, isError = false) {
- const resultElement = document.getElementById('result');
-
- // 设置样式
- if (isError || (result.code && result.code !== 200)) {
- resultElement.className = 'result-area error';
- } else if (result.code === 200) {
- resultElement.className = 'result-area success';
- } else {
- resultElement.className = 'result-area';
- }
- // 构建显示内容
- let displayContent = '';
-
- displayContent += '=== 江苏医保刷脸测试结果 ===\n\n';
- displayContent += `业务类型: ${businessType} (${getBusinessTypeName(businessType)})\n`;
- displayContent += `请求URL: http://localhost:8321/readcard/entry?param=jiangsu_face_${businessType}\n`;
- displayContent += `调用时间: ${new Date().toLocaleString()}\n`;
- displayContent += `响应时间: ${responseTime}ms\n`;
- displayContent += `HTTP状态: ${httpStatus}\n\n`;
- // 响应结果
- displayContent += '=== 接口返回数据 ===\n';
- displayContent += JSON.stringify(result, null, 2);
- // 成功时的额外信息
- if (result.code === 200 && result.data) {
- try {
- const dataObj = JSON.parse(result.data);
- if (dataObj.data) {
- displayContent += '\n\n=== 医保身份信息 ===\n';
- if (dataObj.data.userName) displayContent += `姓名: ${dataObj.data.userName}\n`;
- if (dataObj.data.idNo) displayContent += `身份证号: ${dataObj.data.idNo}\n`;
- if (dataObj.data.ecToken) displayContent += `医保Token: ${dataObj.data.ecToken}\n`;
- if (dataObj.data.insuOrg) displayContent += `参保地区: ${dataObj.data.insuOrg}\n`;
- }
- } catch (e) {
- // 数据解析失败时忽略
- }
- }
- resultElement.textContent = displayContent;
- }
- // 获取业务类型名称
- function getBusinessTypeName(businessType) {
- const businessTypes = {
- '01101': '门诊挂号',
- '01102': '住院建档',
- '01103': '入院登记',
- '01104': '缴纳预缴金',
- '01201': '问诊',
- '01202': '预约检查',
- '01203': '检查',
- '01204': '治疗',
- '01301': '门诊结算',
- '01302': '取药',
- '02121': '药店购药',
- '02122': '下载外购处方',
- '02123': '特殊门诊',
- '02124': '药师审核处方'
- };
- return businessTypes[businessType] || '未知业务类型';
- }
- </script>
- </body>
- </html>
|