123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273 |
- <!DOCTYPE html>
- <html lang="zh-CN">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>江苏医保电子凭证解码调用示例</title>
- <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
- <style>
- body {
- font-family: 'Microsoft YaHei', Arial, sans-serif;
- max-width: 800px;
- margin: 0 auto;
- padding: 20px;
- background-color: #f5f5f5;
- }
- .container {
- background: white;
- padding: 30px;
- border-radius: 10px;
- box-shadow: 0 2px 10px rgba(0,0,0,0.1);
- }
- h1 {
- color: #2c5aa0;
- text-align: center;
- margin-bottom: 30px;
- }
- .form-group {
- margin-bottom: 15px;
- }
- label {
- display: block;
- margin-bottom: 5px;
- font-weight: bold;
- color: #333;
- }
- input, select {
- width: 100%;
- padding: 10px;
- border: 1px solid #ddd;
- border-radius: 5px;
- box-sizing: border-box;
- }
- .btn {
- background-color: #2c5aa0;
- color: white;
- padding: 12px 30px;
- border: none;
- border-radius: 5px;
- cursor: pointer;
- font-size: 16px;
- margin-right: 10px;
- margin-top: 10px;
- }
- .btn:hover {
- background-color: #1e3d6f;
- }
- .btn-success {
- background-color: #28a745;
- }
- .btn-success:hover {
- background-color: #1e7e34;
- }
- .result {
- margin-top: 20px;
- padding: 15px;
- border-radius: 5px;
- white-space: pre-wrap;
- font-family: 'Courier New', monospace;
- }
- .success {
- background-color: #d4edda;
- border: 1px solid #c3e6cb;
- color: #155724;
- }
- .error {
- background-color: #f8d7da;
- border: 1px solid #f5c6cb;
- color: #721c24;
- }
- .info {
- background-color: #e2e3e5;
- border: 1px solid #d6d8db;
- color: #383d41;
- }
- .patient-info {
- background-color: #fff3cd;
- border: 1px solid #ffeaa7;
- color: #856404;
- padding: 15px;
- border-radius: 5px;
- margin-top: 15px;
- }
- .patient-info h3 {
- margin-top: 0;
- color: #856404;
- }
- </style>
- </head>
- <body>
- <div class="container">
- <h1>🏥 江苏医保电子凭证解码接口调用示例</h1>
-
- <div class="form-group">
- <label for="serverUrl">服务器地址:</label>
- <input type="text" id="serverUrl" value="http://localhost:8321" placeholder="例如: http://localhost:8321">
- </div>
- <div class="form-group">
- <label for="businessType">业务类型:</label>
- <select id="businessType">
- <option value="01101">01101 - 门诊挂号</option>
- <option value="01102">01102 - 住院建档</option>
- <option value="01103">01103 - 入院登记</option>
- <option value="01201">01201 - 问诊</option>
- <option value="01301">01301 - 门诊结算</option>
- <option value="01302">01302 - 取药</option>
- <option value="02121">02121 - 药店购药</option>
- </select>
- </div>
- <div class="form-group">
- <label for="operatorId">操作员编号:</label>
- <input type="text" id="operatorId" value="OP001" placeholder="操作员编号">
- </div>
- <div class="form-group">
- <label for="operatorName">操作员姓名:</label>
- <input type="text" id="operatorName" value="系统管理员" placeholder="操作员姓名">
- </div>
- <div class="form-group">
- <label for="officeId">科室编号:</label>
- <input type="text" id="officeId" value="32760" placeholder="科室编号">
- </div>
- <div class="form-group">
- <label for="officeName">科室名称:</label>
- <input type="text" id="officeName" value="医保科" placeholder="科室名称">
- </div>
- <button class="btn" onclick="initSystem()">🔧 初始化系统</button>
- <button class="btn btn-success" onclick="decodeElectronicCertificate()">🔍 解码电子凭证</button>
- <button class="btn" onclick="clearResult()">🗑️ 清空结果</button>
- <div id="result"></div>
- </div>
- <script>
- // 初始化系统
- function initSystem() {
- const serverUrl = document.getElementById('serverUrl').value;
- showLoading('正在初始化江苏医保系统...');
- $.ajax({
- url: `${serverUrl}/api/jiangsuec/init`,
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify({
- config: {
- // 可以在这里配置具体的医院参数
- // IP: "10.61.165.3",
- // PORT: 8086,
- // ORG_ID: "H32132200561"
- }
- }),
- timeout: 10000,
- success: function(result) {
- if (result.success) {
- showResult(result, 'success');
- alert('✅ 系统初始化成功!');
- } else {
- showResult(result, 'error');
- alert('❌ 系统初始化失败: ' + result.message);
- }
- },
- error: function(xhr, status, error) {
- const errorMsg = `请求失败: ${error}\n状态: ${status}\nHTTP状态码: ${xhr.status}`;
- showResult({ error: errorMsg }, 'error');
- alert('❌ 网络请求失败,请检查服务器地址是否正确');
- }
- });
- }
- // 解码电子凭证
- function decodeElectronicCertificate() {
- const serverUrl = document.getElementById('serverUrl').value;
- const businessType = document.getElementById('businessType').value;
- const operatorId = document.getElementById('operatorId').value;
- const operatorName = document.getElementById('operatorName').value;
- const officeId = document.getElementById('officeId').value;
- const officeName = document.getElementById('officeName').value;
- showLoading('正在解码江苏医保电子凭证...');
- const requestData = {
- businessType: businessType,
- operatorId: operatorId,
- operatorName: operatorName,
- officeId: officeId,
- officeName: officeName
- };
- $.ajax({
- url: `${serverUrl}/api/jiangsuec/decode`,
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(requestData),
- timeout: 15000,
- success: function(result) {
- if (result.success) {
- showResult(result, 'success');
- showPatientInfo(result.data);
- alert('✅ 电子凭证解码成功!');
- } else {
- showResult(result, 'error');
- alert('❌ 电子凭证解码失败: ' + result.message);
- }
- },
- error: function(xhr, status, error) {
- const errorMsg = `请求失败: ${error}\n状态: ${status}\nHTTP状态码: ${xhr.status}`;
- showResult({ error: errorMsg }, 'error');
- alert('❌ 网络请求失败,请检查服务器地址和网络连接');
- }
- });
- }
- // 显示加载状态
- function showLoading(message) {
- const resultDiv = document.getElementById('result');
- resultDiv.innerHTML = `<div class="result info">⏳ ${message}</div>`;
- }
- // 显示结果
- function showResult(data, type) {
- const resultDiv = document.getElementById('result');
- const jsonStr = JSON.stringify(data, null, 2);
- resultDiv.innerHTML = `<div class="result ${type}">${jsonStr}</div>`;
- }
- // 显示患者信息
- function showPatientInfo(patientData) {
- if (!patientData) return;
- const patientInfoHtml = `
- <div class="patient-info">
- <h3>👤 患者信息</h3>
- <p><strong>姓名:</strong> ${patientData.userName || '未提供'}</p>
- <p><strong>身份证号:</strong> ${patientData.idNo || '未提供'}</p>
- <p><strong>证件类型:</strong> ${patientData.idType || '未提供'}</p>
- <p><strong>性别:</strong> ${patientData.gender || '未提供'}</p>
- <p><strong>出生日期:</strong> ${patientData.birthday || '未提供'}</p>
- <p><strong>参保地区:</strong> ${patientData.insuOrg || '未提供'}</p>
- <p><strong>电子凭证令牌:</strong> ${patientData.ecToken || '未提供'}</p>
- <p><strong>电子凭证索引号:</strong> ${patientData.ecIndexNo || '未提供'}</p>
- </div>
- `;
-
- document.getElementById('result').innerHTML += patientInfoHtml;
- }
- // 清空结果
- function clearResult() {
- document.getElementById('result').innerHTML = '';
- }
- // 页面加载完成后的初始化
- $(document).ready(function() {
- // 可以在这里添加页面初始化逻辑
- console.log('江苏医保电子凭证解码页面已加载');
- });
- </script>
- </body>
- </html>
|