diff --git a/h5/hyapp/withdraw-exchange/index.html b/h5/hyapp/withdraw-exchange/index.html index dfd7094..f4cfd6e 100644 --- a/h5/hyapp/withdraw-exchange/index.html +++ b/h5/hyapp/withdraw-exchange/index.html @@ -4,7 +4,7 @@ Withdraw/Exchange - +
@@ -165,6 +165,6 @@
- + diff --git a/h5/hyapp/withdraw-exchange/script.js b/h5/hyapp/withdraw-exchange/script.js index 116c54d..a1ff79a 100644 --- a/h5/hyapp/withdraw-exchange/script.js +++ b/h5/hyapp/withdraw-exchange/script.js @@ -69,6 +69,8 @@ income: "Income", expense: "Expense", balance: "Balance", + receive_time: "Receive time", + transfer_time: "Transfer time", period: "Period", days: "Days", target: "Target", @@ -675,12 +677,40 @@ document.body.classList.toggle("salary-history-open", open); } + function formatHistoryDateParts(date) { + const pad = (item) => String(item).padStart(2, "0"); + return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}`; + } + function formatHistoryDate(value) { - if (!value) return ""; - const text = String(value).replace("T", " "); + if (value === null || value === undefined || value === "") return ""; + const raw = String(value).trim(); + if (/^\d{10,13}$/.test(raw)) { + const number = Number(raw); + const date = new Date(raw.length === 10 ? number * 1000 : number); + if (!Number.isNaN(date.getTime())) return formatHistoryDateParts(date); + } + + const text = raw.replace("T", " "); return text.length > 16 ? text.slice(0, 16) : text; } + function rawHistoryTime(item) { + const transferCandidates = [item?.transferTime, item?.transferredAt, item?.transferAt, item?.outTime]; + const receiveCandidates = [item?.receiveTime, item?.receivedAt, item?.receiveAt, item?.incomeTime]; + const commonCandidates = [item?.createTime, item?.createdAt, item?.time, item?.timestamp, item?.updateTime, item?.updatedAt]; + const candidates = Number(item?.type) === 1 + ? transferCandidates.concat(commonCandidates) + : receiveCandidates.concat(commonCandidates); + return candidates.find((candidate) => candidate !== null && candidate !== undefined && candidate !== "") || ""; + } + + function historyTimeLabel(item) { + return Number(item?.type) === 1 + ? message("transfer_time", "Transfer time") + : message("receive_time", "Receive time"); + } + function formatBillPeriod(value) { const text = String(value || ""); if (text.length < 6) return text; @@ -903,7 +933,7 @@ const meta = document.createElement("div"); meta.className = "salary-history-item-meta"; const metaItems = []; - if (item.date) metaItems.push(item.date); + if (item.date) metaItems.push(`${historyTimeLabel(item)}: ${item.date}`); if (item.period) metaItems.push(`${message("period", "Period")}: ${item.period}`); if (item.target) metaItems.push(`${message("target", "Target")}: ${item.target}`); if (item.days) metaItems.push(`${message("days", "Days")}: ${item.days}`); @@ -1067,7 +1097,7 @@ type: item.type, status: item.salaryEvent || "", period: item.billBelong ? formatBillPeriod(item.billBelong) : "", - date: formatHistoryDate(item.createdAt) + date: formatHistoryDate(rawHistoryTime(item)) })) }; } @@ -1089,7 +1119,7 @@ balance: item.balance, type: item.type, status: item.event || "", - date: formatHistoryDate(item.createTime) + date: formatHistoryDate(rawHistoryTime(item)) })) }; }