test_jiangsu_face.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>江苏医保刷脸功能测试页面</title>
  7. <style>
  8. * {
  9. margin: 0;
  10. padding: 0;
  11. box-sizing: border-box;
  12. }
  13. body {
  14. font-family: 'Microsoft YaHei', sans-serif;
  15. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  16. min-height: 100vh;
  17. padding: 20px;
  18. }
  19. .container {
  20. max-width: 1200px;
  21. margin: 0 auto;
  22. background: white;
  23. border-radius: 15px;
  24. box-shadow: 0 20px 60px rgba(0,0,0,0.1);
  25. overflow: hidden;
  26. }
  27. .header {
  28. background: linear-gradient(135deg, #8e44ad 0%, #3498db 100%);
  29. color: white;
  30. padding: 30px;
  31. text-align: center;
  32. }
  33. .header h1 {
  34. font-size: 2.5em;
  35. margin-bottom: 10px;
  36. font-weight: 600;
  37. }
  38. .header p {
  39. font-size: 1.1em;
  40. opacity: 0.9;
  41. }
  42. .content {
  43. padding: 40px;
  44. }
  45. .info-section {
  46. background: #f8f9fa;
  47. border-radius: 10px;
  48. padding: 25px;
  49. margin-bottom: 30px;
  50. border-left: 5px solid #8e44ad;
  51. }
  52. .info-section h3 {
  53. color: #2c3e50;
  54. margin-bottom: 15px;
  55. font-size: 1.3em;
  56. }
  57. .test-section {
  58. background: white;
  59. border-radius: 10px;
  60. padding: 30px;
  61. margin-bottom: 30px;
  62. border: 1px solid #e9ecef;
  63. }
  64. .test-buttons {
  65. display: grid;
  66. grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  67. gap: 20px;
  68. margin-bottom: 30px;
  69. }
  70. .test-btn {
  71. background: linear-gradient(135deg, #8e44ad 0%, #9b59b6 100%);
  72. color: white;
  73. border: none;
  74. padding: 15px 25px;
  75. border-radius: 8px;
  76. font-size: 1.1em;
  77. cursor: pointer;
  78. transition: all 0.3s ease;
  79. text-align: center;
  80. }
  81. .test-btn:hover {
  82. transform: translateY(-2px);
  83. box-shadow: 0 8px 25px rgba(142, 68, 173, 0.3);
  84. }
  85. .result-area {
  86. background: #f8f9fa;
  87. border-radius: 8px;
  88. padding: 20px;
  89. margin-top: 20px;
  90. min-height: 200px;
  91. font-family: 'Courier New', monospace;
  92. white-space: pre-wrap;
  93. border: 1px solid #dee2e6;
  94. }
  95. .success {
  96. background: #d4edda;
  97. color: #155724;
  98. border: 1px solid #c3e6cb;
  99. }
  100. .error {
  101. background: #f8d7da;
  102. color: #721c24;
  103. border: 1px solid #f5c6cb;
  104. }
  105. .loading {
  106. display: none;
  107. text-align: center;
  108. padding: 20px;
  109. color: #8e44ad;
  110. }
  111. .spinner {
  112. border: 3px solid #f3f3f3;
  113. border-top: 3px solid #8e44ad;
  114. border-radius: 50%;
  115. width: 30px;
  116. height: 30px;
  117. animation: spin 1s linear infinite;
  118. margin: 0 auto 10px;
  119. }
  120. @keyframes spin {
  121. 0% { transform: rotate(0deg); }
  122. 100% { transform: rotate(360deg); }
  123. }
  124. </style>
  125. </head>
  126. <body>
  127. <div class="container">
  128. <div class="header">
  129. <h1>江苏医保刷脸功能测试</h1>
  130. <p>使用NationECCode.dll实现 - 与泰和完全一致的刷脸授权获取医保身份功能</p>
  131. </div>
  132. <div class="content">
  133. <!-- 实现说明 -->
  134. <div class="info-section">
  135. <h3>💡 实现说明</h3>
  136. <p>✓ 使用相同的NationECCode.dll动态库</p>
  137. <p>✓ 相同的两步式认证流程:cn.nhsa.ec.auth → cn.nhsa.auth.check</p>
  138. <p>✓ 相同的服务地址和机构编号(写死参数)</p>
  139. <p>✓ 完全符合国家医保电子凭证业务标准动态库交互规范</p>
  140. <p>✓ 唯一区别:使用江苏医保的配置参数而非泰和配置</p>
  141. </div>
  142. <!-- 测试按钮 -->
  143. <div class="test-section">
  144. <h3>🧪 功能测试</h3>
  145. <div class="test-buttons">
  146. <button class="test-btn" onclick="testFaceAuth('01101')">
  147. 门诊挂号 (01101)
  148. </button>
  149. <button class="test-btn" onclick="testFaceAuth('01301')">
  150. 门诊结算 (01301)
  151. </button>
  152. <button class="test-btn" onclick="testFaceAuth('02121')">
  153. 药店购药 (02121)
  154. </button>
  155. <button class="test-btn" onclick="testFaceAuth('01102')">
  156. 住院建档 (01102)
  157. </button>
  158. <button class="test-btn" onclick="testFaceAuth('01103')">
  159. 入院登记 (01103)
  160. </button>
  161. <button class="test-btn" onclick="testFaceAuth('01104')">
  162. 缴纳预缴金 (01104)
  163. </button>
  164. </div>
  165. <!-- 加载指示器 -->
  166. <div class="loading" id="loading">
  167. <div class="spinner"></div>
  168. <p>正在进行江苏医保刷脸认证...</p>
  169. <p style="font-size: 12px; color: #666; margin-top: 5px;">请耐心等待,刷脸操作可能需要60秒</p>
  170. </div>
  171. <!-- 结果显示区域 -->
  172. <div id="result" class="result-area">
  173. 🎯 江苏医保刷脸功能测试页面
  174. 📋 实现说明:
  175. • 使用NationECCode.dll动态库(与泰和完全一致)
  176. • 两步式认证:cn.nhsa.ec.auth + cn.nhsa.auth.check
  177. • 写死配置参数:机构编号H32132200561
  178. • 符合国家医保电子凭证业务标准规范
  179. 🚀 点击上方按钮开始测试不同业务类型的刷脸功能
  180. ⚠️ 注意:测试前请确保:
  181. 1. NationECCode.dll已正确部署
  182. 2. 刷脸设备正常工作
  183. 3. 网络连接正常
  184. 4. 服务地址可访问
  185. </div>
  186. </div>
  187. </div>
  188. </div>
  189. <script>
  190. // 测试江苏医保刷脸功能
  191. async function testFaceAuth(businessType) {
  192. const loadingElement = document.getElementById('loading');
  193. const resultElement = document.getElementById('result');
  194. // 显示加载状态
  195. loadingElement.style.display = 'block';
  196. resultElement.innerHTML = '';
  197. resultElement.className = 'result-area';
  198. try {
  199. const startTime = new Date();
  200. const url = `http://localhost:8321/readcard/entry?param=jiangsu_face_${businessType}`;
  201. console.log('发起江苏医保刷脸请求:', {
  202. url: url,
  203. businessType: businessType,
  204. timestamp: startTime.toLocaleString()
  205. });
  206. // 添加AbortController用于超时控制
  207. const controller = new AbortController();
  208. const timeoutId = setTimeout(() => controller.abort(), 60000); // 60秒超时(增加超时时间)
  209. const response = await fetch(url, {
  210. method: 'GET',
  211. headers: {
  212. 'Content-Type': 'application/json'
  213. },
  214. signal: controller.signal
  215. });
  216. clearTimeout(timeoutId);
  217. const endTime = new Date();
  218. const responseTime = endTime - startTime;
  219. let result;
  220. try {
  221. result = await response.json();
  222. } catch (e) {
  223. const responseText = await response.text();
  224. result = {
  225. code: 1001,
  226. message: '响应解析失败: ' + e.message,
  227. rawResponse: responseText
  228. };
  229. }
  230. // 隐藏加载状态
  231. loadingElement.style.display = 'none';
  232. // 显示结果
  233. displayResult(result, businessType, responseTime, response.status);
  234. } catch (error) {
  235. // 隐藏加载状态
  236. loadingElement.style.display = 'none';
  237. // 处理不同类型的错误
  238. let errorResult;
  239. if (error.name === 'AbortError') {
  240. errorResult = {
  241. code: 1001,
  242. message: '请求超时(60秒): 刷脸操作可能需要更长时间,请耐心等待或重试',
  243. error: 'NetworkTimeout',
  244. suggestion: '1. 确认刷脸设备正常工作 2. 检查网络连接 3. 重新尝试刷脸操作 4. 如果问题持续,请检查DLL配置',
  245. timestamp: new Date().toLocaleString()
  246. };
  247. } else {
  248. errorResult = {
  249. code: 1001,
  250. message: '网络请求失败: ' + error.message,
  251. error: error.name,
  252. timestamp: new Date().toLocaleString()
  253. };
  254. }
  255. displayResult(errorResult, businessType, 0, 0, true);
  256. }
  257. }
  258. // 显示测试结果
  259. function displayResult(result, businessType, responseTime, httpStatus, isError = false) {
  260. const resultElement = document.getElementById('result');
  261. // 设置样式
  262. if (isError || (result.code && result.code !== 200)) {
  263. resultElement.className = 'result-area error';
  264. } else if (result.code === 200) {
  265. resultElement.className = 'result-area success';
  266. } else {
  267. resultElement.className = 'result-area';
  268. }
  269. // 构建显示内容
  270. let displayContent = '';
  271. displayContent += '=== 江苏医保刷脸测试结果 ===\n\n';
  272. displayContent += `业务类型: ${businessType} (${getBusinessTypeName(businessType)})\n`;
  273. displayContent += `请求URL: http://localhost:8321/readcard/entry?param=jiangsu_face_${businessType}\n`;
  274. displayContent += `调用时间: ${new Date().toLocaleString()}\n`;
  275. displayContent += `响应时间: ${responseTime}ms\n`;
  276. displayContent += `HTTP状态: ${httpStatus}\n\n`;
  277. // 响应结果
  278. displayContent += '=== 接口返回数据 ===\n';
  279. displayContent += JSON.stringify(result, null, 2);
  280. // 成功时的额外信息
  281. if (result.code === 200 && result.data) {
  282. try {
  283. const dataObj = JSON.parse(result.data);
  284. if (dataObj.data) {
  285. displayContent += '\n\n=== 医保身份信息 ===\n';
  286. if (dataObj.data.userName) displayContent += `姓名: ${dataObj.data.userName}\n`;
  287. if (dataObj.data.idNo) displayContent += `身份证号: ${dataObj.data.idNo}\n`;
  288. if (dataObj.data.ecToken) displayContent += `医保Token: ${dataObj.data.ecToken}\n`;
  289. if (dataObj.data.insuOrg) displayContent += `参保地区: ${dataObj.data.insuOrg}\n`;
  290. }
  291. } catch (e) {
  292. // 数据解析失败时忽略
  293. }
  294. }
  295. resultElement.textContent = displayContent;
  296. }
  297. // 获取业务类型名称
  298. function getBusinessTypeName(businessType) {
  299. const businessTypes = {
  300. '01101': '门诊挂号',
  301. '01102': '住院建档',
  302. '01103': '入院登记',
  303. '01104': '缴纳预缴金',
  304. '01201': '问诊',
  305. '01202': '预约检查',
  306. '01203': '检查',
  307. '01204': '治疗',
  308. '01301': '门诊结算',
  309. '01302': '取药',
  310. '02121': '药店购药',
  311. '02122': '下载外购处方',
  312. '02123': '特殊门诊',
  313. '02124': '药师审核处方'
  314. };
  315. return businessTypes[businessType] || '未知业务类型';
  316. }
  317. </script>
  318. </body>
  319. </html>