feat: 新增自定义单程票价、站点名称展示及中文事件类型支持
后端调整:支持单程订单使用客户端传入的自定义票价,无需通过系统自动计算 前端优化:新增中文事件类型支持,添加站点编码转中文名称功能,更新日志展示站点中文名称,自动拉取站点列表构建解析映射
This commit is contained in:
+27
-7
@@ -100,16 +100,21 @@
|
||||
}
|
||||
if (type === 'topup' || type === 'refill' || action === 'topup' || type === '充值') {
|
||||
const amount = ev?.amount ?? ev?.["充值数额"] ?? 0;
|
||||
const code = ev?.station_code || ev?.["站点编号"] || '---';
|
||||
const name = ev?.station_name || ev?.["站点中文"] || ev?.["发生站"] || (typeof getStationName === 'function' && code !== '---' ? getStationName(code) : code);
|
||||
if (code !== '---' || ev?.station_name) {
|
||||
return `机器ID: ${deviceId};站点编号: ${code};站点中文: ${name};充值数额: ${amount};余额: ${balance};时间: ${timeStr}`;
|
||||
}
|
||||
return `机器ID: ${deviceId};充值数额: ${amount};余额: ${balance};时间: ${timeStr}`;
|
||||
}
|
||||
if (action === 'entry' || type === 'entry' || type === '进站') {
|
||||
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};余额: ${balance};时间: ${timeStr}`;
|
||||
}
|
||||
if (action === 'exit' || type === 'exit' || type === '出站') {
|
||||
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};余额: ${balance};时间: ${timeStr}`;
|
||||
}
|
||||
|
||||
@@ -261,10 +266,25 @@
|
||||
|
||||
const params = new URLSearchParams(location.search);
|
||||
const q = params.get('q');
|
||||
if (q) {
|
||||
inputEl.value = q;
|
||||
doQuery().catch((error) => renderQueryError(error.message || String(error)));
|
||||
} else {
|
||||
loadAllCards().catch((error) => renderQueryError(error.message || String(error)));
|
||||
|
||||
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 (q) {
|
||||
inputEl.value = q;
|
||||
doQuery().catch((error) => renderQueryError(error.message || String(error)));
|
||||
} else {
|
||||
loadAllCards().catch((error) => renderQueryError(error.message || String(error)));
|
||||
}
|
||||
}
|
||||
init();
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user