|
|
@@ -114,7 +114,7 @@
|
|
|
<!-- 全局工具栏 -->
|
|
|
<div class="toolbar">
|
|
|
<label>API 基础地址</label>
|
|
|
- <label for="baseUrl"></label><input type="text" id="baseUrl" value="http://localhost:8002" style="flex:1;">
|
|
|
+ <label for="baseUrl"></label><input type="text" id="baseUrl" value="http://8.135.32.236:8001" style="flex:1;">
|
|
|
</div>
|
|
|
|
|
|
<!-- 用户侧登录区 -->
|
|
|
@@ -199,6 +199,8 @@
|
|
|
<div class="module-tab" data-module="platform-account">9.平台账号</div>
|
|
|
<div class="module-tab" data-module="business-license">10.营业执照</div>
|
|
|
<div class="module-tab" data-module="platform-config">11.平台配置</div>
|
|
|
+ <div class="module-tab" data-module="search-record">12.搜索记录</div>
|
|
|
+ <div class="module-tab" data-module="platform-session">13.平台会话</div>
|
|
|
</div>
|
|
|
|
|
|
<!-- 运营侧模块标签栏 -->
|
|
|
@@ -296,6 +298,8 @@ async function runTest(sectionId, method, path, body, requireAuth, validatorName
|
|
|
|
|
|
// 检测响应中的二维码并渲染图片预览
|
|
|
const qrBase64 = result.data?.data?.qrCodeBase64;
|
|
|
+ const payUrl = result.data?.data?.payUrl;
|
|
|
+ const channel = result.data?.data?.channel;
|
|
|
let qrBox = document.getElementById(sectionId + '-qrcode');
|
|
|
if (qrBase64) {
|
|
|
if (!qrBox) {
|
|
|
@@ -304,7 +308,14 @@ async function runTest(sectionId, method, path, body, requireAuth, validatorName
|
|
|
qrBox.style.cssText = 'text-align:center;padding:12px;background:#fff;border-radius:4px;margin-top:8px;';
|
|
|
rawEl.parentNode.insertBefore(qrBox, rawEl.nextSibling);
|
|
|
}
|
|
|
- qrBox.innerHTML = '<img src="' + qrBase64 + '" style="max-width:220px;border:1px solid #eee;border-radius:4px;"><div style="margin-top:6px;font-size:12px;color:#666;">支付二维码(扫码付款后回调自动激活,也可手动确认支付测试回调)</div>';
|
|
|
+ // 支付宝电脑网站支付:payUrl是跳转链接/表单,显示跳转按钮+二维码
|
|
|
+ if (channel === 'ALIPAY' && payUrl) {
|
|
|
+ qrBox.innerHTML = '<img src="' + qrBase64 + '" style="max-width:180px;border:1px solid #eee;border-radius:4px;opacity:0.5;">'
|
|
|
+ + '<div style="margin-top:8px;"><a href="' + payUrl + '" target="_blank" style="display:inline-block;padding:8px 20px;background:#1677ff;color:#fff;border-radius:4px;text-decoration:none;font-size:14px;">点击跳转支付宝收银台</a></div>'
|
|
|
+ + '<div style="margin-top:6px;font-size:12px;color:#999;">支付宝电脑网站支付(页面跳转模式,也可手动确认支付测试回调)</div>';
|
|
|
+ } else {
|
|
|
+ qrBox.innerHTML = '<img src="' + qrBase64 + '" style="max-width:220px;border:1px solid #eee;border-radius:4px;"><div style="margin-top:6px;font-size:12px;color:#666;">支付二维码(扫码付款后回调自动激活,也可手动确认支付测试回调)</div>';
|
|
|
+ }
|
|
|
|
|
|
// 自动回填订单号到相关输入框
|
|
|
const orderNo = result.data?.data?.orderNo;
|
|
|
@@ -553,6 +564,8 @@ function renderModule(module) {
|
|
|
case 'platform-account': html = renderPlatformAccountModule(); break;
|
|
|
case 'business-license': html = renderBusinessLicenseModule(); break;
|
|
|
case 'platform-config': html = renderPlatformConfigModule(); break;
|
|
|
+ case 'search-record': html = renderSearchRecordModule(); break;
|
|
|
+ case 'platform-session': html = renderPlatformSessionModule(); break;
|
|
|
// 运营侧模块
|
|
|
case 'admin-membership': html = renderAdminMembershipModule(); break;
|
|
|
case 'admin-invite': html = renderAdminInviteModule(); break;
|
|
|
@@ -1224,12 +1237,8 @@ function renderSearchModule() {
|
|
|
</div>
|
|
|
${testSection('search-query', '药品搜索', 'POST', 'post', '/api/search/query', '需认证', 'auth-required',
|
|
|
[{label:'关键词(keyword)', name:'keyword', placeholder:'阿莫西林胶囊', default:'阿莫西林胶囊'},
|
|
|
- {label:'平台(platform,可选)', name:'platform', placeholder:'yaoshibang', default:''}], true, null, '搜索药品比价,消耗每日配额,返回各平台价格列表')}
|
|
|
- ${testSection('search-suggestions', '搜索建议', 'GET', 'get', '/api/search/suggestions', '公开', 'auth-public', null, true, null, '获取热门药品搜索建议列表(无需认证)')}
|
|
|
- ${testSection('search-history', '搜索历史', 'GET', 'get', '/api/search/history', '需认证', 'auth-required', null, true, null, '获取当前用户的搜索历史记录')}
|
|
|
- ${testSection('search-history-delete', '删除历史', 'DELETE', 'delete', '/api/search/history/{id}', '需认证', 'auth-required',
|
|
|
- [{label:'记录ID(id)', name:'id', placeholder:'1', default:'1'}], false, null, '删除指定搜索历史记录')}
|
|
|
- ${testSection('search-history-clear', '清空历史', 'DELETE', 'delete', '/api/search/history', '需认证', 'auth-required', null, false, null, '清空当前用户的所有搜索历史')}`;
|
|
|
+ {label:'平台列表(platforms,可选)', name:'platforms', placeholder:'yaoshibang,yaobangmang,yiyaocheng', default:'', type:'array'}], true, null, '搜索药品比价,消耗每日配额,返回各平台价格列表。platforms传多个平台代码用逗号分隔,不传则查询全部平台')}
|
|
|
+ ${testSection('search-suggestions', '搜索建议', 'GET', 'get', '/api/search/suggestions', '公开', 'auth-public', null, true, null, '获取热门药品搜索建议列表(无需认证)')}`;
|
|
|
}
|
|
|
|
|
|
function renderPlatformAccountModule() {
|
|
|
@@ -1272,6 +1281,41 @@ function renderPlatformConfigModule() {
|
|
|
[{label:'平台代码(platformCode)', name:'platformCode', placeholder:'yaoshibang', default:'yaoshibang'}], true, 'platformConfig', '获取指定平台的详细配置信息')}`;
|
|
|
}
|
|
|
|
|
|
+function renderSearchRecordModule() {
|
|
|
+ return `
|
|
|
+ <div class="batch-buttons">
|
|
|
+ <button class="btn btn-warning btn-sm" onclick="runSearchRecordTests()">运行全部搜索记录测试</button>
|
|
|
+ </div>
|
|
|
+ ${testSection('sr-save', '保存搜索记录', 'POST', 'post', '/api/search-record/history', '需认证', 'auth-required',
|
|
|
+ [{label:'药品名称(drugName)', name:'drugName', placeholder:'阿莫西林', default:'阿莫西林'},
|
|
|
+ {label:'状态文案(statusText)', name:'statusText', placeholder:'已返回 2 个平台的可比价结果。', default:'已返回 2 个平台的可比价结果。'},
|
|
|
+ {label:'平台结果(platformResults)', name:'platformResults', placeholder:'[{"platformId":"yiyaocheng","platformName":"壹药城"}]', default:'[{"platformId":"yiyaocheng","platformName":"壹药城","response":{"status":"ok","products":[]}}]', type:'json'},
|
|
|
+ {label:'搜索日志(searchLog)', name:'searchLog', placeholder:'null', default:'null', type:'json'}], true, null, '保存一次完整的比价搜索快照,包含平台响应数据。platformResults和searchLog支持任意JSON结构')}
|
|
|
+ ${testSection('sr-list', '搜索记录列表', 'GET', 'get', '/api/search-record/history?limit={limit}', '需认证', 'auth-required',
|
|
|
+ [{label:'条数(limit)', name:'limit', placeholder:'20', default:'20'}], true, null, '获取当前用户最近的搜索记录,默认20条,最多50条')}
|
|
|
+ ${testSection('sr-detail', '记录详情', 'GET', 'get', '/api/search-record/history/{id}', '需认证', 'auth-required',
|
|
|
+ [{label:'记录ID(id)', name:'id', placeholder:'1', default:'1'}], true, null, '读取单条搜索记录详情(包含完整的platformResults)')}
|
|
|
+ ${testSection('sr-delete', '删除记录', 'DELETE', 'delete', '/api/search-record/history/{id}', '需认证', 'auth-required',
|
|
|
+ [{label:'记录ID(id)', name:'id', placeholder:'1', default:'1'}], false, null, '删除单条搜索记录(幂等,不存在也返回成功)')}
|
|
|
+ ${testSection('sr-clear', '清空记录', 'DELETE', 'delete', '/api/search-record/history', '需认证', 'auth-required', null, false, null, '清空当前用户全部搜索记录')}`;
|
|
|
+}
|
|
|
+
|
|
|
+function renderPlatformSessionModule() {
|
|
|
+ return `
|
|
|
+ <div class="batch-buttons">
|
|
|
+ <button class="btn btn-warning btn-sm" onclick="runPlatformSessionTests()">运行全部平台会话测试</button>
|
|
|
+ </div>
|
|
|
+ ${testSection('ps-upload', '上传平台会话', 'PUT', 'put', '/api/platform-session/{platformCode}', '需认证', 'auth-required',
|
|
|
+ [{label:'平台代码(platformCode)', name:'platformCode', placeholder:'yiyaocheng', default:'yiyaocheng'},
|
|
|
+ {label:'平台名称(platformName)', name:'platformName', placeholder:'壹药城', default:'壹药城'},
|
|
|
+ {label:'账号标签(accountLabel)', name:'accountLabel', placeholder:'深圳大方无限科技有限公司', default:'测试账号'},
|
|
|
+ {label:'登录URL(loginUrl)', name:'loginUrl', placeholder:'https://mall.yaoex.com/login', default:'https://mall.yaoex.com/login'},
|
|
|
+ {label:'cookies(JSON数组)', name:'cookies', placeholder:'[{"name":"session","value":"xxx"}]', default:'[{"name":"mall_session","value":"test-cookie-value","domain":".mall.yaoex.com","path":"/","secure":true,"httpOnly":true,"expirationDate":1800000000}]', type:'json'}], true, null, '上传或覆盖当前用户某个平台的Cookie会话快照,Cookie会加密存储。platformCode必须与路径中的一致')}
|
|
|
+ ${testSection('ps-list', '平台会话列表', 'GET', 'get', '/api/platform-session/list', '需认证', 'auth-required', null, true, null, '获取当前用户所有已保存的平台会话(Cookie已解密),用于启动时恢复登录态')}
|
|
|
+ ${testSection('ps-delete', '删除平台会话', 'DELETE', 'delete', '/api/platform-session/{platformCode}', '需认证', 'auth-required',
|
|
|
+ [{label:'平台代码(platformCode)', name:'platformCode', placeholder:'yiyaocheng', default:'yiyaocheng'}], false, null, '删除某个平台的远端会话(幂等,不存在也返回成功)')}`;
|
|
|
+}
|
|
|
+
|
|
|
// ==================== 运营侧模块 ====================
|
|
|
function renderAdminMembershipModule() {
|
|
|
return `
|
|
|
@@ -1519,6 +1563,8 @@ function runSearchTests() { runBatchTests('search'); }
|
|
|
function runPlatformAccountTests() { runBatchTests('pa'); }
|
|
|
function runBusinessLicenseTests() { runBatchTests('bl'); }
|
|
|
function runPlatformConfigTests() { runBatchTests('pc'); }
|
|
|
+function runSearchRecordTests() { runBatchTests('sr'); }
|
|
|
+function runPlatformSessionTests() { runBatchTests('ps'); }
|
|
|
// 运营侧快捷批量运行
|
|
|
function runAdminMembershipTests() { runBatchTests('admin-membership'); }
|
|
|
function runAdminInviteTests() { runBatchTests('admin-invite'); }
|
|
|
@@ -1605,6 +1651,16 @@ function validate_paymentOrders(result) { return result.data?.code === 200 && Ar
|
|
|
function validate_searchQuery(result) { return result.data?.code === 200 && result.data?.data?.prices !== undefined; }
|
|
|
function validate_searchSuggestions(result) { return result.data?.code === 200 && Array.isArray(result.data?.data) && result.data?.data?.length > 0; }
|
|
|
function validate_searchHistory(result) { return result.data?.code === 200 && Array.isArray(result.data?.data); }
|
|
|
+function validate_searchSave(result) { return result.data?.code === 200 && result.data?.data?.keyword; }
|
|
|
+function validate_searchRecords(result) { return result.data?.code === 200 && result.data?.data?.records !== undefined; }
|
|
|
+
|
|
|
+// 搜索记录模块验证器
|
|
|
+function validate_srSave(result) { return result.data?.code === 200 && result.data?.data?.id && result.data?.data?.drugName; }
|
|
|
+function validate_srList(result) { return result.data?.code === 200 && Array.isArray(result.data?.data); }
|
|
|
+function validate_srDetail(result) { return result.data?.code === 200 && result.data?.data?.id; }
|
|
|
+// 平台会话模块验证器
|
|
|
+function validate_psUpload(result) { return result.data?.code === 200 && result.data?.data?.platformCode; }
|
|
|
+function validate_psList(result) { return result.data?.code === 200 && Array.isArray(result.data?.data); }
|
|
|
|
|
|
// ===================== 初始化 =====================
|
|
|
window.addEventListener('DOMContentLoaded', () => {
|