feat: Enhance API path handling and normalize company industry names
This commit is contained in:
@@ -104,11 +104,19 @@
|
||||
});
|
||||
}
|
||||
|
||||
// 反向代理子路径(如 /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 apiUrl() {
|
||||
if (deviceCode) {
|
||||
return '/app/outdoor-fair/company-page?deviceCode=' + encodeURIComponent(deviceCode);
|
||||
return apiBase() + '/app/outdoor-fair/company-page?deviceCode=' + encodeURIComponent(deviceCode);
|
||||
}
|
||||
return '/app/outdoor-fair/' + encodeURIComponent(fairId) + '/companies/' + encodeURIComponent(companyId) + '/page';
|
||||
return apiBase() + '/app/outdoor-fair/' + encodeURIComponent(fairId) + '/companies/' + encodeURIComponent(companyId) + '/page';
|
||||
}
|
||||
|
||||
function fetchJson(url) {
|
||||
@@ -118,7 +126,7 @@
|
||||
}
|
||||
|
||||
function fetchDict(dictType) {
|
||||
return fetchJson('/app/common/dict/' + encodeURIComponent(dictType)).then(function (body) {
|
||||
return fetchJson(apiBase() + '/app/common/dict/' + encodeURIComponent(dictType)).then(function (body) {
|
||||
if (body.code !== 200 || !Array.isArray(body.data)) {
|
||||
return {};
|
||||
}
|
||||
@@ -157,7 +165,7 @@
|
||||
'</section>' +
|
||||
'<div class="actions">' +
|
||||
'<button type="button" class="btn checkin" id="checkinBtn">签到</button>' +
|
||||
'<a class="btn" href="' + escapeHtml(data.fairH5Url) + '">查看招聘会</a>' +
|
||||
'<a class="btn" href="' + escapeHtml(apiBase() + '/h5/outdoor-fair/detail.html?fairId=' + pageFairId) + '">查看招聘会</a>' +
|
||||
'</div>' +
|
||||
'<section class="section">' +
|
||||
'<h2>企业信息</h2>' +
|
||||
@@ -245,7 +253,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() })
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user