feat: 优化首页服务入口与租住业务流程
补齐首页待办跳转、押金支付引导和多类租住服务页面能力,统一租客端关键业务流程体验。
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
const RESERVATION_FLOW_STEP = {
|
||||
APPLICATION: 1,
|
||||
INSPECTION: 2,
|
||||
BILL: 3,
|
||||
CONTRACT: 4,
|
||||
CONTRACT: 3,
|
||||
BILL: 4,
|
||||
CHECKIN: 5
|
||||
}
|
||||
|
||||
@@ -90,7 +90,70 @@ export function getReservationCurrentNode(flow = {}) {
|
||||
return null
|
||||
}
|
||||
|
||||
return nodes.find(item => item.isCurrent) || nodes[nodes.length - 1]
|
||||
const currentNodes = nodes.filter(item => item.isCurrent)
|
||||
if (currentNodes.length) {
|
||||
const currentCheckinNode = currentNodes.find(item => (
|
||||
Number(item.step || 0) === RESERVATION_FLOW_STEP.CHECKIN
|
||||
&& String(item.refNo || '').trim()
|
||||
))
|
||||
if (currentCheckinNode) {
|
||||
return currentCheckinNode
|
||||
}
|
||||
|
||||
// 后端偶发会把前序节点也标记成 isCurrent,优先取排序最靠后的当前节点
|
||||
return currentNodes[currentNodes.length - 1]
|
||||
}
|
||||
|
||||
const checkinNode = nodes.find(item => (
|
||||
Number(item.step || 0) === RESERVATION_FLOW_STEP.CHECKIN
|
||||
&& String(item.refNo || '').trim()
|
||||
))
|
||||
if (checkinNode) {
|
||||
return checkinNode
|
||||
}
|
||||
|
||||
return nodes[nodes.length - 1]
|
||||
}
|
||||
|
||||
export function getReservationCurrentFlow(flowList = []) {
|
||||
const flows = normalizeArray(flowList)
|
||||
.filter(item => item && typeof item === 'object')
|
||||
.map(item => ({
|
||||
flow: item,
|
||||
currentNode: getReservationCurrentNode(item)
|
||||
}))
|
||||
.filter(item => item.currentNode)
|
||||
|
||||
if (!flows.length) {
|
||||
return null
|
||||
}
|
||||
|
||||
const compareNode = (target) => {
|
||||
const node = target.currentNode || {}
|
||||
const step = Number(node.step || 0)
|
||||
const sort = Number(node.sort || 0)
|
||||
const refNo = String(node.refNo || '').trim()
|
||||
const isCurrent = !!node.isCurrent
|
||||
const isCheckinWithRefNo = step === RESERVATION_FLOW_STEP.CHECKIN && !!refNo
|
||||
return [
|
||||
isCheckinWithRefNo ? 1 : 0,
|
||||
isCurrent ? 1 : 0,
|
||||
step,
|
||||
sort
|
||||
]
|
||||
}
|
||||
|
||||
return flows
|
||||
.sort((a, b) => {
|
||||
const aScore = compareNode(a)
|
||||
const bScore = compareNode(b)
|
||||
for (let index = 0; index < aScore.length; index += 1) {
|
||||
if (aScore[index] !== bScore[index]) {
|
||||
return bScore[index] - aScore[index]
|
||||
}
|
||||
}
|
||||
return 0
|
||||
})[0].flow
|
||||
}
|
||||
|
||||
export function hasEffectiveReservationFlow(flow = {}) {
|
||||
@@ -149,7 +212,7 @@ export function getReservationStepMeta(step, language = 'zh') {
|
||||
},
|
||||
[RESERVATION_FLOW_STEP.BILL]: {
|
||||
label: currentLanguage === 'en' ? 'Bill' : '账单',
|
||||
actionText: currentLanguage === 'en' ? 'Go to Bill' : '去缴费'
|
||||
actionText: currentLanguage === 'en' ? 'Go to Payment' : '去支付'
|
||||
},
|
||||
[RESERVATION_FLOW_STEP.CONTRACT]: {
|
||||
label: currentLanguage === 'en' ? 'Contract' : '合同',
|
||||
|
||||
Reference in New Issue
Block a user