feat: 新增自定义单程票价、站点名称展示及中文事件类型支持
后端调整:支持单程订单使用客户端传入的自定义票价,无需通过系统自动计算 前端优化:新增中文事件类型支持,添加站点编码转中文名称功能,更新日志展示站点中文名称,自动拉取站点列表构建解析映射
This commit is contained in:
+27
-11
@@ -115,22 +115,24 @@
|
||||
|
||||
if (type === 'sale' || type === '售票') {
|
||||
const cost = ev.cost ?? ev.price ?? ev.amount ?? ev["票价"] ?? ev["售票额"] ?? '0';
|
||||
return `机器ID: ${deviceId};票价: ${cost};时间: ${timeStr}`;
|
||||
const code = ev.station_code || ev["站点编号"] || '---';
|
||||
const name = ev.station_name || ev["售票站"] || ev["发生站"] || (typeof getStationName === 'function' && code !== '---' ? getStationName(code) : code);
|
||||
return `机器ID: ${deviceId};站点编号: ${code};站点中文: ${name};票价: ${cost};时间: ${timeStr}`;
|
||||
}
|
||||
if (type === 'entry' || action === 'entry') {
|
||||
const code = ev.station_code || ev["站点编号"] || '---';
|
||||
const name = ev.station_name || ev["站点中文"] || ev["发生站"] || '---';
|
||||
const name = ev.station_name || ev["站点中文"] || ev["发生站"] || (typeof getStationName === 'function' && code !== '---' ? getStationName(code) : code);
|
||||
return `机器ID: ${deviceId};站点编号: ${code};站点中文: ${name};时间: ${timeStr}`;
|
||||
}
|
||||
if (type === 'exit' || action === 'exit') {
|
||||
const code = ev.station_code || ev["站点编号"] || '---';
|
||||
const name = ev.station_name || ev["站点中文"] || ev["发生站"] || '---';
|
||||
const name = ev.station_name || ev["站点中文"] || ev["发生站"] || (typeof getStationName === 'function' && code !== '---' ? getStationName(code) : code);
|
||||
return `机器ID: ${deviceId};站点编号: ${code};站点中文: ${name};时间: ${timeStr}`;
|
||||
}
|
||||
|
||||
// fallback
|
||||
const code = ev.station_code || ev["站点编号"] || '---';
|
||||
const name = ev.station_name || ev["站点中文"] || ev["发生站"] || '---';
|
||||
const name = ev.station_name || ev["站点中文"] || ev["发生站"] || (typeof getStationName === 'function' && code !== '---' ? getStationName(code) : code);
|
||||
return `机器ID: ${deviceId};站点编号: ${code};站点中文: ${name};时间: ${timeStr}`;
|
||||
};
|
||||
|
||||
@@ -302,13 +304,27 @@
|
||||
|
||||
const sp = new URLSearchParams(location.search);
|
||||
const qid = sp.get('id');
|
||||
if (qid) {
|
||||
qEl.value = qid;
|
||||
loadDetail(qid);
|
||||
doSearch();
|
||||
} else {
|
||||
doSearch();
|
||||
let stationMap = {};
|
||||
window.getStationName = (code) => stationMap[code] || code;
|
||||
|
||||
async function init() {
|
||||
try {
|
||||
const res = await fetch('/api/public/stations');
|
||||
const list = await res.json();
|
||||
if (Array.isArray(list)) {
|
||||
list.forEach(s => { stationMap[s.code] = s.name || s.cn_name; });
|
||||
}
|
||||
} catch(e) {}
|
||||
|
||||
if (qid) {
|
||||
qEl.value = qid;
|
||||
loadDetail(qid);
|
||||
doSearch();
|
||||
} else {
|
||||
doSearch();
|
||||
}
|
||||
loadPopular();
|
||||
}
|
||||
loadPopular();
|
||||
init();
|
||||
})();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user