test_jiangsu_face.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  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. </div>
  170. <!-- 结果显示区域 -->
  171. <div id="result" class="result-area">
  172. 🎯 江苏医保刷脸功能测试页面
  173. 📋 实现说明:
  174. • 使用NationECCode.dll动态库(与泰和完全一致)
  175. • 两步式认证:cn.nhsa.ec.auth + cn.nhsa.auth.check
  176. • 写死配置参数:机构编号H32132200561
  177. • 符合国家医保电子凭证业务标准规范
  178. 🚀 点击上方按钮开始测试不同业务类型的刷脸功能
  179. ⚠️ 注意:测试前请确保:
  180. 1. NationECCode.dll已正确部署
  181. 2. 刷脸设备正常工作
  182. 3. 网络连接正常
  183. 4. 服务地址可访问
  184. </div>
  185. </div>
  186. </div>
  187. </div>
  188. <script>
  189. // 测试江苏医保刷脸功能
  190. async function testFaceAuth(businessType) {
  191. const loadingElement = document.getElementById('loading');
  192. const resultElement = document.getElementById('result');
  193. // 显示加载状态
  194. loadingElement.style.display = 'block';
  195. resultElement.innerHTML = '';
  196. resultElement.className = 'result-area';
  197. try {
  198. const startTime = new Date();
  199. const url = `http://localhost:8321/readcard/entry?param=jiangsu_face_${businessType}`;
  200. console.log('发起江苏医保刷脸请求:', {
  201. url: url,
  202. businessType: businessType,
  203. timestamp: startTime.toLocaleString()
  204. });
  205. // 创建一个带超时的fetch请求(30秒超时)
  206. const controller = new AbortController();
  207. const timeoutId = setTimeout(() => controller.abort(), 30000); // 30秒超时
  208. const response = await fetch(url, {
  209. method: 'GET',
  210. headers: {
  211. 'Content-Type': 'application/json'
  212. },
  213. signal: controller.signal
  214. });
  215. clearTimeout(timeoutId);
  216. const endTime = new Date();
  217. const responseTime = endTime - startTime;
  218. let result;
  219. try {
  220. result = await response.json();
  221. } catch (e) {
  222. const responseText = await response.text();
  223. result = {
  224. code: 1001,
  225. message: '响应解析失败: ' + e.message,
  226. rawResponse: responseText
  227. };
  228. }
  229. // 隐藏加载状态
  230. loadingElement.style.display = 'none';
  231. // 显示结果
  232. displayResult(result, businessType, responseTime, response.status);
  233. } catch (error) {
  234. // 隐藏加载状态
  235. loadingElement.style.display = 'none';
  236. // 显示错误
  237. const errorResult = {
  238. code: 1001,
  239. message: '网络请求失败: ' + error.message,
  240. error: error.name,
  241. timestamp: new Date().toLocaleString()
  242. };
  243. displayResult(errorResult, businessType, 0, 0, true);
  244. }
  245. }
  246. // 显示测试结果
  247. function displayResult(result, businessType, responseTime, httpStatus, isError = false) {
  248. const resultElement = document.getElementById('result');
  249. // 设置样式
  250. if (isError || (result.code && result.code !== 200)) {
  251. resultElement.className = 'result-area error';
  252. } else if (result.code === 200) {
  253. resultElement.className = 'result-area success';
  254. } else {
  255. resultElement.className = 'result-area';
  256. }
  257. // 构建显示内容
  258. let displayContent = '';
  259. displayContent += '=== 江苏医保刷脸测试结果 ===\n\n';
  260. displayContent += `业务类型: ${businessType} (${getBusinessTypeName(businessType)})\n`;
  261. displayContent += `请求URL: http://localhost:8321/readcard/entry?param=jiangsu_face_${businessType}\n`;
  262. displayContent += `调用时间: ${new Date().toLocaleString()}\n`;
  263. displayContent += `响应时间: ${responseTime}ms\n`;
  264. displayContent += `HTTP状态: ${httpStatus}\n\n`;
  265. // 响应结果
  266. displayContent += '=== 接口返回数据 ===\n';
  267. displayContent += JSON.stringify(result, null, 2);
  268. // 成功时的额外信息
  269. if (result.code === 200 && result.data) {
  270. try {
  271. const dataObj = JSON.parse(result.data);
  272. if (dataObj.data) {
  273. displayContent += '\n\n=== 医保身份信息 ===\n';
  274. if (dataObj.data.userName) displayContent += `姓名: ${dataObj.data.userName}\n`;
  275. if (dataObj.data.idNo) displayContent += `身份证号: ${dataObj.data.idNo}\n`;
  276. if (dataObj.data.ecToken) displayContent += `医保Token: ${dataObj.data.ecToken}\n`;
  277. if (dataObj.data.insuOrg) displayContent += `参保地区: ${dataObj.data.insuOrg}\n`;
  278. }
  279. } catch (e) {
  280. // 数据解析失败时忽略
  281. }
  282. }
  283. resultElement.textContent = displayContent;
  284. }
  285. // 获取业务类型名称
  286. function getBusinessTypeName(businessType) {
  287. const businessTypes = {
  288. '01101': '门诊挂号',
  289. '01102': '住院建档',
  290. '01103': '入院登记',
  291. '01104': '缴纳预缴金',
  292. '01201': '问诊',
  293. '01202': '预约检查',
  294. '01203': '检查',
  295. '01204': '治疗',
  296. '01301': '门诊结算',
  297. '01302': '取药',
  298. '02121': '药店购药',
  299. '02122': '下载外购处方',
  300. '02123': '特殊门诊',
  301. '02124': '药师审核处方'
  302. };
  303. return businessTypes[businessType] || '未知业务类型';
  304. }
  305. </script>
  306. </body>
  307. </html>