feat: Enhance API path handling and normalize company industry names

This commit is contained in:
2026-07-03 13:19:47 +08:00
parent 0024f81484
commit 23b60904e4
4 changed files with 113 additions and 10 deletions

View File

@@ -88,6 +88,14 @@
});
}
// 反向代理子路径(如 /api/shihezi依据当前页面路径推导 API 前缀,
// 保证 /app/... 请求带上子路径,避免落到根路径 404。
function apiBase() {
var path = window.location.pathname;
var idx = path.indexOf('/h5/');
return idx > 0 ? path.slice(0, idx) : '';
}
function render(data) {
var fair = data.fair || {};
pageFairId = (fair.id !== null && fair.id !== undefined) ? fair.id : fairId;
@@ -174,7 +182,7 @@
if (!pageFairId) { showToast('缺少招聘会信息', true); return; }
var submitBtn = document.getElementById('checkinSubmit');
if (submitBtn) submitBtn.disabled = true;
fetch('/app/outdoor-fair/check-in', {
fetch(apiBase() + '/app/outdoor-fair/check-in', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ fairId: Number(pageFairId), name: name.trim(), phone: phone.trim() })
@@ -192,7 +200,7 @@
app.innerHTML = '<div class="error">缺少招聘会参数</div>';
return;
}
fetch('/app/outdoor-fair/' + encodeURIComponent(fairId)).then(function (res) {
fetch(apiBase() + '/app/outdoor-fair/' + encodeURIComponent(fairId)).then(function (res) {
return res.json();
}).then(function (body) {
if (body.code !== 200) {