feat: 优化首页服务入口与租住业务流程

补齐首页待办跳转、押金支付引导和多类租住服务页面能力,统一租客端关键业务流程体验。
This commit is contained in:
liangjian
2026-08-25 13:53:12 +08:00
parent 1111ac148b
commit 9fee2c3a74
41 changed files with 6985 additions and 933 deletions

64
utils/todo-route.js Normal file
View File

@@ -0,0 +1,64 @@
function ensureArray(value) {
return Array.isArray(value) ? value : []
}
function pickFirstText() {
for (let index = 0; index < arguments.length; index += 1) {
const value = arguments[index]
if (value === null || value === undefined) continue
const text = String(value).trim()
if (text) return text
}
return ''
}
function normalizeNumber(value, fallback = 0) {
const num = Number(value)
return Number.isFinite(num) ? num : fallback
}
function normalizeTodoEntry(raw) {
if (raw && typeof raw === 'object') {
return {
...raw,
_todoCode: pickFirstText(raw.code, raw.no, raw.contractNo, raw.billNo, raw.orderNo, raw.referenceTypeNo)
}
}
const text = pickFirstText(raw)
return text ? { code: text, _todoCode: text } : null
}
function extractTodoEntries(item) {
const sourceList = [item && item.items, item && item.codes, item && item.list, item && item.data]
for (let index = 0; index < sourceList.length; index += 1) {
const current = sourceList[index]
if (!Array.isArray(current)) continue
return current.map(entry => normalizeTodoEntry(entry)).filter(Boolean)
}
return []
}
export function extractTodoRows(response) {
const payload = response && response.data !== undefined ? response.data : response
if (Array.isArray(payload)) return payload
if (!payload || typeof payload !== 'object') return []
if (Array.isArray(payload.data)) return payload.data
if (payload.data && Array.isArray(payload.data.data)) return payload.data.data
return []
}
export function normalizeTodoList(rows = []) {
return ensureArray(rows).map((item) => {
const entries = extractTodoEntries(item)
const count = Math.max(normalizeNumber(item && item.count, entries.length), entries.length)
return {
todoType: String(item && item.todoType !== undefined ? item.todoType : ''),
todoTypeDesc: pickFirstText(item && item.todoTypeDesc),
count,
entries,
codes: entries
.map(entry => ({ code: pickFirstText(entry && entry._todoCode) }))
.filter(entry => entry.code)
}
}).filter(item => item.count > 0 || item.entries.length > 0 || item.todoTypeDesc)
}